transformtraj
Generate trajectories between two transformations
Syntax
Description
Examples
Interpolate Between Homogenous Transformations
Build transformations from two orientations and positions. Specify the time interval and vector of times for interpolating.
t0 = axang2tform([0 1 1 pi/4])*trvec2tform([0 0 0]); tF = axang2tform([1 0 1 6*pi/5])*trvec2tform([1 1 1]); tInterval = [0 1]; tvec = 0:0.01:1;
Interpolate between the points. Plot the trajectory using plotTransforms
. Convert the transformations to quaternion rotations and linear transitions. The figure shows all the intermediate transformations of the coordinate frame.
[tfInterp, v1, a1] = transformtraj(t0,tF,tInterval,tvec); rotations = tform2quat(tfInterp); translations = tform2trvec(tfInterp); plotTransforms(translations,rotations) xlabel('X') ylabel('Y') zlabel('Z')
Interpolate Between SE(3) Transformations
Build the first transformation from an axis-angle rotation and build the final transformation from both an axis-angle rotation and a translation.
t0 = se3([0 1 1 pi/4],"axang"); tF = se3([1 0 1 6*pi/5],"axang")*se3([1 1 1],"trvec");
Specify the time interval and vector of times for interpolating.
tInterval = [0 1]; tvec = 0:0.01:1;
Interpolate between the transformations. Plot the trajectory using plotTransforms
.
[tfInterp] = transformtraj(t0,tF,tInterval,tvec); plotTransforms(tfInterp(1:10:end))
Input Arguments
T0
— Initial transformation
4-by-4 homogeneous transformation | se3
object
Initial transformation, specified as a 4-by-4 homogeneous transformation or a scalar
se3
object.
The function generates a trajectory that starts at the initial transformation,
T0
, and goes to the final transformation,
TF
.
T0
and TF
must be of the same type. For
example, if T0
is a scalar se3
object, then
TF
must be a scalar se3
object.
Data Types: single
| double
TF
— Final transformation
4-by-4 homogeneous transformation | se3
object
Final transformation, specified as a 4-by-4 homogeneous transformation or a scalar
se3
object.
The function generates a trajectory that starts at the initial transformation,
T0
, and goes to the final transformation,
TF
.
T0
and TF
must be of the same type. For
example, if T0
is a scalar se3
object, then
TF
must be a scalar se3
object.
Data Types: single
| double
tInterval
— Start and end times for trajectory
two-element vector
Start and end times for the trajectory, specified as a two-element vector in seconds.
Example: [0 10]
Data Types: single
| double
tSamples
— Time samples for trajectory
m-element vector
Time samples for the trajectory, specified as an m-element vector in seconds.
Example: 0:0.01:10
Data Types: single
| double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: TimeScaling=[0 1 1; 0 1 0; 0 0 0]
TimeScaling
— Time scaling vector and first two derivatives
3-by-m vector
Time scaling vector and the first two derivatives, specified as a
3-by-m vector, where m is the length of
tSamples
. By default, the time scaling is a linear time scaling
between the time points in tInterval
.
For a nonlinear time scaling, specify the values of the time points as position time scaling in the first row. The second and third rows are the first and second derivative of the first row, 1/s and 1/s2, respectively. For example, to follow the path with a linear velocity to the halfway point, and then jump to the end, the time-scaling would be:
s(1,:) = [0 0.25 0.5 1 1 1] % Position time scaling, s(t) s(2,:) = [1 1 1 0 0 0] % Velocity time scaling, ds/dt s(3,:) = [0 0 0 0 0 0] % Acceleration time scaling, d^2s/dt^2
Data Types: single
| double
Output Arguments
tforms
— Transformation trajectory
4-by-4-by-m homogeneous transformation matrix array | m-element array of se3
objects
Transformation trajectory, returned as a 4-by-4-by-m homogeneous
transformation matrix array or an m-element array of
se3
objects. m is the number of points in
tSamples
.
vel
— Transformation velocities
6-by-m matrix
Transformation velocities, returned as a 6-by-m matrix in m/s,
where m is the number of points in tSamples
. The
first three elements are the angular velocities, and the second three elements are the
velocities in time.
acc
— Transformation accelerations
6-by-m matrix
Transformation accelerations, returned as a 6-by-m matrix in
m/s2, where m is the number of points in
tSamples
. The first three elements are the angular accelerations,
and the second three elements are the accelerations in time.
References
[1] Lynch, Kevin M., and Frank C. Park. Modern Robotics: Mechanics, Planning, and Control. Cambridge University Press, 2017.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2019aR2023a: transformtraj
supports SE(3) transformation object inputs
The T0
and TF
arguments of
transformtraj
now accept se3
objects and
the resulting output value for the tforms
argument is an
m-element array of se3
objects. m
is the number of points in tSamples
.
See Also
bsplinepolytraj
| contopptraj
| cubicpolytraj
| quinticpolytraj
| rottraj
| trapveltraj
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)