write
Syntax
Description
Examples
Generate OSI Trace File Using Multiple Sensors
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
osiData
— Open simulation interface object
openSimulationInterface
object
Open simulation interface object to write in binary format, specified as an openSimulationInterface
object.
filename
— OSI trace filename
character vector | string scalar
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
See Also
Objects
Functions
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)