Main Content

addPoint

Add point to route

Since R2025a

    Description

    point = addPoint(rrRoute,position) adds a point to the end of the specified route at the specified position.

    example

    Examples

    collapse all

    Use the addPoint function to create a route for an actor.

    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.

    Use addPoint to Create 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 three points to the route rrRoute at different positions.

    rrPoint = addPoint(rrRoute,[0 -10 0]);
    rrPoint2 = addPoint(rrRoute,[5 -50 0]);
    rrPoint3 = addPoint(rrRoute,[-5 -100 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.

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

    Run the simulation by using the simulateScenario function. The actor car follows the path specified by the new route until it reaches the end.

    simulateScenario(rrApp)

    Input Arguments

    collapse all

    Route to which to add a point, specified as a Route object.

    Example: point = addPoint(rrRoute,[0 0 0]) adds a point to the route rrRoute at the world origin.

    World position at which to place the point, specified as a three-element vector.

    Output Arguments

    collapse all

    Scenario route point, returned as a Point object.

    Version History

    Introduced in R2025a