quinticpolytraj
Generate fifth-order trajectories
Syntax
Description
[
generates a fifth-order polynomial that achieves a given set of input waypoints with corresponding time points. The function outputs positions, velocities, and accelerations at the given time samples,q
,qd
,qdd
,页
] = quinticpolytraj(wayPoints
,timePoints
,tSamples
)tSamples
. The function also returns the piecewise polynomial页
form of the polynomial trajectory with respect to time.
[
specifies additional parameters asq
,qd
,qdd
,页
] = quinticpolytraj(___,Name,Value
)Name,Value
pair arguments using any combination of the previous syntaxes.
Examples
计算五次为二维平面运动轨迹
Use thequinticpolytraj
function with a given set of 2-Dxywaypoints. Time points for the waypoints are also given.
wpts = [1 4 4 3 -2 0; 0 1 2 4 3 1]; tpts = 0:5;
Specify a time vector for sampling the trajectory. Sample at a smaller interval than the specified time points.
tvec = 0:0.01:5;
Compute the quintic trajectory. The function outputs the trajectory positions (q
), velocity (qd
), acceleration (qdd
), and polynomial coefficients (页
) of the quintic polynomial.
[q, qd, qdd, pp] = quinticpolytraj(wpts, tpts, tvec);
Plot the quintic trajectories for thex-andy-positions. Compare the trjactory with each waypoint.
plot(tvec, q) holdallplot(tpts, wpts,'x') xlabel('t') ylabel('Positions') legend('X-positions','Y-positions') holdoff
You can also verify the actual positions in the 2-D plane. Plot the separate rows of theq
vector and the waypoints asx-andy-positions.
figure plot(q(1,:),q(2,:),'.b',wpts(1,:),wpts(2,:),'or') xlabel('X') ylabel('Y')
Input Arguments
wayPoints
—Waypoints for trajectory
n-by-pmatrix
Points for waypoints of trajectory, specified as ann-by-pmatrix, wherenis the dimension of the trajectory andpis the number of waypoints.
Example:[1 4 4 3 -2 0; 0 1 2 4 3 1]
Data Types:single
|double
timePoints
—Time points for waypoints of trajectory
p-element vector
Time points for waypoints of trajectory, specified as ap-element vector.
Example:[0 2 4 5 8 10]
Data Types:single
|double
Name-Value Arguments
Specify optional comma-separated pairs ofName,Value
arguments.Name
is the argument name andValue
is the corresponding value.Name
must appear inside quotes. You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN
.
'VelocityBoundaryCondition',[1 0 -1 -1 0 0; 1 1 1 -1 -1 -1]
VelocityBoundaryCondition
—Velocity boundary conditions for each waypoint
zeroes(n,p)
(default) |n-by-pmatrix
Velocity boundary conditions for each waypoint, specified as the comma-separated pair consisting of'VelocityBoundaryCondition'
and ann-by-pmatrix. Each row corresponds to the velocity at all ofpwaypoints for the respective variable in the trajectory.
Example:[1 0 -1 -1 0 0; 1 1 1 -1 -1 -1]
Data Types:single
|double
AccelerationBoundaryCondition
—Acceleration boundary conditions for each waypoint
zeroes(n,p)
(default) |n-by-pmatrix
Acceleration boundary conditions for each waypoint, specified as the comma-separated pair consisting of'VelocityBoundaryCondition'
and ann-by-pmatrix. Each row corresponds to the acceleration at all ofpwaypoints for the respective variable in the trajectory.
Example:[1 0 -1 -1 0 0; 1 1 1 -1 -1 -1]
Data Types:single
|double
Output Arguments
q
— Positions of trajectory
m-element vector
Positions of the trajectory at the given time samples intSamples
, returned as anm-element vector, wheremis the length oftSamples
.
Data Types:single
|double
qd
— Velocities of trajectory
vector
Velocities of the trajectory at the given time samples intSamples
, returned as a vector.
Data Types:single
|double
qdd
— Accelerations of trajectory
vector
Accelerations of the trajectory at the given time samples intSamples
, returned as a vector.
Data Types:single
|double
页
— Piecewise-polynomial
structure
Piecewise-polynomial, returned as a structure that defines the polynomial for each section of the piecewise trajectory. You can build your own piecewise polynomials usingmkpp
, or evaluate the polynomial at specified times using页val
. The structure contains the fields:
form
:'pp'
.breaks
:p-element vector of times when the piecewise trajectory changes forms.pis the number of waypoints.coefs
:n(p–1)-by-order
matrix for the coefficients for the polynomials.n(p–1) is the dimension of the trajectory times the number ofpieces
. Each set ofnrows defines the coefficients for the polynomial that described each variable trajectory.pieces
:p–1. The number of breaks minus 1.order
: Degree of the polynomial + 1. For example, cubic polynomials have an order of 4.dim
:n. The dimension of the control point positions.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
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)