Main Content

write

Write OSI data to binary file

Since R2024b

    Description

    write(osiData,filename) writes the OSI data of each sensor to a distinct binary file with a .txt extension. The filenames for the output binary files follow this format: <timestamp>_<type>_<osi-version>_<protobuf-version>_<number-of-frames>_<filename>_<sensor-name>.txt.

    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 sensor models for a radar and a vision sensor, to add to the ego vehicle, using drivingRadarDataGenerator and visionDetectionGenerator objects. Specify a unique ID for each sensor.

    radar = drivingRadarDataGenerator(SensorIndex=1, ...
          MountingLocation=[2.4 0 0.2], ...
          RangeLimits=[0 100], ...
          TargetReportFormat="Detections");
    
    camera = visionDetectionGenerator(SensorIndex=2, ...
              SensorLocation=[2.4 0], ...
              MaxRange=50, ...
              DetectorOutput="Objects only", ...
              UpdateInterval=0.1);
    sensors = {radar camera};

    Add the sensors 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);

    Start the RoadRunner simulation, storing the scenario simulation data in OSI format in the osiData object.

    startRoadRunnerSimulation(osiData);

    Specify a custom filename for the output binary files with a .txt extension, and write the OSI data from each sensor to a distinct OSI trace file.

    write(osiData,"testEgoFollowSpeed.txt");

    Input Arguments

    collapse all

    Open simulation interface object to write in binary format, specified as an openSimulationInterface object.

    OSI trace filename, specified as a character vector or string scalar. You must specify a filename that ends with a .txt extension. If you do not specify filename, then RoadRunner returns an error.

    Example: write(osiData,"testEgoFollowSpeed.txt") saves the OSI trace file for a scenario with a radar sensor as 20240624160337_sv_350_300_501_testEgoFollowSpeed_Radar1.txt. Note that the specific timestamp, type, version numbers, number of frames, and sensor name might differ depending on your specified openSimulationInterface object.

    Data Types: char | string

    Version History

    Introduced in R2024b