Main Content

exportActorTrajectoryToCSV

Export trajectories of actors in RoadRunner scenario to comma-separated values (CSV) files using MATLAB

Since R2025a

    Description

    exportActorTrajectoryToCSV(rrApp,folderpath,foldername) exports the trajectories of the actors in the current scenario of the specified RoadRunner Scenario application rrApp to CSV files. The function exports a separate CSV file for each actor to the specified folder foldername in the specified location folderpath. Each exported CSV file contains the time, position, and, orientation values of the waypoints on the trajectories of the corresponding actor.

    example

    exportActorTrajectoryToCSV(rrApp,folderpath,foldername,Name=Value) sets options using one or more name-value arguments. For example, ExcludeTiming=true excludes the timing values of waypoints on the actor trajectories from the exported CSV files.

    Examples

    collapse all

    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);

    Specify the folder path and the folder name to which you want to export the CSV files.

    folderpath = "C:\RR\MyProject\Exports";
    foldername = "TrajectoryCutIn";

    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. 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.

    exportActorTrajectoryToCSV(rrApp,folderpath,foldername);

    Input Arguments

    collapse all

    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.

    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.

    Example: exportActorTrajectoryToCSV(rrApp,"C:\RR\MyProject\Exports","TrajectoryCutIn") specifies to create a folder to contain the exported CSV files in the "C:\RR\MyProject\Exports" 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. For each actor in the scenario, the folder contains an individual CSV file with the name ActorName_ActorID.csv, where ActorName 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 ComponentUnit
    timeTimeseconds
    xx-positionmeters
    yy-positionmeters
    zz-positionmeters
    yawYaw radians
    pitchPitch radians
    rollRoll 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

    Name-Value Arguments

    collapse all

    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,"C:\RR\MyProject\Exports","TrajectoryCutIn",ExcludeTiming=true) excludes the time values of waypoints from the actor trajectories in the exported CSV files.

    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.

    Version History

    Introduced in R2025a