Simulation 3D Scene Configuration
Libraries:
Vehicle Dynamics Blockset /
Vehicle Scenarios /
Sim3D /
Sim3D Core
Aerospace Blockset /
Animation /
Simulation 3D
Automated Driving Toolbox /
Simulation 3D
UAV Toolbox /
Simulation 3D
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®. Aerospace Blockset™ Interface for Unreal Engine Projects 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. Using this block, you can also control the position of the sun and the weather conditions of a scene. For more details, see Sun Position and Weather.
You can simulate from a set of prebuilt scenes or from your own custom scenes. Scene customization requires the Aerospace Blockset Interface for Unreal Engine Projects support package. For more details, see Customize 3D Scenes for Aerospace Blockset Simulations.
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 Control and Display Execution Order.
Examples
Parameters
Scene
Scene SelectionScene source — Source of scene
Default Scenes
(default) | Unreal Executable
| Unreal Editor
Source of the scene in which to simulate, specified as one of the options in the table.
Option | Description |
---|---|
Default Scenes | Simulate in one of the default, prebuilt scenes specified in the Scene name parameter. |
Unreal Executable | Simulate in a scene that is part of an Unreal Engine executable file. Specify the executable file in the Project 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 ( 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. |
Scene name — Name of prebuilt 3D scene
Airport
(default)
Name of the prebuilt 3D scene in which to simulate, specified as one of these options.
The Aerospace Blockset Interface for Unreal Engine Projects contains customizable versions of these scenes. For details about customizing scenes, see Customize Scenes Using Simulink and Unreal Editor.
Dependencies
To enable this parameter, set Scene source to
Default Scenes
.
Project name — Name of Unreal Engine executable file
VehicleSimulation.exe
(default) | valid executable file name
Name of the Unreal Engine executable file, specified as a valid executable project file name. You can either browse for the file or specify the full path to the project file, using backslashes. To specify a scene from this file to simulate in, use the Scene parameter.
By default, Project 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
.
Scene — Name of scene from executable file
/Game/Maps/HwStrght
(default) | path to valid scene name
Name of a scene from the executable file specified by the Project 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 Project name parameter.
Use backward slashes and specify the .umap
extension for the
scene.
By default, Scene is set to
/Game/Maps/HwStrght
, which is a scene from the default
VehicleSimulation.exe
executable file specified by the
Project 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
.
Project — Name of Unreal Engine project file
valid project file name
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.
Dependencies
To enable this parameter, set Scene source to
Unreal Editor
.
Scene view — Configure placement of virtual camera that displays scene
Scene Origin
| vehicle name
Configure the placement of the virtual camera that displays the scene during simulation.
If your model contains no 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.
When Scene view is set to a vehicle name, during simulation, you can change the location of the camera around the vehicle.
To smoothly change the camera views, use these key commands.
Key | Camera View | |
---|---|---|
1 | Back left |
|
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.
Key | Camera 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:
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 — Sample time of visualization engine
(default) | scalar greater than or equal to 0.01
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 blocks, inherit this sample rate.
Display 3D simulation window — Unreal Engine visualization
on
(default) | off
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 Scenes
or Unreal
Executable
.
Weather
Override scene weather — Control the scene weather and sun position
off
(default) | on
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 Day | Settings | Unreal Editor Environment |
---|---|---|
Midnight | Sun altitude: -90 Sun azimuth: 180 | |
Sunrise in the north | Sun altitude: 0 Sun azimuth: 180 | |
Noon | Sun altitude: 90 Sun azimuth: 180 |
This table summarizes settings for specific cloud conditions.
Cloud Condition | Settings | Unreal Editor Environment |
---|---|---|
Clear | Cloud opacity: 0 | |
Heavy | Cloud opacity: 85 |
This table summarizes settings for specific fog conditions.
Fog Condition | Settings | Unreal Editor Environment |
---|---|---|
None | Fog density: 0 | |
Heavy | Fog density: 100 |
This table summarizes settings for specific rain conditions.
Rain Condition | Settings | Unreal Editor Environment |
---|---|---|
Light | Cloud opacity: 10 Rain density: 25 | |
Heavy | Cloud opacity: 10 Rain density: 80 |
Sun altitude — Altitude angle between sun and horizon
40
(default) | any value between -90
and 90
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.
Sun azimuth — Azimuth angle from south to horizontal projection of the sun ray
90
(default) | any value between 0
and 360
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.
Cloud opacity — Unreal Editor Cloud Opacity global actor target value
10
(default) | any value between 0
and 100
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.
Cloud speed — Unreal Editor Cloud Speed global actor target value
1
(default) | any value between -100
and 100
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.
Fog density — Unreal Editor Set Fog Density and Set Start Distance target values
0
(default) | any value between 0
and 100
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.
Rain density — Unreal Editor local actor controlling rain density, wetness, rain puddles, and ripples
0
(default) | any value between 0
and 100
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
Enable geospatial configuration — Option to enable geospatial parameters and variant subsystem
off (default) | on
Select this check box to enable geospatial parameters and a variant subsystem.
Access token ID — ID of stored token
string representing ID of stored token
ID of stored token, specified as a string. To create this token, create a Cesium® ion™ account, then generate the token through this account. For more information, see https://cesium.com/ion.
Origin height (m) — Height at georeference point on globe
real scalar
Height at georeference point on the globe, specified as a real scalar. This parameter represents the height above the 1984 World Geodetic System (WGS84) ellipsoid model of the Earth at the latitude and longitude specified in Origin latitude and Origin longitude.
Origin latitude — Latitude
real scalar
Latitude, specified as a real scalar in decimal degrees.
Origin longitude — Longitude
real scalar
Longitude, specified as a real scalar in decimal degrees.
Map style — Raster overlay type
Aerial
(default) | Aerial with labels
| Road
Raster overlay type, specified as Aerial
,
Aerial with labels
, or
Road
.
Additional asset IDs — Local dataset IDs
[]
(default) | array | vector
Local dataset IDs, specified as an array or vector.
Use advanced Sun sky — Georeferenced, location-accurate Sun Sky actor
off
(default) | on
Select this check box to add a georeferenced, location-accurate Sun Sky actor in simulation.
Solar time — Current solar time
11
(default) | scalar real
Current solar time, specified as scalar hours from midnight.
Time zone — Time zone
11
(default) | scalar real
Time zone, specified as hours offset from Greenwich Mean Time (GMT). To specify
hours before GMT, use a minus sign (-
).
Day — Day
21
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
| 28
| 29
| 30
| 31
Day, specified as a scalar from 1
to
31
.
Month — Month
9
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
Month, specified as a scalar from 1
to
12
.
Year — Year
2022
(default) | scalar real
Year, specified as a scalar real.
Use daylight saving time (DST) — Daylight saving time
off
(default) | on
Select this check box to enable daylight saving time.
DST start day — Start day of daylight saving time
10
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
| 28
| 29
| 30
| 31
Start day of daylight saving time, specified as a scalar from 1
to 31
.
DST start month — Start month of daylight saving time
3
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
Start month of daylight saving time, specified as a scalar from
1
to 12
.
DST end day — Last day of daylight saving time
3
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
| 25
| 26
| 27
| 28
| 29
| 30
| 31
Last day of daylight saving time, specified as a scalar from 1
to 31
.
DST end month — Last month of daylight saving time
11
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
Last month of daylight saving time, specified as a scalar from
1
to 12
.
DST switch hour — Hour when daylight saving time switches
2
(default) | 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 13
| 14
| 15
| 16
| 17
| 18
| 19
| 20
| 21
| 22
| 23
| 24
Hour when daylight saving time switches, specified as a scalar from
1
to 24
.
Authentication manager — Management of access tokens
button
Click to manage access tokens, such as create, update, and delete tokens.
More About
Sun Position and Weather
To control the scene weather and sun position, on the Weather tab, select Override scene weather. Use the enabled parameters to change the sun position, clouds, fog, and rain during the simulation.
Use Sun altitude and Sun azimuth to control the sun position.
Sun altitude — Altitude angle in a vertical plane between the sun rays and the horizontal projection of the rays.
Sun azimuth — Azimuth angle in the horizontal plane measured from the south to the horizontal projection of the sun rays.
This table summarizes sun position settings for specific times of day.
Time of Day | Settings | Unreal Editor Environment |
---|---|---|
Midnight | Sun altitude: -90 Sun azimuth: 180 | |
Sunrise in the north | Sun altitude: 0 Sun azimuth: 180 | |
Noon | Sun altitude: 90 Sun azimuth: 180 |
Use Cloud opacity and Cloud speed to control clouds in the scene.
Cloud opacity — Unreal Editor Cloud Opacity global actor target value. Zero is a cloudless scene.
Cloud speed — 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.
This table summarizes settings for specific cloud conditions.
Cloud Condition | Settings | Unreal Editor Environment |
---|---|---|
Clear | Cloud opacity: 0 | |
Heavy | Cloud opacity: 85 |
Use Fog density to control fog in the scene. Fog density corresponds to the Unreal Editor Set Fog Density.
This table summarizes settings for specific fog conditions.
Fog Condition | Settings | Unreal Editor Environment |
---|---|---|
None | Fog density: 0 | |
Heavy | Fog density: 100 |
Use Cloud opacity and Rain density to control rain in the scene.
Cloud opacity — Unreal Editor Cloud Opacity global actor target value.
Rain density — Unreal Editor local actor that controls rain density, wetness, rain puddles, and ripples.
This table summarizes settings for specific rain conditions.
Rain Condition | Settings | Unreal Editor Environment |
---|---|---|
Light | Cloud opacity: 10 Rain density: 25 | |
Heavy | Cloud opacity: 10 Rain density: 80 |
Version History
Introduced in R2021b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)