Main Content

BehaviorAsset

Behavior asset type

Since R2025a

    Description

    The BehaviorAsset object represents an asset with the Behavior asset type in the RoadRunner project. Behavior assets store user-defined parameters as .rrbehavior files that enable you to create custom simulation behaviors for actors. You can use a BehaviorAsset object to assign an .rrbehavior asset to an actor in your scenario. For more information on user-defined parameters in RoadRunner Scenario, see Scenario Parameters (RoadRunner Scenario).

    Creation

    You can create a BehaviorAsset object in these ways:

    • The getAsset function extracts an object for the asset of the specified asset type at the specified path relative to the Asset folder of the specified project. Specify the assetType argument as "BehaviorAsset" to extract a BehaviorAsset object.

    • The createAsset function creates an asset of the specified asset type at the specified path relative to the Asset folder of the specified project. Specify the assetType argument as "BehaviorAsset" to create a BehaviorAsset object. The extension you specify for the new asset must match the type specified for the assetType argument.

    Properties

    expand all

    This property is read-only.

    Relative path to the asset in the RoadRunner project, represented as a string scalar.

    Examples

    collapse all

    By default, RoadRunner Scenario includes the behavior asset BuiltInBehaviorParameters.rrbehavior in the Behaviors folder of your RoadRunner project. This behavior asset file contains two parameters, FollowGround and RotateWheels. FollowGround instructs the associated actor to remain oriented to the road surface, and, if the actor is a vehicle, RotateWheels instructs the wheels of the actor to rotate during simulation. RoadRunner Scenario enables both of these parameters by default for all actors. However, you can modify the parameters of the BuiltInBehaviorParameters.rrbehavior file to turn these settings off for specific actors.

    Use the getAsset function to extract a BehaviorAsset object for the BuiltInBehaviorParameters.rrbehavior asset in your RoadRunner project. Then, assign the behavior to the BehaviorAsset property of the actor car.

    Note

    To modify individual parameters within an .rrbehavior asset, you must edit the asset file directly in a text editor. Alternatively, you can interactively change the parameter settings in RoadRunner Scenario by selecting the asset file in the Library Browser tab and changing the parameter values in the Attributes pane.

    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 the getAsset function to extract the BehaviorAsset object builtInBehavior to represent the BuiltInBehaviorParameters.rrbehavior asset in the project prj.

    builtInBehavior = getAsset(prj,"Behaviors/BuiltInBehaviorParameters.rrbehavior","BehaviorAsset");

    Assign the BuiltInBehaviorParameters.rrbehavior asset to the actor by setting the BehaviorAsset property of the actor car to the BehaviorAsset object builtInBehavior.

    car.BehaviorAsset = builtInBehavior;

    Run the simulation by using the simulateScenario function. The actor car follows the behavior parameters specified by the .rrbehavior asset during simulation.

    simulateScenario(rrApp)

    Version History

    Introduced in R2025a