Convert Scenes Between Formats Using MATLAB Functions
This example shows how to import RoadRunner scenes from one file format and export those scenes to a different format. In this example, you import ASAM OpenDRIVE® files into scenes, save them to a project, and export the scenes to export them to Filmbox® FBX® files using MATLAB® functions.
To run this example, you must:
Have an Automated Driving Toolbox® license.
Have a RoadRunner® license and the product is installed.
Have created a RoadRunner project folder.
Start RoadRunner Programmatically
To use MATLAB functions to control RoadRunner programmatically, use the
roadrunner object. By default,
roadrunner opens RoadRunner from the default installation folder for the platform you are using (either Windows® or Linux®). These are the default installation locations by platform:
Windows – C:\Program Files\RoadRunner R20NNx\bin\win64
Linux, Ubuntu® – /usr/local/RoadRunner_R20NNx/bin/glnxa64
R20NNx is the MATLAB release you are using.
If your RoadRunner installation is at a different location than the default location, use MATLAB
settings API to customize the default value of the RoadRunner installation folder.
Import and Export of Multiple Scenes
Import multiple scenes from the ASAM OpenDRIVE format and export them to the FBX format.
Open a project in RoadRunner using the
roadrunner function by specifying the location in which to create a 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 on
C:\RR\MyProject. The function returns a
rrApp, that provides functions for performing basic workflow tasks such as opening, closing, and saving scenes and projects.
demoProj = fullfile('C:','DemoProject'); rrApp = roadrunner(demoProj,InstallationFolder="C:\Program Files\RoadRunner R2022b\bin\win64 ");
Specify the paths to the ASAM OpenDRIVE files you want to import and to the folder into which you want to export the Filmbox files.
odrFolder = fullfile('C:','OpenDRIVE'); odrFiles = dir(fullfile(odrFolder,'*.xodr')); exportFolder = fullfile('C:','Filmbox');
Import the ASAM OpenDRIVE files and export them to the FBX format. Import each ASAM OpenDRIVE file into a new scene by using the
newScene function to create a new scene in your project, then specifying the file path for each scene to import to the
importScene function. Then, export the imported scene to a file by using the
for fndx = 1:length(odrFiles) newScene(rrApp); importFilePath = fullfile(odrFolder,odrFiles(fndx).name); importScene(rrApp,importFilePath,"OpenDRIVE"); [~,fileName] = fileparts(odrFiles(fndx).name); exportFilePath = [fullfile(exportFolder,fileName) '.fbx']; exportScene(rrApp,exportFilePath,"Filmbox"); end
Once all the scenes have been exported, close the RoadRunner application by using the
Extend RoadRunner Export Options
To customize the script further, you can specify non-default import and export settings or specify other file formats. For more details on supported formats, see the
exportScene functions. For additional flexibility in exporting scenes, consider exporting the scene using custom export options. For more details, see the