setEndCondition
Description
creates and assigns a condition of the specified type to the end of the specified
phase.rrCondition
= setEndCondition(rrPhase
,conditionType
)
Examples
Assign an end condition to a phase in the RoadRunner scenario logic that instructs the actor car
to stop
after the specified time has elapsed.
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 addPhaseInSerial
to
add a new actor action phase, srPhase
, in serial after the initial
phase. Then, use addAction
to
specify the action of the new phase as "ChangeSpeedAction"
. The
srPhase
object represents the newly created actor action phase in
the scenario logic, and chSpd
represents the Change
Speed
action assigned to srPhase
.
srPhase = addPhaseInSerial(rrLogic,initPhase,"ActorActionPhase",Insertion="after"); chSpd = addAction(srPhase,"ChangeSpeedAction");
Assign an actor to the new phase by specifying car
as the value
of the Actor
property of the phase. Set the
Speed
property of the chSpd
action to
0
. This instructs the assigned actor to change its speed to 0 m/s
during simulation.
srPhase.Actor = car; chSpd.Speed = 0;
Use setEndCondition
to Assign End Condition to Phase
Use the setEndCondition
function to create a DurationCondition
object, rrCondition
, and assign it to the initial phase of the
actor car
.
This adds a Duration
condition to the initial phase
initPhase
in the RoadRunner scenario logic that instructs the actor to perform the action specified
by initphase
until it reaches the value specified by the
Duration
property of the newly added condition
rrCondition
.
rrCondition = setEndCondition(initPhase,"DurationCondition");
rrCondition.Duration = 3;
Run the simulation by using the simulateScenario
function. The
end condition rrCondition
specifies for the initial phase
initphase
to end after 3 seconds, after which the actor
car
enters the next phase srPhase
and changes
its speed to 0 m/s.
simulateScenario(rrApp)
Input Arguments
Existing logic phase to which to assign the condition, specified as one of these objects:
ActorActionPhase
— Logic phase that executes an actor action.SystemActionPhase
— Logic phase that executes a system action.ParallelPhase
— Logic phase that executes child phases concurrently.
Example: rrCondition =
setEndCondition(rrPhase,"ActorSpeedCondition")
assigns an Actor
Speed
end condition, rrCondition
, to the phase
rrPhase
.
Type of condition to assign, specified as one of these condition types:
"ActorSpeedCondition"
— Specifies for the associated phase to end when an actor reaches the specified speed."CollisionCondition"
— Specifies for the associated phase to end when the one actor collides with another actor."DistanceToActorCondition"
— Specifies for the associated phase to end when an actor is a certain distance away from a reference actor."DistanceToPointCondition"
— Specifies for the associated phase to end when an actor is a certain distance away from a specified point."LongitudinalDistanceToActorCondition"
— Specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor."DurationCondition"
— Specifies for the associated phase to end after the specified amount of time elapses."PhaseStateCondition"
— Specifies for the associated phase to end when the referenced phase reaches the specified state.
Output Arguments
Condition assigned to the phase, returned as one of these objects:
ActorSpeedCondition
— Represents anActor Speed
condition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor reaches the specified speed.DurationCondition
— Represents aDuration
condition in the RoadRunner scenario logic that specifies for the associated phase to end after the specified amount of time elapses.CollisionCondition
— Represents aCollision
condition in the RoadRunner scenario logic that specifies for the associated phase to end when the one actor collides with another actor.PhaseStateCondition
— Represents aPhase 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 aDistance 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 aDistance 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 aLongitudinal 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
See Also
roadrunnerAPI
| setFailCondition
| addPhase
| ActorSpeedCondition
| DurationCondition
Topics
- Conditions (RoadRunner Scenario)
- Define Scenario Logic (RoadRunner Scenario)
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)