exportActorTrajectoryToCSV
Export trajectories of actors in RoadRunner scenario to comma-separated values (CSV) files using MATLAB
Since R2025a
Description
exportActorTrajectoryToCSV( exports the
trajectories of the actors in the current scenario of the specified RoadRunner Scenario
application rrApp)rrApp to CSV files. Each exported CSV file contains the time,
position, and, orientation values of the waypoints on the trajectories of the corresponding
actor.
exportActorTrajectoryToCSV(
sets options using one or more name-value arguments. For example,
rrApp,Name=Value)ExcludeTiming=true excludes the timing values of waypoints on the actor
trajectories from the exported CSV files.
Examples
Export the trajectories of the actors in a scenario to CSV files using MATLAB®.
Specify the path to an existing project. For example, this code shows the path to a project located at "C:\RR\MyProject".
projectFolder = "C:\RR\MyProject";Create a roadrunner object and launch RoadRunner by specifying your project path. This example assumes that RoadRunner is installed in its default location.
rrApp = roadrunner(projectFolder);
Open the TrajectoryCutIn.rrscenario scenario in RoadRunner Scenario by using the openScenario function. This scenario is included by default in RoadRunner projects, and is located in the Scenarios folder of the project.
filename = "TrajectoryCutIn.rrscenario";
openScenario(rrApp,filename);Run the simulation by using the simulateScenario function, and set EnableLogging to true to enable RoadRunner Scenario to log the simulation data.
simulateScenario(rrApp,EnableLogging=true);
Export the trajectories of the actors in the scenario by using the exportActorTrajectoryToCSV function, specifying the rrApp object. Specify the folder path and the folder name to which you want to export the CSV files using the FolderPath and FolderName name-value arguments.
exportActorTrajectoryToCSV(rrApp,FolderPath="C:\RR\MyProject\Exports",FolderName="TrajectoryCutIn");
Once the simulation is complete, RoadRunner exports the CVS files to the specified export folder. You can now navigate to the export folder and locate the CSV files. The export folder contains an individual CSV file for each actor in the scenario. For this example, the export folder has the Lead_1.csv and Ego_2.csv files that contain the actor trajectory data of the lead and ego vehicle actors, respectively.
Input Arguments
RoadRunner application associated with a project, specified as a
roadrunner object. This object provides functions
for performing common workflow tasks such as opening, closing, and saving scenes and
projects. rrApp provides functions that support importing data from
files and exporting scenes to other formats from RoadRunner.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: exportActorTrajectoryToCSV(rrApp,ExcludeTiming=true) excludes
the time values of waypoints from the actor trajectories in the exported CSV
files.
Export folder path, specified as a character vector or string scalar. Use this
argument to specify an absolute path to the folder in which to create the folder that
contains the exported CSV files. If the specified folder path does not exist then
RoadRunner returns an error. If you do not specify a value for the
FolderPath argument, then RoadRunner creates the folder in the Exports folder of the
current project folder.
Data Types: char | string
Export folder name, specified as a character vector or string scalar. Use this
argument to specify the name of the folder to which to export the CSV files.
RoadRunner names the folder by appending the date and timestamp to the end of
FolderName. If you do not specify a value for the
FolderName argument, the default behavior of RoadRunner depends on whether you have saved the current scenario.
If you have saved the current scenario, RoadRunner creates a folder with the same name as the saved scenario, and appends the date and timestamp. For example,
TrajectoryCutIn_2024-09-06_18-39-39.If you have not saved the current scenario, RoadRunner creates a folder with the name
New Scenarioand appends the date and timestamp. For example,New Scenario_2024-09-06_18-39-39.
For each actor in the scenario, the folder contains an individual CSV file with
the name
,
where ActorName_ActorID.csvActorName and ActorID
correspond to the values of the Name and Actor Id attributes, respectively, of the corresponding
actor.
When you export actor trajectories to CSV files, the files organize the data in columns. Each column header specifies the type of data contained within that column. This table lists the header for each component in the exported CSV files, along with the corresponding unit of measurement for each component.
Header Names, Components, and Units
| Header | Component | Unit |
|---|---|---|
time | Time | seconds |
x | x-position | meters |
y | y-position | meters |
z | z-position | meters |
yaw | Yaw | radians |
pitch | Pitch | radians |
roll | Roll | radians |
Example:
exportActorTrajectoryToCSV(rrApp,"C:\RR\MyProject\Exports","TrajectoryCutIn"),
exports the CSV files to the TrajectoryCutIn_YYYY-MM-DD_HH-MM-SS
folder located in the "C:\RR\MyProject\Exports" folder.
YYYY is the year, MM the month,
DD the day, HH the hour, MM
the minute, and SS the second at which you export the actor
trajectories.
Data Types: char | string
Exclude the timing data, specified as a logical 1
(true) or 0 (false). If
true, RoadRunner excludes the timing values of waypoints from the actor trajectories in
the exported CSV files.
Exclude orientation data, specified as a logical 1
(true) or 0 (false). If
true, RoadRunner excludes the yaw, pitch, and roll values of waypoints from the actor
trajectories in the exported CSV files.
Exclude the trajectories of the child actors from the exported CSV files,
specified as a logical 1 (true) or
0 (false). If true,
RoadRunner does not export the trajectories of the child actors attached to parent
vehicles to CSV files.
If a scenario includes a child actor attached to a parent vehicle, such as a
trailer, and you set this field to false, the default behavior of
RoadRunner Scenario depends on the value of the Type attribute of the
Connection Attributes for the child actor.
If you set the Type attribute to
trailer, RoadRunner Scenario allows the child actor to move and use independent dynamics relative to the parent vehicle. In this case, the orientation values for the child and parent vehicles differ in the exported CSV files.If you set the Type attribute to
fixed, RoadRunner Scenario locks the child actor rotation to the dynamics of the parent vehicle, and the orientation values for both the child and parent vehicles are the same in the exported CSV files.
For more information on connection attributes, see Vehicle Assets (RoadRunner Scenario).
Version History
Introduced in R2025aYou can now exclude the trajectories of child actors attached to parent vehicles from
the exported CSV files, using the new ExcludeChildActors name-value
argument.
See Also
roadrunner | openScenario | simulateScenario
Topics
- RoadRunner Scenario Fundamentals (RoadRunner Scenario)
- Simulate a RoadRunner Scenario Using MATLAB Functions
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)