Main Content


Specify options for customizing imported CSV files

Since R2022b


    The csvTrajectoryImportOptions object enables you to specify options when importing CSV files into a RoadRunner scenario.



    options = csvTrajectoryImportOptions creates a default configuration object for importing CSV trajectories into RoadRunner scenarios.

    options = csvTrajectoryImportOptions(Name=Value) specifies properties using one or more name-value arguments. For example, csvTrajectoryImportOptions(SpawnTime=3) specifies to add the imported actor to the scenario 3 seconds after the simulation starts.


    expand all

    Optional actor attributes, specified as an actorImportOptions (RoadRunner Scenario) object.

    Time to wait before adding the actor to the scenario, specified as a positive scalar in seconds.

    Example: options = csvTrajectoryImportOptions(SpawnTime=1); specifies to add the actor to the scenario 1 second after the simulation starts.

    Time to wait before removing the actor from the scenario, specified as a positive scalar in seconds.


    collapse all

    When you import CSV trajectory files into RoadRunner you can simultaneously specify options for customizing the accompanying actor using the csvTrajectoryImportOptions object and the actorImportOptions object.

    Create a roadrunner object, specifying the path to an existing project. For example, this code shows the path to a project, on a Windows® machine, located at "C:\RR\MyProject". This code assumes that RoadRunner is installed in the default location, and returns an object, rrApp, that provides functions for performing basic tasks such as opening, closing, and saving scenes and projects.

    rrApp = roadrunner(ProjectFolder="C:\RR\MyProject");

    Open a scenario in which to import your CSV trajectory. Alternatively, if you do not have an existing scenario file, switch to scenario editing mode by selecting Scenario Editing from the top-right corner of the RoadRunner application.

    Create an actorImportOptions (RoadRunner Scenario) object to set attributes for the actor to be imported with the CSV trajectory. Specify your actor import options object to the ActorImportOptions property of the csvTrajectoryImportOptions object, then use the SpawnTime property to add the actor to the scenario 1 second after the simulation starts.

    myActor = actorImportOptions(Color="red");
    options = csvTrajectoryImportOptions(ActorImportOptions=myActor,SpawnTime=1);

    Import your CSV trajectory using the importScenario (RoadRunner Scenario) function, specifying your csvTrajectoryImportOptions object as input.

    importScenario(rrApp,"C:\RR\MyProject\MyCSVs.csv","CSV Trajectory",options)

    Version History

    Introduced in R2022b