Main Content

Send Double-Lane Change Scene Data

This example shows you how to use theSimulation 3D Message Setblock to communicate with the 3D visualization environment when you run the double-lane change maneuver. Specifically, you use theSimulation 3D Message Setblock to control the traffic signal light. For the minimum hardware required to run the example, see theUnreal Engine Simulation Environment Requirements and Limitations.

Run a Double-Lane Change Maneuver

With the 3D visualization environment enabled, run a double-lane change maneuver.

  1. Create and open a working copy of the double-lane change reference application project.

  2. Enable the 3D visualization environment. In the Visualization subsystem, open the3D Engineblock mask and selectEnabled. Apply the changes and save the model.

    Alternatively, at the MATLAB®command prompt, enter this code.

    See Code That Enables 3D Environment

  3. Run the maneuver for 30 seconds. View the simulation in the AutoVrtlEnv window.

    3D image of double-lane change scene

    See Code That Runs Simulation

UseSimulation 3D Message SetBlock to Control Traffic Signal Light

  1. Navigate to the Visualization > 3D Engine subsystem. Right-click the3D Engineblock and selectMask>Look Under Mask. In the Visualization > 3D Engine > 3D Engine subsystem, insert these blocks:

    • Simulation 3D Message Set

    • Repeating Sequence Stair

  2. Set theSimulation 3D Message Setblock parameters so that the block sends traffic signal data to the double-lane change scene. Set these block parameters, apply the changes, and save the model.

    • Signal name, SigNametoTrafficLight1

    • Sample timeto-1

    This table provides the scene traffic signal light color that corresponds to theWriteMsgvalue in the Double Lane Change scene.

    Simulation 3D Message SetBlockWriteMsgValue

    TrafficLight1Color

    0 Red
    1 Yellow
    2 Green

    Alternatively, at the MATLAB command prompt, enter this code.

    See Code That Sets Parameters

  3. Set theRepeating Sequence Stairblock parameters to send a command that corresponds to red, yellow, and green traffic light signals. Set these block parameters, apply the changes, and save the model.

    • Vector of output values:to[0 0 0 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2].'

    • Sample timeto1

      Repeating Sequence Stair block mask

    • Output data typetoint32

      Repeating Sequence Stair block mask

    Alternatively, at the MATLAB command prompt, enter this code. Apply the block changes and save the model.

    See Code That Sets Parameters

  4. Connect the blocks as shown. Confirm the block parameters and signal connections. Save the model.

    Simulink model.

  5. Verify that theSimulation 3D Message Setblock executes before theSimulation 3D Scene Configurationblock. That way,Simulation 3D Message Setprepares the signal data before the Unreal Engine®3D visualization environment receives it. To check the block execution order, right-click the blocks and selectProperties. On theGeneraltab, confirm thesePrioritysettings:

    • Simulation 3D Scene Configuration0

    • Simulation 3D Message Set-1

    For more information about execution order, seeControl and Display Execution Order.

  6. Run the maneuver. As the simulation runs, in the AutoVrtlEnv window, you can see theTrafficLight1light change from red to yellow to green.

    3D image of traffic light showing yellow light.

    Time Range (s)

    WriteMsgValue

    TrafficLight1Color

    0–3

    0 Red

    3–5

    1 Yellow

    5–30

    2 Green

See Also

||||

Related Examples

More About