Main Content

Create actor or vehicle trajectory in driving scenario

The `trajectory`

function creates a trajectory for an actor to
follow in a scenario. A trajectory consists of the path followed by an object and its
speed along the path. You specify the path using *N* two-dimensional or
three-dimensional waypoints. Each of the *N* – 1 segments between
waypoints defines a curve whose curvature varies linearly with distance along the
segment. The function fits a piecewise *clothoid* curve to the
(*x*, *y*) coordinates of the waypoints by
matching the curvature on both sides of the waypoint. For a nonclosed curve, the
curvature at the first and last waypoint is zero. If the first and last waypoints
coincide, then the curvatures before and after the endpoints are matched. The
*z*-coordinates of the trajectory are interpolated using a
shape-preserving piecewise cubic curve.

You can specify speed as a scalar or a vector. When speed is a scalar, the actor
follows the trajectory with constant speed. When speed is an
*N*-element vector, speed is linearly interpolated between waypoints.
Setting the speed to zero at two consecutive waypoints creates a stationary
actor.