Open and Validate Existing Scenario
Create a roadrunner
object, specifying the path to an existing
project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject"
. This code
assumes that RoadRunner is installed in the default location, and returns an object,
rrApp
, that provides functions for performing basic tasks such as
opening, closing, and saving scenes and projects.
Open an existing scenario in RoadRunner by using the openScenario
function, specifying the
roadrunner
object rrApp
and the filename of
the CutInAndSlow.rrscenario
scenario.
Create an object for the RoadRunner authoring API, rrAPI
, that references the object for
the current RoadRunner instance rrApp
. The rrApi
object
enables you to programmatically author scenarios, such as by adding and modifying
actors and logic components, using MATLAB®. Then, extract the object for your scenario from the
Scenario
property of the authoring API object
rrApi
.
Use the validate
function to validate the scenario.
Validate Invalid Scenario
When you modify a scenario, you can introduce critical errors that can cause it to
fail validation, such as leaving an empty ReferenceActor
property
for a phase that compares two actors during simulation.
From the scenario scnro
, extract the objects for the scenario
phase logic, from the PhaseLogic
property, and the actor named
"Yellow"
, stored as the first element of the
Actor
property. rrLogic
represents the
RoadRunner scenario logic, and yellowCar
represents the actor
named "Yellow"
.
Use the initialPhaseForActor
function to extract the object for the initial
phase of the actor yellowCar
. Add a new actor action phase,
srPhase
, after the initial phase initPhase
and
assign it to the actor yellowCar
. Then, use addAction
to
specify the action of srPhase
as
"ChangeSpeedAction"
. Set the SpeedReference
property of the change speed action chSpd
to
"actor"
.
Validate the modified scenario. Because you have not specified a reference actor
for chSpd
, its ReferenceActor
property is empty
and the validation fails.