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.
The model consists of these main components:
Scene – A Simulation 3D Scene Configuration block configures the scene in which you simulate.
Vehicles – A Simulation 3D UAV Vehicle blocks configures the quadrotor within the scene and specifies its trajectory.
Sensor – A Simulation 3D Fisheye Camera configures the mounting position and parameters of the fisheye camera used to capture simulation data. A Video Viewer (Computer Vision Toolbox) block visualizes the simulation output of this sensor.
You can open the model using the following command.
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.
imshow('USCityBlock.jpg',... 'XData', [-242.998152046784, 200.198152046784],... 'YData', [-215.598152046784,227.598152046784]); set(gca,'YDir','normal')
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.
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.
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 forward along the X-axis of the center of the ego vehicle by 0.1 meters.
The Parameters tab contains the intrinsic camera parameters of a fisheye camera. These parameters are set to their default values except the mapping coefficient, where the second coefficient is set to -0.0005 to model lens distortion.
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 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.