Contenido principal

Create and Use an Oval Track

R2026b

You can create a RoadRunner scenario with realistic road geometry and use it in a Vehicle Dynamics Blockset™ co-simulation with 3D visualization. To create the oval track used in the Follow Waypoints Around Oval Track example, use either of these workflows.

WorkflowGoalDescriptionGet Started

Simplified (recommended)

You want default 3D visualization without custom scene assets

In R2026b: Create track in RoadRunner and import directly into the Reference Path Generator block without exporting to Unreal Engine®

See Use RoadRunner Scenario Object as Reference Oval Path

Custom

You need hand-crafted 3D scene assets in Unreal Engine

Create track in RoadRunner, export to Unreal Engine, and co-simulate with Vehicle Dynamics Blockset

Follow Steps 1–4 on this page

Before you start the custom workflow, make sure that you have the required products installed.

StepRequired Products

1

Step 1: Create Track in RoadRunner

RoadRunner

2

Step 2: Export Track from RoadRunner

RoadRunner

Unreal Engine 5.4

RoadRunner plugin

Visual Studio® 2022

3

Step 3: Import Track to Unreal Engine

4

Step 4: Co-Simulate in Vehicle Dynamics Blockset

Unreal Engine 5.4

Vehicle Dynamics Blockset

Vehicle Dynamics Blockset Interface for Unreal Engine Projects

Step 1: Create Track in RoadRunner

In this example, you create the oval track specified in the following figure. The locations and reference poses are in the RoadRunner coordinate system, (X, Y, θ). The locations, X and Y, are in m. The reference poses, θ, are in deg.

Legend

Green

Locations of patch boundaries, X, Y

Red

Intersection points of straight-line segments, X, Y

Black

Track locations and reference poses, X, Y, θ

Use RoadRunner to create the oval track. For more information about creating tracks, see Road Plan Tool (RoadRunner).

Create Straight Line Segments

  1. Open the Road Plan Tool.

  2. Navigate to Library Browser > RoadStyles. Select Residential.

  3. Right-click to place the start and endpoints of a straight-line road.

  4. After each straight segment, left-click and repeat the preceding step.

  5. Select the road control points. Use the oval track figure at the beginning of Step 1 to enter the coordinate information.

Create Circular Arc

  1. Open the Road Plan Tool. If you are continuing from creating the straight-line segments, the Residential road is the default road.

  2. Right-click to place the start and endpoints of the arc. If you use this method to connect straight lines, there might be multiple control points. Delete all but one control point.

  3. To create a control point, right-click anywhere in the road. To position it as specified in red in the oval track figure at the beginning of Step 1, left-click each arc control point.

  4. To create the circular arc, edit the positions of the control points.

    If the start of a road marks the end of another, RoadRunner connects them.

Adjust Road Width

  1. Open the Lane Width Tool.

  2. Select the road that needs the width adjustment.

  3. To adjust the road width, select any purple or red segment.

  4. Modify the lines so that the entire width of the road is 14 m, or 7 m from the road centerline to each edge.

Create Patch

  1. Open the Surface Tool.

  2. Right-click to create four nodes.

  3. Right-click the first node to close the loop. By default, the surface is green.

Add Trees

To provide visual cues that indicate vehicle speed, add trees.

  1. Open the Prop Curve Tool.

  2. Select an asset to place in the scene. For example, select Props\Trees\Eucalyptus_Sm01.

  3. Right-click to select the inner boundary of the trajectory. To limit the trees in the green areas, adjust the tangents at the control points.

  4. To speed up import into Unreal Engine, choose an appropriate spacing that limits the number of trees in the scene. The import time is proportional to the number of scene assets.

Step 2: Export Track from RoadRunner

  1. In RoadRunner, open the scene.

  2. Select File > Export > Unreal (.fbx, .xodr + rrdata.xml)

  3. In the Export Unreal dialog box, select Split by Segmentation and export folder. Click Export.

Step 3: Import Track to Unreal Engine

After exporting from RoadRunner, you import the data into Unreal Engine.

Create Empty Project

Create an empty project by following the steps listed in Create Empty Project in Unreal Engine.

Acquire and Rebuild RoadRunner Plugins

  1. Download the RoadRunner plugin. For more information, see Downloading Plugins (RoadRunner).

  2. Extract the RoadRunner plugin .zip file. Locate the RoadRunnerImporter and RoadRunnerMaterials folders under the Unreal Engine plugins.

    Note

    The Unreal Engine plugin folder also contains a RoadRunnerCarla integration plugin. If you are not using CARLA, do not copy this folder.

  3. Copy the RoadRunnerImporter and RoadRunnerMaterials folders into the Plugins folder under the project folder. If a Plugins folder does not exist, create one.

    Image of Plugins folder.

  4. Rebuild the plugin using one of these options:

    • Option A: Generate project files and build.

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

      • Linux® – Set environment variable UE4_ROOT to your Unreal Engine installation folder. At the command line, run this command:

        $UE4_ROOT/GenerateProjectFiles.sh -project="<Path to .uproject file>" -game -engine

    • Option B: Open the project directly. Select Yes to build the plugins when prompted.

    If both options fail, try using Visual Studio to build the binaries.

  5. Verify that the RoadRunner and MathWorks Interface plugins are enabled. Select Edit > Plugins. Confirm that Enabled is selected.

Import to Unreal Engine

  1. In the Unreal® Editor, click Import. Select the .fbx file from Step 2.

    Note

    Selecting File > Import Into Level does not use the exported RoadRunner xml. Instead, it uses the Unreal importer.

  2. Use the default options in the RoadRunner Import Options dialog box. Click Import.

  3. Under the Scene tab, select Import as Dynamic. This setting enables translation of the whole scene.

  4. Under Static Meshes, clear Remove Degenerates. Set Normal Input Method to Input Normals. The import can take up to 1 hour to complete. Click Import.

  5. In the World Outliner, select the scene that you imported, for example, FbxScene_OvalTrack1. To align the RoadRunner and Unreal coordinate systems, enter a 90° rotation about the Z-axis.

    Unreal Engine World Outliner tab

  6. Consider using the editor to add terrain and foliage to the scene.

  7. Save the project (.uproject) file. Close the Unreal Editor.

Step 4: Co-Simulate in Vehicle Dynamics Blockset

  1. Open the Simulink® model. Do not open the Unreal Editor.

  2. Open the Simulation 3D Scene Configuration block.

    1. Set Scene source to Unreal Editor.

    2. Set Project to the project (.uproject) file that you saved in Step 3: Import Track to Unreal Engine.

    3. Click Apply.

    4. Click Open Unreal Editor.

    The project opens in the Unreal Editor.

  3. Select Blueprints > Open Level Blueprint.

  4. In the level blueprint:

    1. Select File > Reparent Blueprint.

    2. Select Sim3dLevelScriptActor.

    3. Click Save.

    4. Close the level blueprint.

    5. In the editor, click Save Current.

    This ensures that the vehicle identifies the ground properly during co-simulation.

    1. In the Simulink model, click Run.

      Because the source of the scenes is the project opened in the Unreal Editor, the simulation does not start.

    2. Verify that the Diagnostic Viewer window in Simulink displays this message:

      In the Simulation 3D Scene Configuration block, you set the scene source to 'Unreal Editor'. In Unreal Editor, select 'Play' to view the scene.

      This message confirms that Simulink has instantiated the actors and other assets in the Unreal Engine 3D environment.

    3. In the Unreal Editor, click Play. The simulation runs in the scene currently open in the Unreal Editor.

See Also

|

Topics