Main Content

exportScenario

Export scenario from RoadRunner Scenario using MATLAB

Since R2022a

    Description

    exportScenario(rrApp,filename,formatname) exports a scenario file to one of the file formats that RoadRunner supports.

    exportScenario(rrApp,filename,formatname,exportoptions) sets options for export using exportoptions. The export options configuration is specified as one of the export options objects compatible with the format name specified in the formatname argument. You can export only ASAM OpenSCENARIO® files.

    example

    Examples

    collapse all

    Export a scenario from RoadRunner Scenario using MATLAB.

    Call the roadrunner function and pass in the location where you want to create the project. This example assumes that RoadRunner is installed in its default location in Windows.

    Specify the path to an existing project. For example, this code shows the path to a project located at "C:\RR\MyProject". This call returns an object rrApp that provides functions for performing basic workflow tasks such as opening, closing, and saving scenes and projects.

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

    Open a scenario in the project by calling the openScenario function. You must pass the rrApp object and the RoadRunner scenario you wish to open as input arguments while calling the openScenario function. This example uses the 'FourWaySignal.rrscenario' scenario, which is one of the scenario included by default in RoadRunner projects and is located in the Scenarios folder of the project.

    scenarioname = "MyScenario.rrscenario";
    openScenario(rrApp,scenarioname);

    Before exporting the file, set export options by creating an openScenarioExportOptions object to enable export of signals and objects from the file.

    options = openScenarioExportOptions(OpenDriveOptions=openDriveExportOptions(OpenDriveVersion = 1.5,ExportSignals = true,ExportObjects = true));

    Once the scenario opens successfully, call the exportScenario function to export the scenario to ASAM OpenSCENARIO®. Pass rrApp, the scenario filename of the scenario, the export format, and the export options as input arguments to the function.

    filename = "FourWaySignal.xosc";
    formatname = "OpenSCENARIO";
    exportScenario(rrApp,filename,formatname,options);

    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.

    File path to the exported file, specified as a character vector or string scalar. filename is absolute or relative to the exported file. If you specify a relative path, then the exported file is saved relative to the Exports folder of the current project. If any folders in the path are missing, RoadRunner tries to create them. filename can include the extension for the exported file or have no extension. If it has no extension, then RoadRunner appends the extension of the format specified by the formatname to the file name before exporting the scenario.

    Example: While calling exportScenario(rrApp,"FourWaySignal.xosc","OpenSCENARIO",options), "FourWaySignal.xosc" represents the file name of the exported file, which is relative to the Exports folder of the current project.

    Data Types: char | string

    Export format name, specified as a character vector or string scalar. This argument specifies the export format name corresponding to a valid RoadRunner export format. Format name options are case-insensitive. RoadRunner only supports ASAM OpenSCENARIO format.

    Example: While calling exportScenario(rrApp,"FourWaySignal.xosc","OpenSCENARIO",options), OpenSCENARIO specifies that the file will be exported to ASAM OpenSCENARIO format.

    Data Types: char | string

    Export options configuration, specified as one of the export options objects compatible with the format name specified in the formatname argument. This argument specifies the options to use during export. The export options configuration property supports these objects:

    As of R2024a, if you specify exportoptions as an openScenarioExportOptions object, the SceneGraphOptions property must be a sceneGraphExportOptions object.

    Version History

    Introduced in R2022a