# smoothTrajectory

## Syntax

## Description

The `smoothTrajectory`

function creates a smooth, jerk-limited
trajectory for an actor in a driving scenario. The generated trajectory features a smooth
transition of accelerations between waypoints, making it compatible for generating synthetic
inertial navigation system (INS) and global navigation satellite system (GNSS) measurements
from an `insSensor`

System object™. For more details on how `smoothTrajectory`

generates
trajectories, see Algorithms.

`smoothTrajectory(___,`

specifies options using one or more name-value pairs and any of the input argument
combinations from previous syntaxes. For example, you can specify the yaw orientation angle
of the actor or vehicle at each waypoint or the maximum amount of jerk in the
trajectory.`Name,Value`

)

## Examples

## Input Arguments

## Tips

If the

`smoothTrajectory`

function is unable to compute a smooth, jerk-limited trajectory given the input parameters, try making these adjustments to the scenario:Extend the distances between waypoints to give the vehicle more time to accelerate to the specified speeds.

Lower the speeds at each waypoint. Try converting the speed values from meters per second to miles per hour to see if the speeds are realistic given the scenario. For example, it is unlikely that the algorithm can compute a smooth trajectory for a sharp turn that is taken at a speed of 30 m/s (about 67 mph).

Increase the maximum jerk. Increasing the jerk maximum enables the algorithm to compute more possible trajectories at the expense of reduced human passenger comfort.

## Algorithms

The `smoothTrajectory`

function creates a jerk-limited trajectory using
a trapezoidal acceleration profile. This trajectory has smooth acceleration transitions
between waypoints, resulting in a comfortable ride for human passengers. The function
calculates a separate trapezoidal acceleration profile for each of the *N* -
1 segments between trajectory waypoints.

Consider a simple scenario in which a car travels a distance of 50 meters along a
100-meter road. The trajectory consists of one 50-meter segment in which the car must increase
its speed from 5 m/s to 10 m/s by the end of the segment. The trajectory has an additional
constraint in which the maximum longitudinal jerk must not exceed 0.5
m/s^{3}.

scenario = drivingScenario; car = vehicle(scenario); road(scenario,[0 -25; 0 75]); % m waypoints = [0 0; 0 50]; % m speed = [5 10]; % m/s jerk = 0.5; % m/s^3 smoothTrajectory(car,waypoints,speed,'Jerk',jerk)

Given the distance, speed, and jerk constraints of this waypoint segment, the
`smoothTrajectory`

function generates a three-phase trapezoidal
acceleration profile:

Increase acceleration linearly. Hold jerk constant at a value no greater than

`jerk`

.Hold acceleration constant. Decrease jerk to 0.

Decrease acceleration linearly. Hold jerk constant at a value no less than

`-jerk`

.

These plots visualize the distance, speed, acceleration, and jerk profile along this waypoint segment over time. The three phases of the acceleration profile form a trapezoidal shape.

When speed decreases between waypoints, the `smoothTrajectory`

function
generates the three-phase trapezoidal acceleration profile in reverse order. In the decreased
speed case, the shape of the acceleration profile is the inverse of the one shown in the
previous plot.

## References

[1] Bae, Il, Jaeyoung Moon, and
Jeongseok Seo. "Toward a Comfortable Driving Experience for a Self-Driving Shuttle Bus."
*Electronics* 8, no. 9 (August 27, 2019): 943. https://doi.org/10.3390/electronics8090943.

## Version History

**Introduced in R2021a**