Main Content

Simulation 3D Scene Configuration

Scene configuration for 3D simulation environment

Since R2020b

  • Simulation 3D Scene Configuration block

Libraries:
UAV Toolbox / Simulation 3D
Aerospace Blockset / Animation / Simulation 3D
Automated Driving Toolbox / Simulation 3D
Vehicle Dynamics Blockset / Vehicle Scenarios / Sim3D / Sim3D Core
Simulink 3D Animation / Simulation 3D

Description

The Simulation 3D Scene Configuration block implements a 3D simulation environment that is rendered by using the Unreal Engine® from Epic Games®. UAV Toolbox integrates the 3D simulation environment with Simulink® so that you can query the world around the vehicle and virtually test perception, control, and planning algorithms.

You can simulate from a set of prebuilt scene or from your own custom scenes. Scene customization requires the UAV Toolbox Interface for Unreal Engine Projects support package. For more details, see Customize Unreal Engine Scenes for UAVs.

You can also simulate custom scenes designed and built in RoadRunner. To do so, you must first export scenes from RoadRunner and specify the path to the exported scene artifacts in the Project parameter of the Simulation 3D Scene Configuration block.

Note

The Simulation 3D Scene Configuration block must execute after blocks that send data to the 3D environment and before blocks that receive data from the 3D environment. To verify the execution order of such blocks, right-click the blocks and select Properties. Then, on the General tab, confirm these Priority settings:

  • For blocks that send data to the 3D environment, such as Simulation 3D Vehicle with Ground Following blocks, Priority must be set to -1. That way, these blocks prepare their data before the 3D environment receives it.

  • For the Simulation 3D Scene Configuration block in your model, Priority must be set to 0.

  • For blocks that receive data from the 3D environment, such as blocks, Priority must be set to 1. That way, the 3D environment can prepare the data before these blocks receive it.

For more information about execution order, see Block Execution Order.

Parameters

expand all

Scene Selection

Source of the scene in which to simulate, specified as one of the options in the table.

OptionDescription
Default Scene

Simulate in the default, prebuilt scene specified in the Scene name parameter.

RoadRunner

Simulate in a RoadRunner scene. To import the scene, specify the RoadRunner file in the Project parameter.

To export a scene from RoadRunner, use the option CARLA Filmbox in Export Using CARLA Filmbox (RoadRunner).

Unreal Executable

Simulate in a scene that is part of an Unreal Engine executable file. Specify the executable file in the File name parameter. Specify the scene in the Scene parameter.

Select this option to simulate in custom scenes that have been packaged into an executable for faster simulation.

Unreal Editor

Simulate in a scene that is part of an Unreal Engine project (.uproject) file and is open in the Unreal® Editor. Specify the project file in the Project parameter.

Select this option when developing custom scenes. By clicking Open Unreal Editor, you can co-simulate within Simulink and the Unreal Editor and modify your scenes based on the simulation results.

Name of the prebuilt 3D scene in which to simulate, specified as one of these options. For details about a scene, see its listed corresponding reference page.

The UAV Toolbox Interface for Unreal Engine Projects contains customizable versions of these scenes. For details about customizing scenes, see Customize Unreal Engine Scenes for UAVs.

Dependencies

To enable this parameter, set Scene source to Default Scene.

Name of the Unreal Engine executable file, specified as a valid executable file name. You can either browse for the file or specify the full path to the file, using backslashes. To specify a scene from this file to simulate in, use the Scene parameter.

By default, File name is set to VehicleSimulation.exe, which is on the MATLAB® search path.

Example: C:\Local\WindowsNoEditor\AutoVrtlEnv.exe

Dependencies

To enable this parameter, set Scene source to Unreal Executable.

Name of a scene from the executable file specified by the File name parameter, specified as a path to a valid scene name.

When you package scenes from an Unreal Engine project into an executable file, the Unreal Editor saves the scenes to an internal folder within the executable file. This folder is located at the path /Game/Maps. Therefore, you must prepend /Game/Maps to the scene name. You must specify this path using forward slashes. For the file name, do not specify the .umap extension. For example, if the scene from the executable in which you want to simulate is named myScene.umap, specify Scene as /Game/Maps/myScene.

Alternatively, you can browse for the scene in the corresponding Unreal Engine project. These scenes are typically saved to the Content/Maps subfolder of the project. This subfolder contains all the scenes in your project. The scenes have the extension .umap. Select one of the scenes that you packaged into the executable file specified by the File name parameter. Use backward slashes and specify the .umap extension for the scene.

By default, Scene is set to /Game/Maps/USCityBlock, which is a scene from the default VehicleSimulation.exe executable file specified by the File name parameter. This scene corresponds to the prebuilt Straight Road scene.

Example: /Game/Maps/scene1

Example: C:\Local\myProject\Content\Maps\scene1.umap

Dependencies

To enable this parameter, set Scene source to Unreal Executable.

Name of the Unreal Engine project file, specified as a valid project file name. You can either browse for the file or specify the full path to the file, using backslashes. The file must contain no spaces. To simulate scenes from this project in the Unreal Editor, click Open Unreal Editor. If you have an Unreal Editor session open already, then this button is disabled.

To run the simulation, in Simulink, click Run. Before you click Play in the Unreal Editor, wait until the Diagnostic Viewer window displays this confirmation 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 scene actors, including the vehicles and cameras, in the Unreal Engine 3D environment. If you click Play before the Diagnostic Viewer window displays this confirmation message, Simulink might not instantiate the actors in the Unreal Editor.

Dependencies

To enable this parameter, set Scene source to Unreal Editor.

Scene Parameters

Configure the placement of the virtual camera that displays the scene during simulation.

  • If your model contains no Simulation 3D UAV Vehicle blocks, then during simulation, you view the scene from a camera positioned at the scene origin.

  • If your model contains at least one vehicle block, then by default, you view the scene from behind the first vehicle that was placed in your model. To change the view to a different vehicle, set Scene view to the name of that vehicle. The Scene view parameter list is populated with all the Name parameter values of the vehicle blocks contained in your model.

If you add a Simulation 3D Scene Configuration block to your model before adding any vehicle blocks, the virtual camera remains positioned at the scene. To reposition the camera to follow a vehicle, update this parameter.

Scene Controls

When Scene view is set to Scene Origin or Custom, you can change the location of the camera to navigate in the scene during simulation using keyboard and mouse control. You can also change the camera location when the simulation is paused.

To navigate in virtual world, use these keyboard shortcuts.

Keyboard ShortcutCamera Control

W

Move forward.

Shift+W

Move faster in the forward direction.

S

Move backward.

Shift+S

Move faster in reverse direction.

A

Move left.

Shift+A

Move faster toward left.

D

Move right.

Shift+D

Move faster toward right.

Q

Move up.

Shift+Q

Move faster in the upward direction.

E

Move down.

Shift+E

Move faster in the downward direction.

Mouse scroll wheel

Control the camera distance from the cursor point.

Shift+mouse scroll wheel

Camera moves faster.

Mouse right-click and drag

Orbit around the cursor point.

O

Attach camera to actor under the cursor point.

Mouse left-click and drag

Orbit around the actor after camera attaches to the actor.

P

Detach camera from the actor.

L

Record the current viewpoint and display Location saved on the scene.

1 to 9

Access the stored viewpoints, if available.

Tab

Cycle the view between all vehicles in the scene and the viewpoint at the start of the simulation, in the forward direction.

Shift+Tab

Cycle the view between all vehicles in the scene and the viewpoint at the start of the simulation, in the reverse direction.

Vehicle Views

When Scene view is set to a vehicle name, you can change the location of the camera around the vehicle during simulation.

To smoothly change the camera views, use these key commands.

KeyCamera View

1

Back left

Image showing key commands and corresponding camera view

2

Back

3

Back right

4

Left

5

Internal

6

Right

7

Front left

8

Front

9

Front right

0

Overhead

For additional camera controls, use these key commands.

KeyCamera Control
Tab

Cycle the view between all vehicles in the scene.

Mouse scroll wheel

Control the camera distance from the vehicle.

L

Toggle a camera lag effect on or off. When you enable the lag effect, the camera view includes:

  • Position lag, based on the vehicle translational acceleration

  • Rotation lag, based on the vehicle rotational velocity

This lag enables improved visualization of overall vehicle acceleration and rotation.

F

Toggle the free camera mode on or off. When you enable the free camera mode, you can use the mouse to change the pitch and yaw of the camera. This mode enables you to orbit the camera around the vehicle.

Sample time, Ts, of the visualization engine, specified as a scalar greater than or equal to 0.01. Units are in seconds.

The graphics frame rate of the visualization engine is the inverse of the sample time. For example, if Sample time is 1/60, then the visualization engine solver tries to achieve a frame rate of 60 frames per second. However, the real-time graphics frame rate is often lower due to factors such as graphics card performance and model complexity.

By default, blocks that receive data from the visualization engine, such as Simulation 3D Camera blocks, inherit this sample rate.

Select whether to run simulations in the 3D visualization environment without visualizing the results, that is, in headless mode.

Consider running in headless mode in these cases:

  • You want to run multiple 3D simulations in parallel to test models in different Unreal Engine scenarios.

Dependencies

To enable this parameter, set Scene source to Default Scene or Unreal Executable.

Select whether to run simulations in web browsers on local or remote devices, including:

  • Local desktops

  • Remote desktops

  • Mobile phones

To display the simulation in a web browser:

  1. If you do not have it installed, install Node.js® on the system that runs the simulation.

  2. Select Display 3D simulation window in a web browser. Apply the change.

  3. In Simulink, select Run.

  4. Follow the steps provided in the Diagnostic Viewer.

    Web Browser DisplaySteps

    Current device

    1. Open a web browser on your current device.

    2. Navigate to the first IP address link provided in the Diagnostic Viewer.

    Remote device

    1. Open a web browser on a remote device that is on the same network.

    2. Navigate to the second IP address link provided in the Diagnostic Viewer.

    Note

    To establish the connections, the system server uses two ports:

    • 7070http: connection to web browser

    • 8888– Streamer connection from Unreal Engine application

Dependencies

To enable this parameter, set Scene source to Default Scenes or Unreal Executable.

Weather

Select whether to control the scene weather and sun position during simulation. Use the enabled parameters to change the sun position, clouds, fog, and rain.

This table summarizes sun position settings for specific times of day.

Time of DaySettingsUnreal Editor Environment

Midnight

Sun altitude: -90

Sun azimuth: 180

Road at midnight

Sunrise in the north

Sun altitude: 0

Sun azimuth: 180

Road at sunrise

Noon

Sun altitude: 90

Sun azimuth: 180

Road at noon

This table summarizes settings for specific cloud conditions.

Cloud ConditionSettingsUnreal Editor Environment

Clear

Cloud opacity: 0

Road with clear skies

Heavy

Cloud opacity: 85

Road with cloudy skies

This table summarizes settings for specific fog conditions.

Fog ConditionSettingsUnreal Editor Environment

None

Fog density: 0

Road with no fog

Heavy

Fog density: 100

Road with heavy fog

This table summarizes settings for specific rain conditions.

Rain ConditionSettingsUnreal Editor Environment

Light

Cloud opacity: 10

Rain density: 25

City scene with light rain

Heavy

Cloud opacity: 10

Rain density: 80

City scene with heavy rain

Altitude angle in a vertical plane between the sun's rays and the horizontal projection of the rays, in deg.

Use the Sun altitude and Sun azimuth parameters to control the time of day in the scene. For example, to specify sunrise in the north, set Sun altitude to 0 deg and Sun azimuth to 180 deg.

Dependencies

To enable this parameter, select Override scene weather.

Azimuth angle in the horizontal plane measured from the south to the horizontal projection of the sun rays, in deg.

Use the Sun altitude and Sun azimuth parameters to control the time of day in the scene. For example, to specify sunrise in the north, set Sun altitude to 0 deg and Sun azimuth to 180 deg.

Dependencies

To enable this parameter, select Override scene weather.

Parameter that corresponds to the Unreal Editor Cloud Opacity global actor target value, in percent. Zero is a cloudless scene.

Use the Cloud opacity and Cloud speed parameters to control clouds in the scene.

Dependencies

To enable this parameter, select Override scene weather.

Parameter that corresponds to the Unreal Editor Cloud Speed global actor target value. The clouds move from west to east for positive values and east to west for negative values.

Use the Cloud opacity and Cloud speed parameters to control clouds in the scene.

Dependencies

To enable this parameter, select Override scene weather.

Parameter that corresponds to the Unreal Editor Set Fog Density and Set Start Distance target values, in percent.

Dependencies

To enable this parameter, select Override scene weather.

Parameter corresponding to the Unreal Editor local actor that controls rain density, wetness, rain puddles, and ripples, in percent.

Use the Cloud opacity and Rain density parameters to control rain in the scene.

Dependencies

To enable this parameter, select Override scene weather.

Geospatial

Select this parameter to enable geospatial parameters and a variant subsystem.

Specify your Cesium access token ID. To create this token, create a Cesium® ion™ account, then generate the token through this account. For more information, see https://ion.cesium.com/.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the height of the origin, in meters, above the 1984 World Geodetic System (WGS84) ellipsoid model of the Earth at the latitude and longitude specified in Origin latitude and Origin longitude.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the latitude of the origin in decimal degrees.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the longitude of the origin in decimal degrees.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the raster overlay type of the map as Aerial, Aerial with labels, or Road.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the local data set IDs.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Select this parameter to add a georeferenced, location-accurate Sun Sky actor to the simulation.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

Specify the current solar time in hours from midnight.

Dependencies

To enable this parameter, select the Enable geospatial configuration and Use advanced Sun sky parameters.

Specify the current time zone in hours offset from Greenwich Mean Time (GMT). To specify time zones earlier than GMT, use a negative value.

Dependencies

To enable this parameter, select the Enable geospatial configuration and Use advanced Sun sky parameters.

Specify the day of the month, from 1 to 31.

Dependencies

To enable this parameter, select the Enable geospatial configuration and Use advanced Sun sky parameters.

Specify the month, from 1 to 12.

Dependencies

To enable this parameter, select the Enable geospatial configuration and Use advanced Sun sky parameters.

Specify the year.

Dependencies

To enable this parameter, select the Enable geospatial configuration and Use advanced Sun sky parameters.

Select this parameter to enable daylight saving time.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Specify the start day of daylight saving time, specified as a scalar from 1 to 31.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Specify the start month of daylight saving time, from 1 to 12.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Specify the end day of daylight saving time, from 1 to 31.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Specify the end month of daylight saving time, from 1 to 12.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Hour when daylight saving time switches, from 1 to 24.

Dependencies

To enable this parameter, select the Enable geospatial configuration, Use advanced Sun sky, and Use daylight saving time (DST) parameters.

Click to manage access tokens, such to create, update, and delete tokens.

Dependencies

To enable this parameter, select the Enable geospatial configuration parameter.

More About

expand all

Version History

Introduced in R2020b

expand all