Main Content

Simulate Simple Flight Scenario and Sensor in Unreal Engine Environment

UAV Toolbox™ provides blocks for visualizing sensors in a simulation environment that uses the Unreal Engine® from Epic Games®. This model simulates a simple flight scenario in a prebuilt scene and captures data from the scene using a fisheye camera sensor. Use this model to learn the basics of configuring and simulating scenes, vehicles, and sensors. For more background on the Unreal Engine simulation environment, see Unreal Engine Simulation for Unmanned Aerial Vehicles.

Model Overview

The model consists of these main components:

You can open the model using the following command.


Inspect Scene

In the Simulation 3D Scene Configuration block, the Scene name parameter determines the scene where the simulation takes place. This model uses the US City Block scene. To explore a scene, you can open the 2D image corresponding to the Unreal Engine scene.

    'XData', [-242.998152046784, 200.198152046784],...
    'YData', [-215.598152046784,227.598152046784]);

The Scene view parameter of this block determines the view from which the Unreal Engine window displays the scene. In this block, Scene view is set to the root of the scene (the scene origin), select root. You can also change the scene view to the quadrotor UAV.

Inspect Vehicle

The Simulation 3D UAV Vehicle block models the quadcopter, named Quadrotor1, in the scenario. During simulation, the quadrotor flys one complete circle with a radius of 5m and elevation of 1.5m around the center of the scene. The viewpoint of the quadrotor yaw oscillates yaw from left to right in the direction of travel.

To create more realistic trajectories, you can obtain waypoints from a scene interactively and specify these waypoints as inputs to the Simulation 3D UAV Vehicle block. See Select Waypoints for Unreal Engine Simulation.

Inspect Sensor

The Simulation 3D Fisheye Camera block models the sensor used in the scenario. Open this block and inspect its parameters.

  • The Mounting tab contains parameters that determine the mounting location of the sensor. The fisheye camera sensor is mounted to the center of the roof of the ego vehicle.

  • The Parameters tab contains the intrinsic camera parameters of a fisheye camera. These parameters are set to their default values.

  • The Ground Truth tab contains a parameter for outputting the location and orientation of the sensor in meters and radians. In this model, the block outputs these values so you can see how they change during simulation.

The block outputs images captured from the simulation. During simulation, the Video Viewer block displays these images.

Simulate Model

Simulate the model. When the simulation begins, it can take a few seconds for the visualization engine to initialize, especially when you are running it for the first time. The MathWorks_Aerospace window shows a view of the scene in the Unreal Engine environment.

To change the view of the scene during simulation, use the numbers 1–9 on the numeric keypad. For a bird's-eye view of the scene, press 0.

After simulating the model, try modifying the intrinsic camera parameters and observe the effects on simulation. You can also change the type of sensor block. For example, try substituting the 3D Simulation Fisheye Camera with a 3D Simulation Camera block. For more details on the available sensor blocks, see Choose a Sensor for Unreal Engine Simulation.

See Also

| |