Main Content

getProtoMessage

Get OSI protocol buffer (protobuf) message at each simulation step

Since R2024b

    Description

    sView = getProtoMessage(osiData) gets the SensorView property of the specified openSimulationInterface object osiData at each simulation step.

    example

    Examples

    collapse all

    Create a roadrunner object to launch the RoadRunner application, which then connects to the project folder at the specified path.

    rrApp = roadrunner(ProjectFolder="C:\OsiRoadRunnerProject\");

    Open the scenario file TrajectoryCutIn.rrscenario. This scenario is included with the RoadRunner Scenario application.

    openScenario(rrApp,"TrajectoryCutIn");

    Create scenarioSim, a ScenarioSimulation object, to connect MATLAB® to the RoadRunner Scenario simulation.

    scenarioSim = createSimulation(rrApp);

    Create sensorSim, a RoadRunner SensorSimulation object, to control the sensor configuration for the RoadRunner Scenario simulation.

    sensorSim = get(scenarioSim,"SensorSimulation");

    Configure the sensor model for a radar sensor, to add to the ego vehicle, using a drivingRadarDataGenerator object.

    radar = drivingRadarDataGenerator(SensorIndex=1, ...
          MountingLocation=[2.4 0 0.2], ...
          RangeLimits=[0 100], ...
          FieldOfView =[40 5], ...
          TargetReportFormat="Detections");
    
    sensors = {radar};

    Add the sensor to the ego vehicle actor in the RoadRunner scenario. Specify the Actor ID property of the vehicle.

    egoVehicleID = 1;
    addSensors(sensorSim,sensors,egoVehicleID);

    Create osiData, a RoadRunner openSimulationInterface object to store RoadRunner Scenario simulation data in OSI format.

    osiData = openSimulationInterface(scenarioSim,sensors);

    Use the ScenarioSimulation object, to step through the RoadRunner scenario, and get the OSI protocol buffer message from the openSimulationInterface object at each simulation step.

    set(scenarioSim,SimulationCommand="Start");
    set(scenarioSim,SimulationCommand="Pause");
    pause(0.5);
    
    while ~isequal(get(scenarioSim,"SimulationStatus"),"Stopped")
    osiProtoMessage = getProtoMessage(osiData);
    set(scenarioSim,SimulationCommand="Step");
    end

    Input Arguments

    collapse all

    Open simulation interface object, specified as an openSimulationInterface object. This function returns the SensorView property of the specified openSimulationInterface object at each simulation step.

    Version History

    Introduced in R2024b