timor.utilities.rtb_trajectory
Attributes
Classes
A container class for trajectory data. Reduced version of the original, without plotting functionalities. |
Functions
|
Return a vector value |
|
Compute a joint-space trajectory |
|
Multi-segment multi-axis trajectory |
Module Contents
- timor.utilities.rtb_trajectory.ArrayLike
- class timor.utilities.rtb_trajectory.RtbTrajectory(name, t, s, sd=None, sdd=None, istime=False)
A container class for trajectory data. Reduced version of the original, without plotting functionalities.
Construct a new trajectory instance
- Parameters:
name (str) – name of the function that created the trajectory
t (ndarray(m)) – independent variable, eg. time or step
s (ndarray(m) or ndarray(m,n)) – position
sd (ndarray(m) or ndarray(m,n)) – velocity
sdd (ndarray(m) or ndarray(m,n)) – acceleration
istime (float) –
tis time, otherwise step numbertblend – blend duration (
trapezoidalonly)
The object has attributes:
tthe independent variablesthe positionsdthe velocitysddthe acceleration
If
tis time, ie.istimeis True, then the units ofsdandsddare \(s^{-1}\) and \(s^{-2}\) respectively, otherwise with respect tot.Note
Data is stored with timesteps as rows and axes as columns.
- __repr__()
String representation of the trajectory
- __str__()
Print representation of the trajectory
- istime = False
- name
- property naxes
Number of axes in the trajectory
- Returns:
number of axes or dimensions
- Return type:
- property q
Position trajectory
- Returns:
trajectory with one row per timestep, one column per axis
- Return type:
ndarray(n,m)
Note
This is a synonym for
.s, for compatibility with other applications.
- property qd
Velocity trajectory
- Returns:
trajectory velocity with one row per timestep, one column per axis
- Return type:
ndarray(n,m)
Note
This is a synonym for
.sd, for compatibility with other applications.
- property qdd
Acceleration trajectory
- Returns:
trajectory acceleration with one row per timestep, one column per axis
- Return type:
ndarray(n,m)
Note
This is a synonym for
.sdd, for compatibility with other applications.
- s
- sd = None
- sdd = None
- t
- timor.utilities.rtb_trajectory._scalartypes
- timor.utilities.rtb_trajectory.getvector(v, dim=None, out='array', dtype=np.float64)
Return a vector value
- Parameters:
- Returns:
vector value in specified format
- Raises:
TypeError – value is not a list or NumPy array
ValueError – incorrect number of elements
- Return type:
ArrayLike
getvector(vec)isvecconverted to the output formatoutwherevecis any of:a Python native int or float, a 1-vector
Python native list or tuple
numPy real 1D array, ie. shape=(N,)
numPy real 2D array with a singleton dimension, ie. shape=(1,N) or (N,1)
getvector(vec, N)as above but must be anN-element vector.
The returned vector will be in the format specified by
out:format
return type
‘sequence’
Python list, or tuple if a tuple was passed in
‘list’
Python list
‘array’
1D numPy array, shape=(N,) [default]
‘row’
row vector, a 2D numPy array, shape=(1,N)
‘col’
column vector, 2D numPy array, shape=(N,1)
Note
For ‘array’, ‘row’ or ‘col’ output the NumPy dtype defaults to the
dtypeofvif it is a NumPy array, otherwise it is set to the value specified by thedtypekeyword which defaults tonp.float64.If
vis symbolic thedtypeis retained as'O'
- Seealso:
isvector()- Return type:
ArrayLike
- timor.utilities.rtb_trajectory.jtraj(q0, qf, t, qd0=None, qd1=None)
Compute a joint-space trajectory
- Parameters:
q0 (array_like(n)) – initial joint coordinate
qf (array_like(n)) – final joint coordinate
t (array_like or int) – time vector or number of steps
qd0 (array_like(n), optional) – initial velocity, defaults to zero
qd1 (array_like(n), optional) – final velocity, defaults to zero
- Returns:
trajectory
- Return type:
Trajectory instance
tg = jtraj(q0, qf, N)is a joint space trajectory where the joint coordinates vary fromq0(M) toqf(M). A quintic (5th order) polynomial is used with default zero boundary conditions for velocity and acceleration. Time is assumed to vary from 0 to 1 inNsteps.tg = jtraj(q0, qf, t)as above buttis a uniformly-spaced time vector
The return value is an object that contains position, velocity and acceleration data.
Notes:
The time vector, if given, scales the velocity and acceleration outputs assuming that the time vector starts at zero and increases linearly.
- Seealso:
ctraj(),qplot(),jtraj()
- timor.utilities.rtb_trajectory.mstraj(viapoints, dt, tacc, qdmax=None, tsegment=None, q0=None, qd0=None, qdf=None, verbose=False)
Multi-segment multi-axis trajectory
- Parameters:
viapoints (ndarray(m,n)) – A set of viapoints, one per row
dt (float (seconds)) – time step
tacc (float) – acceleration time (seconds)
qdmax (array_like(n) or float, optional) – maximum speed, defaults to None
tsegment (array_like, optional) – maximum time of each motion segment (seconds), defaults to None
q0 (array_like(n), optional) – initial coordinates, defaults to first row of viapoints
qd0 (array_like(n), optional) – inital velocity, defaults to zero
qdf (array_like(n), optional) – final velocity, defaults to zero
verbose (bool, optional) – print debug information, defaults to False
- Returns:
trajectory
- Return type:
Trajectory instance
Computes a trajectory for N axes moving smoothly through a set of viapoints. The motion comprises M segments:
The initial coordinates are the first row of
viapointsorq0if provided.The final coordinates are the last row of
viapointsEach segment is linear motion and polynomial blends connect the viapoints.
All joints arrive at each via point at the same time, ie. the motion is coordinated across axes
The time of the segments can be specified in two different ways:
In terms of segment time where
tsegmentis an array of segment times which is the number of via points minus one:``traj = mstraj(viapoints, dt, tacc, tsegment=TS)``
Governed by the speed of the slowest axis for the segment. The axis speed is a scalar (all axes have the same speed) or an N-vector of speed per axis:
traj = mstraj(viapoints, dt, tacc, qdmax=SPEED)
The return value is a namedtuple (named
mstraj) with elements:tthe time coordinate as a numpy ndarray, shape=(K,)qthe axis values as a numpy ndarray, shape=(K,N)arrivea list of arrival times for each segmentinfoa list of named tuples, one per segment that describe the slowest axis, segment time, and time stampviathe passed set of via points
The trajectory proper is (
traj.t,traj.q). The trajectory is a matrix has one row per time step, and one column per axis.Notes:
Only one of
qdmagortsegmentcan be specifiedIf
taccis greater than zero then the path smoothly accelerates
between segments using a polynomial blend. This means that the the via point is not actually reached. - The path length K is a function of the number of via points and the time or velocity limits that apply. - Can be used to create joint space trajectories where each axis is a joint coordinate. - Can be used to create Cartesian trajectories where the “axes” correspond to translation and orientation in RPY or Euler angle form. - If
qdmaxis a scalar then all axes are assumed to have the same maximum speed. -tghas extra attributesarrive,infoandvia- Seealso:
trapezoidal(),ctraj(),mtraj()