# 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`

,`pp`

] = quinticpolytraj(`wayPoints`

,`timePoints`

,`tSamples`

)`tSamples`

. The function also returns the
piecewise polynomial `pp`

form of the polynomial trajectory with respect
to time.

`[`

specifies additional parameters as `q`

,`qd`

,`qdd`

,`pp`

] = quinticpolytraj(___,`Name,Value`

)`Name,Value`

pair arguments using any
combination of the previous syntaxes.

## Examples

### Compute Quintic Trajectory for 2-D Planar Motion

Use the `quinticpolytraj`

function with a given set of 2-D *xy* waypoints. 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 (`pp`

) of the quintic polynomial.

[q, qd, qdd, pp] = quinticpolytraj(wpts, tpts, tvec);

Plot the quintic trajectories for the *x- *and *y*-positions. Compare the trjactory with each waypoint.

plot(tvec, q) hold all plot(tpts, wpts, 'x') xlabel('t') ylabel('Positions') legend('X-positions','Y-positions') hold off

You can also verify the actual positions in the 2-D plane. Plot the separate rows of the `q`

vector and the waypoints as *x-* and *y- *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-*p* matrix

Points for waypoints of trajectory, specified as an
*n*-by-*p* matrix, where *n* is the
dimension of the trajectory and *p* is 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 a *p*-element
vector.

**Example: **`[0 2 4 5 8 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: **```
'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-*p* matrix

Velocity boundary conditions for each waypoint, specified as the comma-separated
pair consisting of `'VelocityBoundaryCondition'`

and an
*n*-by-*p* matrix. Each row corresponds to the
velocity at all of *p* waypoints 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-*p* matrix

Acceleration boundary conditions for each waypoint, specified as the
comma-separated pair consisting of `'AccelerationBoundaryCondition'`

and an *n*-by-*p* matrix. Each row corresponds to
the acceleration at all of *p* waypoints 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 in
`tSamples`

, returned as an *m*-element vector,
where *m* is the length of `tSamples`

.

**Data Types: **`single`

| `double`

`qd`

— Velocities of trajectory

vector

Velocities of the trajectory at the given time samples in
`tSamples`

, returned as a vector.

**Data Types: **`single`

| `double`

`qdd`

— Accelerations of trajectory

vector

Accelerations of the trajectory at the given time samples in
`tSamples`

, returned as a vector.

**Data Types: **`single`

| `double`

`pp`

— 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 using
`mkpp`

, or evaluate the polynomial at
specified times using `ppval`

. The structure contains the fields:

`form`

:`'pp'`

.`breaks`

:*p*-element vector of times when the piecewise trajectory changes forms.*p*is 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 of`pieces`

. Each set of*n*rows 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™.

## Version History

**Introduced in R2019a**

## See Also

`bsplinepolytraj`

| `cubicpolytraj`

| `rottraj`

| `transformtraj`

| `trapveltraj`

## 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)