Main Content

Publish Actor Behavior as Proto File, Package or Action Asset

This topic explains how to publish your Simulink® or MATLAB® System object™ actor behaviors as proto files, packages or action asset files using the publishActorBehavior, publishActor or publishCustomAction functions.

Proto files are specific to RoadRunner and have a .slprotodata extension. This data interface allows you to combine your behavior model and its parameters and share them with RoadRunner. You can then tune these parameters in the RoadRunner environment.

Generate Behavior Proto File for Simulink or MATLAB System Object Behavior

Use the publishActorBehavior function to generate a behavior proto file from your Simulink behavior.

  1. For demonstration purposes, suppose you create the Simulink model, foo01.slx. This code below initiates the model and then assigns a new workspace variable gain with value 2.0.

    % ---------------------- Setup a SL Model -----------------------
    model = 'foo01';
    modelWorkspace = get_param(model,'ModelWorkspace');
    var_name = 'gain01';
    var_value = 2.0;
    % Assign to model workspace
    % Set model argument
    params = Simulink.internal.getModelParameterInfo(model);
  2. To create a proto file for foo01.slx, use this command.


    This command creates the foo01.slprotodata file in your current directory.

  3. You can now drag foo01.slprotodata into any folder under MyProject/Assets. For this example, the file is placed in the Vehicles folder.

    The proto file appears as a behavior under the Vehicles folder

  4. Double-click the foo01 behavior and observe that the gain parameter and its value appears. You can now tune this parameter for simulation purposes.

    The gain parameter is displayed in the Attributes pane. The parameter value is 2.

  5. Attach the proto file to your vehicle in your scenario.

    The proto file is attached to a vehicle

You can also use this workflow to generate a behavior proto file from a MATLAB System object behavior.

For example, suppose that you create the behavior MySystemObjectBehavior.m. To publish your behavior as a proto file, use this command.


Generate Package from Simulink Model or MATLAB System Object

You can also publish your behavior as a package in a .zip file. Publishing in a .zip file allows you to create a package that includes the supporting files for your model, for example, a .mat file. To publish your Simulink model, Simulink project, or MATLAB System object behavior as a package, use the publishActor function.

For example, to publish your MySystemObjectBehavior.m behavior as a package, use this command.


The package includes:

  • Metadata folder — Stores the actor files. packageInfo.json contains the package type, MATLAB version, and publish date to identify the package.

  • Model files — An .slx or .m file.

  • Data files — Dependent data files for use in setup and cleanup scripts, such as model callbacks, .mat files, and .sldd files.

Generation Action Asset File from Simulink Model

You can publish your Simulink actor behavior model containing a user-defined action as an action asset file in the .seaction format. To publish the user-defined action as an action asset file, use the publishCustomAction function.

To use this function successfully:

  • The Simulink model must read the user-defined action from a Simulink bus object, saved as a MAT-file.

  • The Simulink model must contain a RoadRunner Scenario block that links the MAT-file to the name of an action in RoadRunner Scenario.

You can use the published .seaction file in the action phases of a scenario simulation.

See Also

| |

Related Topics