Main Content

RouteSegment

Route segment

Since R2025a

    Description

    A RouteSegment object represents a route segment in a RoadRunner scenario. A route segment connects two successive points in a route and influences how RoadRunner Scenario interpolates the space between the points.

    Creation

    To retrieve a RouteSegment object from your RoadRunner scenario, extract an element from the Segments property of a Route object. For example, segment1 = rrRoute.Segments(1) extracts the first RouteSegment object from the Segments property of the route rrRoute and assigns it to the variable segment1.

    Properties

    expand all

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

    Note

    You can specify the Name property of RouteSegment in MATLAB®, but RoadRunner Scenario does not display the Name property of route segments in the user interface.

    Route segment curve type, specified as one of these options:

    • "cubic" — The route segment follows a cubic polynomial curve.

    • "clothoid" — The route segment follows a clothoid curve, where the curve changes linearly with distance.

    • "clothoid-turn" — The route segment follows a series of clothoid curves and a circular arc to navigate a change in heading.

    To use this property, you must set the value of the Freeform property to 1(true).

    Angle of the turn taken by the circular arc of the clothoid spline, specified as a numeric scalar.

    To use this property, you must set the value of the CurveType property to "clothoid-turn".

    Angle of the turn taken by one portion of the clothoid spline, specified as a numeric scalar.

    To use this property, you must set the value of the CurveType property to "clothoid-turn".

    Preferred radius of the circular arc of the turn, based on point location and the value of ClothoidTurnProportion, specified as a numeric scalar. Because the distance between points on the route and the total angle of the clothoid turn constrain the clothoid arc radius, the route segment might not achieve the ClothoidTurnPreferredRadius value.

    To use this property, you must set the value of the CurveType property to "clothoid-turn".

    Clothoid proportion percentage value, specified as a numeric scalar in the range [0,100].

    To use this property, you must set the value of the CurveType property to "clothoid-turn".

    Road geometry is independent of route shape, specified as a logical 1 (true) or 0 (false). If true, the road geometry does not influence the shape of the route between points.

    This property is read-only.

    Point at the start of the segment, represented as a Point object.

    This property is read-only.

    Point at the end of the segment, represented as a Point object.

    This property is read-only.

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

    Examples

    collapse all

    Use the addPoint function to create a route for an actor, then extract the object for one of the route segments.

    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.

    Extract RouteSegment Object from Route

    Extract the route for the actor car from the Route property of its InitialPoint property.

    rrRoute = car.InitialPoint.Route;

    Use the addPoint function to add two points to the route rrRoute at different positions.

    rrPoint = addPoint(rrRoute,[0 -10 0]);
    rrPoint2 = addPoint(rrRoute,[5 -50 0]);

    Use autoAnchor to anchor the new points to the road. Specify the PosePreservation argument as "reset-pose" to specify for the points to adjust their positions to align within the nearest lane. The shape of the route changes to follow the direction of the lane it is in.

    autoAnchor(rrPoint,PosePreservation="reset-pose")
    autoAnchor(rrPoint2,PosePreservation="reset-pose")

    Extract the first segment of the route segments on the route by extracting the first element of the Segments property of the route rrRoute.

    segment1 = rrRoute.Segments(1)

    Version History

    Introduced in R2025a