Main Content

Simulink.ActorSimulation.createMATLABStruct

Create MATLAB structure for bus object for RoadRunner

Since R2024a

    Description

    example

    struct = Simulink.ActorSimulation.createMATLABStruct(BusName) creates a MATLAB® structure that has the same hierarchy and attributes as the specified bus. The resulting structure uses the ground values of the bus. When you have Simulink® string data type, the function converts them to the char data type with a maximum character length of 256, to support code generation.

    Examples

    collapse all

    Based on the configuration of the RoadRunner Scenario Reader block in a Simulink model, the block outputs various types of bus. To see the data type of the output bus in your model, on the Debug tab, select Information Overlays, enable Bus Data Type, and update your model. This code assumes that the RoadRunner Scenario Reader block outputs the BusActorRuntime bus and uses it to create the structure in a MATLAB System object™.

    function out = stepImpl(obj, u)
     
            % Construct default output struct
            out = Simulink.ActorSimulation.createMATLABStruct('BusActorRuntime');
    
            % Get ActorID
            actorSim = Simulink.ScenarioSimulation.find( ...
                 'ActorSimulation','SystemObject',obj);
            actorID = getAttribute(actorSim,"ID");
    
            if ~isempty(u)
                pose = u(end).Pose;
                velocity = u(end).Velocity;
                displacement = velocity*obj.stepSize*obj.SpeedFactor;
        
                % Update pose
                pose(1,4) = pose(1,4)+displacement(1); % x
        
                % Update output
                out.Pose = pose;
                out.Velocity = velocity;
                out.ActorID = castIntToFi(actorID);
            end
    
        end
    

    Input Arguments

    collapse all

    name of the Simulink.Bus object output by the RoadRunner Scenario Reader block in a model, specified as a character vector or string scalar.

    This is the list of supported buses:

    • BusActionComplete

    • BusActorActions

    • BusActorEvents

    • BusActorPose

    • BusActorRuntime

    • BusActorSpec

    • BusBoundingBox

    • BusChangeParameterAction

    • BusDistanceTarget

    • BusDynamicConstraints

    • BusLaneChangeAction

    • BusLaneChangeTarget

    • BusLateralOffsetAction

    • BusLateralOffsetTarget

    • BusLongitudinalDistanceAction

    • BusPaintColor

    • BusParameterAction

    • BusPathAction

    • BusPathPointTiming

    • BusPathTarget

    • BusSpeedAction

    • BusSpeedTarget

    • BusTransitionDynamics

    • BusVehicleLocationOnLane

    • BusVehicleMapLocation

    • BusVehicleRuntime

    • BusVehicleSpec

    • BusWheelSpec

    Output Arguments

    collapse all

    MATLAB structure with the same hierarchy and attributes as the specified bus, returned as a structure.

    Version History

    Introduced in R2024a