Main Content

How 3D Simulation in Unreal Engine Environment Works

Simulink® 3D Animation™ allows you to co-simulate MATLAB® and Simulink with the 3D simulation engine from Unreal Engine® from Epic Games®. This co-simulation framework allows Simulink 3D Animation to send data between the Unreal Engine and MATLAB or Simulink. Understanding how communication with the 3D simulation engine works can help you troubleshoot performance issues and customize your models.

Communication with 3D Simulation Engine

When you run your algorithms using Simulink 3D Animation, MATLAB and Simulink co-simulate the algorithms with the 3D simulation engine through, lock-step mechanism. The lock-step mechanism is a synchronization approach where the simulation progresses in fixed time steps, and the two simulation engines, either MATLAB or Simulink and the 3D simulation engine, run sequentially. One simulation engine waits while the other simulation engine proceeds, so each simulation produces consistent results.

During each simulation step:

  • MATLAB or Simulink configures the initial settings of the 3D environment, including actor transformations and properties and the custom scene viewpoint. MATLAB or Simulink also determines the configuration parameters of the 3D environment and the actors using the 3D simulation engine feedback.

  • The co-simulation framework sends data from MATLAB or Simulink to the 3D simulation engine.

  • The co-simulation framework sends a command signal to the 3D simulation engine indicating the end of data transfer.

  • The 3D simulation engine executes the simulation. The 3D simulation engine configures the 3D environment and the actors based on the data from MATLAB or Simulink, then provides updated information about the 3D environment and the actors.

  • The co-simulation framework sends data from the 3D simulation engine to MATLAB or Simulink.

  • The co-simulation framework sends an acknowledge signal to MATLAB or Simulink, indicating the end of data transfer from the 3D simulation engine.

Information flow between MATLAB or Simulink and the 3D simulation environment

Simulation Speed

Simulation speed depends on the stop time and the sample time of the simulation. The stop time is the duration of the simulation. The sample time is the time interval at which the output is updated during the simulation. To set the stop time and the sample time in MATLAB, set the StopTime and SampleTime arguments, respectively, in the sim3d.World object. To set the sample time in Simulink, use the Sample time parameter in the Simulation 3D Scene Configuration block. If you decrease the sample time, the software takes more samples per second, so simulation speed decreases. For more information on sample time, see SampleTime

Simulation speed also depends on model complexity, computational speed, and the speed at which the system can render a scene, which depends on the system configuration. You can use the profile function in MATLAB or the Simulink Profiler (Simulink) in Simulink to analyze the distribution of simulation execution time among the simulation components and see the computational time of each component in the simulation. For more information on profiling, see Profile Your Code to Improve Performance.

See Also

| | | | |

Related Topics