smoothTrajectory
Syntax
Description
The smoothTrajectory
function creates a smooth, jerk-limited
trajectory for an actor in a driving scenario based on either the speed values or arrival
times of an actor at each waypoint. 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. By default, the function
creates a trajectory for a vehicle whose steering location is at its rear axle. To create a
trajectory for a vehicle whose steering location is at its front axle, use the
ReferenceSteerPosition
name-value argument.
Smoothed Trajectory from Actor Speed Information
smoothTrajectory(___,
specifies options using one or more name-value arguments in addition to any combination of
arguments from the previous syntaxes. For example, Name=Value
)Course=course
specifies the course angle course
, which defines the steering direction
of the actor or vehicle at each waypoint.
Smoothed Trajectory from Actor Arrival Times
Since R2024b
smoothTrajectory(
creates a smoothed trajectory for an actor or vehicle, ac
,waypoints
,TimeOfArrival=timeOfArrival
)ac
, from a set
of waypoints, waypoints
, using the arrival time of the actor at each
waypoint timeOfArrival
.
smoothTrajectory(
specifies options using one or more name-value arguments. For example,
ac
,waypoints
,TimeOfArrival=timeOfArrival
,Name=Value
)MotionDirection=motionDirection
specifies the direction
motionDirection
for the actor to move at each waypoint.
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, the algorithm is unlikely to successfully 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.
To get the position of the vehicle with reference to a specific vehicle body location, use the
getReferencePosition
function.If a driving scenario contains a front-axle trajectory for at least one vehicle, you can get the front-axle position from the
FrontAxlePosition
field of theActorPoses
structure returned by therecord
function.If a driving scenario contains a front-axle trajectory, to plot both the rear-axle and front-axle trajectories, specify the
ShowRearAxle
name-value argument of theplot
function as"on"
.
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/s3.
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.