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."SimulationTimeCondition"— Specifies for the associated phase to end after the specified amount of time has elapsed since the start of the simulation."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 Speedcondition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor reaches the specified speed.DurationCondition— Represents aDurationcondition in the RoadRunner scenario logic that specifies for the associated phase to end after the specified amount of time elapses.CollisionCondition— Represents aCollisioncondition in the RoadRunner scenario logic that specifies for the associated phase to end when the one actor collides with another actor.PhaseStateCondition— Represents aPhase Statecondition 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 Actorcondition 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 Pointcondition 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 Actorcondition in the RoadRunner scenario logic that specifies for the associated phase to end when an actor reaches a certain longitudinal distance from another actor.SimulationTimeCondition— Represents aSimulation Timecondition in the RoadRunner scenario logic that specifies for the associated phase to end after the specified amount of time has elapsed since the start of the simulation.
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.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- 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)