API Reference v9.2.0
PvtSequenceclass
Module: zaber_motion.ascii
A handle for a PVT sequence with this number on the device. PVT sequences provide a way execute or store trajectory consisting of points with defined position, velocity, and time. PVT sequence methods append actions to a queue which executes or stores actions in a first in, first out order.
The following example illustrates how you can obtain an instance of this type:
from zaber_motion.ascii import Connection
connection = Connection.open_serial_port('COM3')
device = connection.get_device(1)
pvt = device.pvt
pvt_sequence = pvt.get_sequence(1)Related Guides:
Index
mMethods
Properties
p
pvt_sequence.axesList[PvtAxisDefinition] An array of axes definitions the PVT sequence is set up to control.p
p
p
Methods
m
pvt_sequence.call(pvt_buffer)Append the actions in a PVT buffer to the sequence's queue.
Arguments
| Name | Type | Description |
|---|---|---|
| pvt_buffer | PvtBuffer | The PVT buffer to call. |
m
s
PvtSequence.convert_time_absolute_to_relative(sequence_data)Converts the time values in a PvtSequenceItem array from absolute to relative. Points passed to the Generate functions or sent to devices must have relative time values.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtSequenceItem] | The sequence data for which to convert times from absolute to relative. Point times must all be in the same units. |
Return Value
List[PvtSequenceItem] The sequence data with times converted from absolute to relative.s
PvtSequence.convert_time_absolute_to_relative_partial(sequence_data)Converts the time values in a PvtPartialSequenceItem array from absolute to relative. Points passed to the Generate functions or sent to devices must have relative time values.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtPartialSequenceItem] | The sequence data for which to convert times from absolute to relative. Point times must all be in the same units. |
Return Value
List[PvtPartialSequenceItem] The sequence data with times converted from absolute to relative.s
PvtSequence.convert_time_relative_to_absolute(sequence_data)Converts the time values in a PvtSequenceItem array from relative to absolute.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtSequenceItem] | The sequence data for which to convert times from relative to absolute. Point times must all be in the same units. |
Return Value
List[PvtSequenceItem] The sequence data with times converted from relative to absolute.s
PvtSequence.convert_time_relative_to_absolute_partial(sequence_data)Converts the time values in a PvtPartialSequenceItem array from relative to absolute.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtPartialSequenceItem] | The sequence data for which to convert times from relative to absolute. Point times must all be in the same units. |
Return Value
List[PvtPartialSequenceItem] The sequence data with times converted from relative to absolute.m
pvt_sequence.cork()Cork the front of the PVT sequences's action queue, blocking execution. Execution resumes upon uncorking the queue, or when the number of queued actions reaches its limit. Corking eliminates discontinuities in motion due to subsequent PVT commands reaching the device late. You can only cork an idle live PVT sequence.
m
s
PvtSequence.generate_positions(sequence_items)Generates positions for a sequence of velocities and times. This function calculates positions by enforcing that acceleration be continuous at each segment transition.
This function does not modify the input velocities or times, and outputs absolute positions. If your initial point has a time of zero, it will be considered a starting position when submitted to the device, and you must already have moved the device to that position. Additionally, all times must be relative to the previous point. Please see the ConvertTimeAbsoluteToRelativePartial function for conversions.
Does not support native units.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_items | List[PvtPartialSequenceItem] | Partial PVT points defining the velocities and times for the sequence. Each point should have velocities defined for each axis. Times must be defined for each point. |
Return Value
List[PvtSequenceItem] Array of points and actions containing the generated PVT sequence. Note returned times are always relative.s
PvtSequence.generate_velocities(sequence_items)Generates velocities for a sequence of positions and times, and (optionally) a partially defined sequence of velocities. Note that if some velocities are defined, the solver will NOT modify them in any way. If all velocities are defined, the solver will simply return the same velocities. This function calculates velocities by enforcing that acceleration be continuous at each segment transition. The function does not modify the input positions or times.
Also note that if the first position is relative, all following points must be relative. If the start position is absolute, then the sequence can include a mix of relative and absolute positions. Additionally, all times must be relative to the previous point. Please see the ConvertTimeAbsoluteToRelativePartial function for conversions.
Does not support native units.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_items | List[PvtPartialSequenceItem] | Partial PVT points defining the positions, optional velocities, and times for the sequence. Each point should have positions defined for each axis. Velocities are optional. Times must be defined for each point. |
Return Value
List[PvtSequenceItem] Array of points and actions containing the generated PVT sequence. Note returned times are always relative.s
PvtSequence.generate_velocities_and_times(sequence_items, target_speed, target_acceleration, resample_number = None)Generates sequences of velocities and times for a sequence of positions. This function fits a geometric spline (not-a-knot cubic for sequences of >3 points, natural cubic for 3, and a straight line for 2) over the position sequence and then calculates the velocity and time information by traversing it using a trapezoidal motion profile.
This generation scheme attempts to keep speed and acceleration less than the specified target values, but does not guarantee it. Generally speaking, a higher resample number will bring the generated trajectory closer to respecting these limits.
Note that consecutive duplicate points will be automatically removed as they have no geometric significance without additional time information. Also note that for multi-dimensional paths this function expects axes to be linear and orthogonal, however for paths of a single dimension rotary units are accepted. Additionally, if the first positions of the input sequence is relative, all following positions must also be relative. If the first position is absolute, the sequence may contain a mix of relative and absolute positions. Resampling a sequence which contains relative positions is not allowed.
This function outputs points with absolute positions and relative times, with the first time equal to zero, meaning it will be treated as a start position when executing on a device. You must move the device to that position before submitting the sequence, or change the first point's time to a value greater than zero.
Does not support native units.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_items | List[PvtPartialSequenceItem] | Partial PVT points defining the positions for the sequence. Each point should have positions defined for each axis. |
| target_speed | Measurement | The target speed used to generate positions and times. |
| target_acceleration | Measurement | The target acceleration used to generate positions and times. |
| resample_number | Optional[int] | The number of points to resample the sequence by. Leave undefined to use the specified points. |
Return Value
List[PvtSequenceItem] Array of points and actions containing the generated PVT sequence. Note returned times are always relative.m
m
pvt_sequence.generic_command_batch(batch)Sends a batch of generic ASCII commands to the PVT sequence. Keeps resending command while the device rejects with AGAIN reason. The batch is atomic in terms of thread safety.
Arguments
| Name | Type | Description |
|---|---|---|
| batch | List[str] | Array of commands. |
m
m
s
PvtSequence.load_partial_sequence_data(path)Load PVT Sequence data from CSV file, allowing for some combinations of incomplete data. Output from this function cannot be enqueued on a device until the missing data has been filled in using the GenerateVelocities, GeneratePositions or GenerateVelocitiesAndTimes functions.
The CSV data can include a header (recommended). There are two possible header formats:
1. A time column with named position and velocity columns. For example, "Time (ms),X Position (cm),X Velocity (cm/s),...". In this case, position, velocity and time columns are all optional. Also, order does not matter, but position and velocity names must be consistent. This is our recommended CSV format.
2. A time column with alternating position and velocity columns. For example, "Time (ms),Position (cm),Velocity (cm/s),...". In this case, only the time column is optional and order does matter.
Units must be wrapped in parens or square braces: ie. (µm/s), [µm/s]. Additionally, native units are the default if no units are specified. Time values default to milliseconds if no units are provided. If no header is included, then column order is assumed to be "T,P1,V1,P2,V2,...". In this case the number of columns must be odd.
Users can add a column named "Relative" with true/false values to indicate whether each point's position is relative or absolute. If this column is not included, all points will be assumed to be absolute.
If the first point has time = zero, it is considered the start position and treated specially. It must have an absolute position, and the device must already be idle at that position when the sequence is submitted. The velocity of the start position is ignored, and should normally be zero. Sequences with nonzero time for the first point do not have these constraints.
Buffer calls and I/O actions can be added into the CSV file by adding a column titled "Actions", containing the ASCII protocol command(s) shortened by everything up to the PVT stream number, for example "call 2" or "io set do 1 1". If you want to insert multiple actions after a point, put them in the same cell separated by a semicolon. See the ASCII Protocol Manual PVT command reference section for the list of available commands. Unit symbols are not supported; analog output voltages are always in volts and schedule delay times are always in milliseconds.
Note that the Relative and Actions columns are not automatically detected, so if you include them you must include a header row.
Time values should always be relative when sent to a device or to the various Generate... functions on this class. If you want to store absolute times in a CSV file, you can use the ConvertTimeRelativeToAbsolute function to convert after loading the file.
Arguments
| Name | Type | Description |
|---|---|---|
| path | str | The path to the csv file to load. |
Return Value
PvtPartialCsvData The PVT csv data loaded from the file.s
PvtSequence.load_sequence_data(path)Load PVT Sequence data from CSV file. This function expects complete data in the CSV files (a time column and both position and velocity columns for each series). If your CSV file has partial data, use LoadPartialSequenceData instead.
The CSV data can include a header (recommended). There are two possible header formats:
1. A time column with named position and velocity columns. For example, "Time (ms),X Position (cm),X Velocity (cm/s),...". In this case, position, velocity and time columns are all optional. Also, order does not matter, but position and velocity names must be consistent. This is our recommended CSV format.
2. A time column with alternating position and velocity columns. For example, "Time (ms),Position (cm),Velocity (cm/s),...". In this case, only the time column is optional and order does matter.
Units must be wrapped in parens or square braces: ie. (µm/s), [µm/s]. Additionally, native units are the default if no units are specified. Time values default to milliseconds if no units are provided. If no header is included, then column order is assumed to be "T,P1,V1,P2,V2,...". In this case the number of columns must be odd.
Users can add a column named "Relative" with true/false values to indicate whether each point's position is relative or absolute. If this column is not included, all points will be assumed to be absolute.
If the first point has time = zero, it is considered the start position and treated specially. It must have an absolute position, and the device must already be idle at that position when the sequence is submitted. The velocity of the start position is ignored, and should normally be zero. Sequences with nonzero time for the first point do not have these constraints.
Buffer calls and I/O actions can be added into the CSV file by adding a column titled "Actions", containing the ASCII protocol command(s) shortened by everything up to the PVT stream number, for example "call 2" or "io set do 1 1". If you want to insert multiple actions after a point, put them in the same cell separated by a semicolon. See the ASCII Protocol Manual PVT command reference section for the list of available commands. Unit symbols are not supported; analog output voltages are always in volts and schedule delay times are always in milliseconds.
Note that the Relative and Actions columns are not automatically detected, so if you include them you must include a header row.
Time values should always be relative when sent to a device or to the various Generate... functions on this class. If you want to store absolute times in a CSV file, you can use the ConvertTimeRelativeToAbsolute function to convert after loading the file.
Arguments
| Name | Type | Description |
|---|---|---|
| path | str | The path to the csv file to load. |
Return Value
PvtCsvData The PVT csv data loaded from the file.m
pvt_sequence.point(positions, velocities, time)Queues a point with absolute coordinates in the PVT sequence. If some or all velocities are not provided, the sequence calculates the velocities from surrounding points using finite difference. If time value is zero, the device must already be idle at the specified position and the specified velocity must be zero. The last point of the sequence must have defined velocity (likely zero).
Arguments
| Name | Type | Description |
|---|---|---|
| positions | List[Measurement] | Positions for the axes to move through, relative to their home positions. |
| velocities | List[Optional[Measurement]] | The axes velocities at the given point. Specify an empty array or null for specific axes to make the sequence calculate the velocity. |
| time | Measurement | The duration between the previous point in the sequence and this one. |
m
pvt_sequence.point_relative(positions, velocities, time)Queues a point with coordinates relative to the previous point in the PVT sequence. If some or all velocities are not provided, the sequence calculates the velocities from surrounding points using finite difference.
The time value must be greater than zero, and each point must have its time value measured relative to the previous point or unexpected behavior will result.
The last point of the sequence must have defined velocity (likely zero).
Arguments
| Name | Type | Description |
|---|---|---|
| positions | List[Measurement] | Positions for the axes to move through, relative to the previous point. |
| velocities | List[Optional[Measurement]] | The axes velocities at the given point. Specify an empty array or null for specific axes to make the sequence calculate the velocity. |
| time | Measurement | The duration between the previous point in the sequence and this one. |
m
pvt_sequence.points(positions, velocities, times)Queues points with absolute coordinates in the PVT sequence. Each point must have its time value measured relative to the previous point or unexpected behavior will result.
Note that if the first time value is zero, the device must already be idle at the position of the first point and the velocity of that point must be zero. All other time values must be greater than zero.
Arguments
| Name | Type | Description |
|---|---|---|
| positions | List[MeasurementSequence] | Per-axis sequences of positions. |
| velocities | List[MeasurementSequence] | Per-axis sequences of velocities. For velocities [v0, v1, ...] and positions [p0, p1, ...], v1 is the target velocity at point p1. |
| times | MeasurementSequence | Segment times from one point to another. For times [t0, t1, ...] and positions [p0, p1, ...], t1 is the time it takes to move from p0 to p1. |
m
pvt_sequence.points_relative(positions, velocities, times)Queues points with coordinates relative to the previous point in the PVT sequence. All time values must be greater than zero and each point must have its time value measured relative to the previous point or unexpected behavior will result.
Arguments
| Name | Type | Description |
|---|---|---|
| positions | List[MeasurementSequence] | Per-axis sequences of positions. |
| velocities | List[MeasurementSequence] | Per-axis sequences of velocities. For velocities [v0, v1, ...] and positions [p0, p1, ...], v1 is the target velocity at point p1. |
| times | MeasurementSequence | Segment times from one point to another. For times [t0, t1, ...] and positions [p0, p1, ...], t1 is the time it takes to move from p0 to p1. |
s
PvtSequence.save_sequence_data(sequence_data, path, dimension_names = None)Saves PvtSequenceItem array as a csv file. Save format is compatible with Zaber Launcher PVT Editor App.
Normally a sequence in memory should have relative time values on the points. If you want to store absolute times instead, you can use the ConvertTimeRelativeToAbsolute function to convert before saving.
Throws InvalidArgumentException if fields are undefined or inconsistent. For example, position and velocity arrays must have the same dimensions. Sequence lengths must be consistent for positions, velocities and times.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtSequenceItem] | The PVT sequence data to save. |
| path | str | The path to save the file to. |
| dimension_names | Optional[List[str]] | Optional csv column names for each series. If not provided, the default names will be used: Series 1, Series 2, etc.. Length of this array must be equal to number of dimensions in sequence data. |
m
m
pvt_sequence.setup_live_composite(*pvt_axes)Setup the PVT sequence to control the specified axes and to queue actions on the device. Allows use of lockstep axes in a PVT sequence.
Arguments
| Name | Type | Description |
|---|---|---|
| *pvt_axes | PvtAxisDefinition | Definition of the PVT sequence axes. |
m
pvt_sequence.setup_store(pvt_buffer, *axes)Setup the PVT sequence to use the specified axes and queue actions into a PVT buffer.
Arguments
| Name | Type | Description |
|---|---|---|
| pvt_buffer | PvtBuffer | The PVT buffer to queue actions in. |
| *axes | int | The axis numbers of the physical axes to setup the PVT sequence on. |
m
pvt_sequence.setup_store_composite(pvt_buffer, *pvt_axes)Setup the PVT sequence to use the specified axes and queue actions into a PVT buffer. Allows use of lockstep axes in a PVT sequence.
Arguments
| Name | Type | Description |
|---|---|---|
| pvt_buffer | PvtBuffer | The PVT buffer to queue actions in. |
| *pvt_axes | PvtAxisDefinition | Definition of the PVT sequence axes. |
m
pvt_sequence.submit_sequence_data(sequence_data)Writes the contents of a PvtSequenceItem array to the sequence. Each point must have its time value measured relative to the previous point or unexpected behavior will result. If your point times are absolute (measured from the start of the sequence), use the ConvertTimeAbsoluteToRelative function to convert them before submitting.
If the first point in the sequence has a time value of zero, it is considered the starting position. It must have an absolute position, zero velocity, and the device must already be idle at the specified position.
Arguments
| Name | Type | Description |
|---|---|---|
| sequence_data | List[PvtSequenceItem] | The PVT sequence data to submit. |
m
m
m