Main Content

generateWaypoints

Generate waypoints to perform lane change and lane drift

Since R2024a

Description

Lane Change Waypoints

[waypoints,yaw] = generateWaypoints(descriptor,"LaneChange",source,destination) generates waypoints, waypoints, and yaw angles, yaw, to change lanes from a source lane, source, to a destination lane, destination, for the input scenario descriptor, descriptor.

example

[___] = generateWaypoints(descriptor,"LaneChange",source,laneChangeDistance) generates waypoints from a source, source, to a destination on its left lane located at a specified distance, laneChangeDistance, along the travel direction of lane.

example

[___] = generateWaypoints(___,Name=Value) specifies options using one or more name-value arguments in addition to any combination of arguments from previous syntaxes. For example, NumSamples=10 generates waypoints that contain 10 samples.

example

Lane Drift Waypoints

[waypoints,yaw] = generateWaypoints(descriptor,"LaneDrift",source,radiusOfCurvature,driftType,driftValue,actorWidth) generates waypoints for the vehicle to drift out of the source lane based on the specified drift curvature, type, and lateral distance or angle, as well as the actor width.

example

[___] = generateWaypoints(descriptor,"LaneDrift",source,radiusOfCurvature,driftType,driftValue,actorWidth,Name=Value) specifies options using one or more name-value arguments.

Note

This function requires the Automated Driving Toolbox™ Test Suite for Euro NCAP® Protocols support package. You can install the Automated Driving Toolbox Test Suite for Euro NCAP Protocols support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

example

Examples

collapse all

Load a driving scenario into the workspace.

load("scenarioWithLanes.mat")

Create a scenario descriptor from the loaded driving scenario.

descriptor = getScenarioDescriptor(scenario,Simulator="DrivingScenario");

Initialize lane change parameters.

source = [13 -0.14 0];       % Units are in meters
destination1 = [54.7 4.5 0]; % Units are in meters
destination2 = [-15 4.5 0];  % Units are in meters
laneChangeDistance = 30;     % Units are in meters

Generate waypoints using the source and destination parameters.

waypoints1 = generateWaypoints(descriptor,"LaneChange",source,destination1);

Generate a trajectory from source to destination that contains 1000 sample waypoints.

waypoints2 = generateWaypoints(descriptor,"LaneChange",source,destination2,NumSamples=1000);

Generate waypoints using the source and laneChangeDistance parameters.

waypoints3 = generateWaypoints(descriptor,"LaneChange",source,laneChangeDistance);

Generate waypoints to perform a lane change to the lane on the right side of the actor lane.

waypoints4 = generateWaypoints(descriptor,"LaneChange",source,laneChangeDistance,Direction="right");

Generate waypoints in the opposite of the lane direction in the driving scenario.

waypoints5 = generateWaypoints(descriptor,"LaneChange",source,laneChangeDistance,LaneDirectionality="opposite");

Visualize the five sets of generated waypoints.

plot(scenario)
hold on
plot(waypoints1(:,1),waypoints1(:,2),"r")
plot(waypoints2(:,1),waypoints2(:,2),"g")
plot(waypoints3(:,1),waypoints3(:,2),"b")
plot(waypoints4(:,1),waypoints4(:,2),"y")
plot(waypoints5(:,1),waypoints5(:,2),"k")
hold off
axis([-20 70 -20 30])

Load a driving scenario into the workspace.

load("scenarioWithLanes.mat")

Create a scenario descriptor from the scenario.

descriptor = getScenarioDescriptor(scenario,Simulator="DrivingScenario");

Initialize lane drift parameters.

actorWidth = 1.8;         % Units are in meters
radiusOfCurvature = 1200; % Units are in meters 
driftType = "curveDriftDistance";
driftValue = 0.54;       % Units are in meters
lateralDistanceD1 = 0.54; % Units are in meters
lateralDistanceD2 = 0.6; % Units are in meters
laneYCoordinate = 1.9;   % Units are in meters
descY = laneYCoordinate - (lateralDistanceD1 + lateralDistanceD2 + actorWidth/2);
source =  [13 descY 0];

Generate waypoints to drift the actor to the lane on the left side of the actor lane.

waypoints1 = generateWaypoints(descriptor,"LaneDrift",source,radiusOfCurvature,driftType,driftValue,actorWidth);

Generate waypoints to drift the actor to the lane on the right side of the actor lane.

waypoints2 = generateWaypoints(descriptor,"LaneDrift",source,radiusOfCurvature,driftType,driftValue,actorWidth,Direction="right");

Visualize the two sets of generated waypoints.

plot(scenario)
hold on
plot(waypoints1(:,1),waypoints1(:,2),"r")
plot(waypoints2(:,1),waypoints2(:,2),"g")
hold off
axis([0 120 -20 30])

Input Arguments

collapse all

Scenario descriptor, specified as a ScenarioDescriptor object. The ScenarioDescriptor object stores the scene, actor, and vehicle information of a seed scenario.

To get a ScenarioDescriptor object from an input scenario, use the getScenarioDescriptor function.

Source position from which to start waypoint generation, specified as a two-element row vector of the form [x y] or a three-element row vector of the form [x y z]. Units are in meters.

Destination position at which to end waypoint generation, specified as a two-element row vector of the form [x y] or a three-element row vector of the form [x y z]. Units are in meters.

Total lane change travel distance, specified as a positive scalar. Units are in meters.

Radius of curvature of the lane drift, specified as a positive scalar. Units are in meters. For more information, see Lane Drift Parameters.

Drift component to specify, specified as "curveDriftDistance" or "driftAngle". This argument specifies whether the function uses the lateral distance or the angle of trajectory during the drift to generate waypoints, as well as which value you must specify for the driftValue argument.

Drift component value, specified as a positive scalar. The specified driftType value determines what the driftValue argument specifies.

  • "curveDriftDistance" — Lateral distance travelled during the curve establishing the drift angle. Units are in meters.

  • "driftAngle" — Angle of trajectory during the drift. Units are in radians.

For more information, see Lane Drift Parameters.

Width of the actor, specified as a positive scalar. Units are in meters. For more information, see Lane Drift Parameters.

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.

Example: generateWaypoints(descriptor,"LaneChange",source,destination,NumSamples=10) generates waypoints containing 10 samples.

Number of lanes to change, specified as a scalar.

Dependencies

To specify this argument, you must use one of these syntaxes:

  • The second input argument is "LaneChange" and the fourth input argument is laneChangeDistance.

  • The second input argument is "LaneDrift".

Perpendicular distance between the destination and the nearest lane edge, specified as a positive scalar. Units are in meters.

Dependencies

To specify this argument, you must specify the second input argument as "LaneChange" and the fourth input argument as laneChangeDistance.

Distance from the source location to the location before the actor drifts, specified as a positive scalar. Units are in meters.

Dependencies

To specify this argument, you must specify the second input argument as "LaneDrift".

Distance from the location after the actor drifts to the destination location, specified as a positive scalar. Units are in meters.

Dependencies

To specify this argument, you must specify the second input argument as "LaneDrift".

Direction of the end waypoint with reference to the source, specified as "left" or "right".

Radius of curvature for lane change, specified as a positive scalar. Units are in meters.

Dependencies

To specify this argument, you must specify the second input argument as "LaneChange".

Number of waypoint samples to generate, specified as a positive scalar.

Direction of lane change with reference to lane direction in the input scenario descriptor, specified as "laneDirection" or "opposite".

For each lane, "laneDirection" aligns with the direction of travel of the lane, while "opposite" is in the opposing direction of travel.

Output Arguments

collapse all

Waypoints of the actor, returned as an N-by-3 matrix. N is the number of waypoints. Each row represents the position of the actor in the form [x y z]. Units are in meters.

Yaw angles of the actor, returned as an N-element row vector. Yaw values are relative to the corresponding values of waypoints. Units are in radians.

Limitations

The function does not support generating waypoints for the roads with composite lanes specified by the compositeLaneSpec objects.

More About

collapse all

Lane Drift Parameters

To generate waypoints using the "LaneDrift" input argument, as per Euro NCAP standards, the source must be located at a distance from the lane edge

curveDriftDistance + actorWidth/2 + lateralDistanceD2,

where,

  • curveDriftDistance is the lateral distance traveled during the curve that establishes the driftAngle.

  • actorWidth is the width of the actor.

  • lateralDistanceD2 is the lateral distance traveled after the curve that establishes the driftAngle, but before crossing the lane edge.

Figure describing a scenario that contains lane drift parameters.

References

[1] European New Car Assessment Programme (Euro NCAP). Test Protocol – Lane Support Systems. Version 4.2. Euro NCAP, November 2022. https://cdn.euroncap.com/media/75440/euro-ncap-lss-test-protocol-v42.pdf

Version History

Introduced in R2024a