Main Content

Route

Sequence of waypoints

Since R2025a

    Description

    The Route object represents a sequence of waypoints that an actor traverses during a simulation and contains data that defines how RoadRunner Scenario should interpolate the points. You can use a Route object to build routes for actors by specifying the route on which to add new points.

    Creation

    To return a Route object from your RoadRunner scenario, extract the Route property of an actor or point. For example, rrRoute = car.InitialPoint.Route extracts the Route property of the InitialPoint property of the actor car and assigns it to the variable rrRoute.

    Properties

    expand all

    Name of the route, specified as a string scalar or character vector.

    This property is read-only.

    Total length of the route, represented as a numeric scalar.

    This property is read-only.

    Control points for the route, represented as a Point object or an array of Point objects.

    This property is read-only.

    Route segments between control points, represented as a RouteSegment object or an array of RouteSegment objects.

    This property is read-only.

    Points include time data, represented as a logical 1 (true) or 0 (false). If one or more points include time data, this property is true.

    This property is read-only.

    Points defining the sampled trace of the route, represented as an N-by-3 numeric matrix where N is the number of points.

    This property is read-only.

    Speed values corresponding to the PositionSamples values, represented as an N-element numeric vector where N is the number of speed values. This property is empty unless one or more points include time data.

    Data Types: double

    This property is read-only.

    Time values corresponding to the PositionSamples values, represented as an N-element numeric vector where N is the number of time values. This property is empty unless one or more points include time data.

    Data Types: double

    Object Functions

    addPointAdd point to route

    Examples

    collapse all

    Use the addPoint function to design a route for an actor in your scenario.

    This example assumes that you have prior knowledge of working with RoadRunner in MATLAB®. Before proceeding, follow the steps outlined in Set Up MATLAB Environment for RoadRunner Authoring Functions to set up your scenario using MATLAB functions for scenario authoring.

    Design Route for Actor

    Design a route for the actor car by extracting the InitialPoint property of car to the variable carPoint. Then, extract the Route property of carPoint to the variable rrRoute. Use addPoint to add a new point to the route rrRoute at the specified location.

    carPoint = car.IninialPoint;
    rrRoute = carPoint.Route;
    roadPoint = addPoint(rrRoute,[0 0 0]);

    If you do not know the exact coordinates at which you want to place the new point, you can quickly align it to the same lane as the actor by using anchorToPoint and specifying the same anchor point anchorPoint as the actor car. Then, set the ForwardOffset property of the new point roadPoint to 50 to move it 50 meters in front of car.

    anchorPoint = car.InitialPoint.AnchorPoint;
    anchorToPoint(roadPoint,anchorPoint,PosePreservation="reset-pose")
    roadPoint.ForwardOffset = 50;

    Run the simulation by using the simulateScenario function. The actor car moves forward along the route until it reaches the end.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a