Exporting to CARLA

CARLA Export Overview

RoadRunner can export scenes to the CARLA simulator. The CARLA export option exports a Filmbox (.fbx) file, an XML for some metadata, and an OpenDRIVE® (.xodr) file. The XML file holds data for materials in the scene.

On the CARLA or Unreal® side, a plugin is provided to help import the FBX® file by using the information stored in the XML file. The plugin handles the following:

  • Setting up materials
    • Material data is read in from the XML file and maps the data into a new instance of one of the base materials included with the plugin.
    • Certain materials will instantiate from one of the CARLA materials.
    • Transparent materials will choose between the translucent and masked blend modes based on the transparency of the diffuse color.
  • Adjusting the colliders in the imported static meshes
    • During import, newly created static mesh assets have their "Collision Complexity" option set to "Use Complex Collision As Simple".
  • Setting up the traffic signal visuals
    • Traffic signal logic is not hooked up to the simulator.
  • Software requirements
    • Unreal Version 4.21+
    • CARLA 0.9.5 built from source

Installing the Plugins

Follow the instructions in this section to install the Unreal plugin:

  1. See Downloading Plugins for instructions for downloading the latest version of the plugin.
  2. Extract the RoadRunner Plugins zip file and locate the "RoadRunnerImporter" and "RoadRunnerCarlaIntegration" folders under "Unreal/Plugins".

  3. Copy the "RoadRunnerImporter" and "RoadRunnerCarlaIntegration" folders into the "Plugins" folder under the CarlaUE4 project directory, located at <carla>/Unreal/CarlaUE4/Plugins (next to the "Carla" folder).

  4. Rebuild the plugin.
    1. Generate the project files.

      • Windows® - Right-click the .uproject file and select "Generate Visual Studio project files."

      • Linux® - Run this code at the command line:

        $UE4_ROOT/GenerateProjectFiles.sh -project="<Path to Carla folder>/Unreal/CarlaUE4/CarlaUE4.uproject" -game -engine

        Set UE4_ROOT to your Unreal Engine install directory.

    2. Open the project and build the plugins by clicking Yes.

  5. The plugin shows up under Edit > Plugins. If it does not appear in that menu, check that the Enabled check box is on.

    import_plugin_carla.png

Plugin Contents

  • RoadRunnerImporter module
    • Overrides the default FBX importer when the metadata file is present
    • Option to overwrite default materials with new materials using the metadata file
    • Import signal data and timing
  • RoadRunnerRuntime module
    • Contains component to control traffic signal visuals
  • RoadRunnerCarlaIntegration module
    • Creates a new map and imports the FBX into the level
    • Moves static mesh assets based on segmentation type
    • Creates materials instantiated from CARLA materials for weather effects
    • Generates the routes from the OpenDRIVE® file
  • Plugin assets:
    • Materials based off RoadRunner materials

Exporting from RoadRunner to CARLA

Follow the steps below to export a scene from RoadRunner to Unreal:

  1. Open your scene in RoadRunner.
  2. Export the scene using the CARLA option. Select File > Export > CARLA (.fbx + .xml + .xodr) from the Main Menu.

    export_to_carla_menu.png
  3. In the Export CARLA dialog box, set the mesh tiling on the FBX tab and the OpenDRIVE options on the OpenDRIVE tab as needed. Then, click Export. 

    export_to_carla_window_fbx.png

    export_to_carla_window_opendrive.png
  4. Browse to open the file dialog box to set the exported file's name and path. The FBX, textures, XML, and OpenDRIVE files are exported to the same folder.

    • The mesh can be split by segmentation type. Meshes have "<segmentation type>Node" appended to their names.
    • If the Export To Tiles option is selected, meshes are split per tile and props are grouped by the tile they are in.
      • By default, only one file is exported. Tiles are stored in separate nodes.
      • If Export Individual Tiles is enabled, each tile is stored in its own FBX file.

Note: The plugin does not fully support the Export Individual Tiles option.

Importing into CARLA/Unreal

There are multiple ways to import the scene into Unreal for use with CARLA.

  • Drag the file into the Content Browser.
  • Use the "Import" button and select the FBX file.

The plugin checks if there is a RoadRunner XML file associated with the imported file, and imports as normal if a corresponding XML file is not found.

Selecting File > Import Into Level does not use the exported RoadRunner XML and uses the Unreal importer instead.

When the RoadRunner Import Options Dialog Box Opens

import_to_unreal_pop_up.png

  • Overwrite Materials
    • Overrides the default material importing. Instances from CARLA materials for roads and foliage.
    • Needs to be unchecked if you want to set the materials to "Use Existing" in the next dialog box.
  • Import Signal Visuals
    • Only functional when the "Create one Blueprint asset" option is selected in the next dialog box.

Note: The Importing Signal Visuals option does not have any effect on the traffic simulation.

When the FBX Scene Import Options Dialog Box Opens

  1. Set Scene > Hierarchy Type to "Create One Blueprint Asset" (selected by default).

    Note: Only the "Create one Blueprint asset" import option works with materials, signals, and transparency sorting. The "Create one Actor with Components" and "Create Level Actors" options import only materials.

  2. Select Invert Normal Maps, if needed.

  3. Set Static Meshes > Normal Import Method to "Import Normals".

  4. (Optional) Uncheck Remove Degenerates, which can help for some props created in a larger scale.
  5. Click Import.

About Importing Traffic Signals into Unreal

If traffic signals were set up in RoadRunner, they are imported into Unreal as RoadRunnerTrafficJunction components. These controllers are automatically created during import and included in the created blueprint.

The RoadRunnerTrafficJunction component handles the logic for switching between signal states. UUIDs are used to match to specific game objects in the scene.

FBX Details

The FBX file will automatically split the mesh by segmentation and transparency sorting layer due to the following:

  • Segmentation: CARLA determines segmentation by static mesh assets.
  • Transparency sorting: Unreal stores the "Translucency Sort Priority" value on the static mesh component.

Testing the map

  1. Click Play in the editor (the first time you click Play takes extra time to build the map).

  2. Run the example Python scripts.

Creating Map Packages for Distribution (CARLA 0.9.5)

Note: Some steps in CARLA have changed since the 0.9.5 release of CARLA, but the same concepts should apply if there are issues.

Exporting the Map

  1. Import the FBX into UE4 by using the plugin.
  2. Run this command: make export-maps ARGS="--file=<map name>"

  3. If the map uses RoadRunner materials, you will likely get a missing material error when trying to run the executable. Follow the steps in the next section if this issue occurs.

RoadRunner Material Workaround

Since CARLA scripts do not copy the RoadRunner plugin "Content" folder, they need to be generated and copied manually to the distribution build.

  1. In UE4, open the packaging settings under File > Package Project > Packaging Settings.
    1. Uncheck "Use Pak File".

    2. Add the map you want to package to the "List of maps to include in a packaged build."
  2. Run this command: make package
  3. Copy the cooked plugin content (located at <carla>/Dist/0.9.5-dirty/LinuxNoEditor/CarlaUE4/Plugins/RoadRunnerImporter) to the desired location.

Note: This procedure generates only the materials used in the included maps.