Main Content

remove

Remove condition object from RoadRunner scenario

Since R2025a

    Description

    remove(rrCondition) removes the specified condition object from the current scenario.

    Examples

    collapse all

    By default, RoadRunner Scenario automatically adds a Collision condition to the scenario Fail Conditions when you create a new scenario. This Collision condition specifies for RoadRunner Scenario to fail the simulation if any actor collides with any other actor.

    Use the remove function to remove the default Collision condition from your scenario logic to specify for the simulation to continue after an actor collides with another 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.

    Add Second Actor to Scenario

    Add a second vehicle actor, staticCar, to the scenario and anchor it to the "ScenarioStart" scene anchor.

    staticCar = addActor(scnro,mySedan,[0 0 0]);
    StaticPoint = findSceneAnchor(scnro,"ScenarioStart");
    staticCarPoint = staticCar.InitialPoint;
    anchorToPoint(staticCarPoint,StaticPoint,PosePreservation="reset-pose")
    

    Specify the Name property of the new actor, so you can more easily distinguish the two actors in the scenario logic. Name staticCar as "StaticCar". Then, set the ForwardOffset property of staticCar to 30 m, so it does not overlap the position of car on the road.

    staticCar.Name = "StaticCar";
    staticCar.InitialPoint.ForwardOffset = 30;
    

    Use initialPhaseForActor to extract the object for the initial phase of staticCar. Then, use the findActions function to extract the ChangeSpeedAction object from that phase and change the Speed property of the action to 0 m/s.

    staticCarPhase = initialPhaseForActor(rrLogic,staticCar);
    staticCarAction = findActions(staticCarPhase,"ChangeSpeedAction");
    staticCarAction.Speed = 0;
    

    Remove Scenario Fail Condition

    Retrieve the existing CollisionCondition object for the scenario collisionCondition by extracting the FailCondition property of the RootPhase property of the scenario phase logic object rrLogic.

    collisionCondition = rrLogic.RootPhase.FailCondition;

    Use the remove function to remove the fail condition collisionCondition, enabling the simulation to continue after car collides with staticCar.

    remove(collisionCondition)

    Run the simulation by using the simulateScenario function.

    simulateScenario(rrApp)

    Input Arguments

    collapse all

    Condition object to remove, specified as one of these objects:

    • ActorSpeedCondition — Represents an Actor Speed condition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor reaches the specified speed.

    • DurationCondition — Represents a Duration condition in the RoadRunner scenario logic that specifies for the associated phase to end after the specified amount of time elapses.

    • CollisionCondition — Represents a Collision condition in the RoadRunner scenario logic that specifies for the associated phase to end when one actor collides with another actor.

    • PhaseStateCondition — Represents a Phase State condition in the RoadRunner scenario logic that specifies for the associated phase to end when the referenced phase reaches the specified state.

    • DistanceToActorCondition — Represents a Distance To Actor condition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor is a certain distance away from a reference actor.

    • DistanceToPointCondition — Represents a Distance To Point condition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor is a certain distance away from a specified point.

    • LongitudinalDistanceToActorCondition — Represents a Longitudinal Distance To Actor condition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.

    Version History

    Introduced in R2025a