Visualize VTOL UAV Takeoff and Forward Transition
This example shows how to visualize a VTOL UAV aircraft during vertical takeoff and forward transition in Unreal Engine®.
Prerequisites
To run this example, you must install the UAV Toolbox Interface for Unreal Engine® Projects and download the 3D model of the VTOL UAV.
1. For more information on how to download and install the UAV Toolbox Interface for Unreal Engine® Projects, see Install Support Package for Customizing Scenes. This process installs the Unreal Engine plugins and the AutoVrtlEnv
project.
2. Run this code to download the 3D model of the VTOL UAV from the MathWorks® website. The Design and Tune Controller for VTOL UAV reference application also uses this 3D model.
zipFile = matlab.internal.examples.downloadSupportFile("uav","data/VTOLAsset.zip"); filepath = fileparts(zipFile); dataFolder = fullfile(filepath,"VTOLAsset"); unzip(zipFile,dataFolder)
Model Overview
Open the VTOLUAVTakeoffModel.slx
Simulink® model.
modelName = "VTOLUAVTakeoffModel";
open_system(modelName)
The model consists of these blocks and subsystems:
Simulation 3D Scene Configuration
The Simulation 3D Scene Configuration block enables you to simulate the VTOL UAV mission in a 3D enivronment using Unreal Engine.
To configure this block for this example, specify the Project parameter of the Simulation 3D Scene Configuration block as the path to the AutoVrtlEnv
project on your system. Then, in the block mask, click Open Unreal Editor and import the VTOL UAV model into Unreal Editor.
For more information on how to import the VTOL UAV model into Unreal Editor, see the Import VTOL Vehicle into Unreal Engine section of the Visualize VTOL UAV Mission Over Urban Environment example.
Simulation 3D UAV Vehicle
The Simulation 3D UAV Vehicle block places the VTOL UAV model in the 3D scene.
To configure this block for this example, specify the Type parameter as Custom
. Then, copy the reference to the VTOL UAV asset from Unreal Editor by right-clicking the VTOLAsset
and selecting Copy Reference.
Paste the reference path into the Path to custom mesh parameter, and select OK.
Body Translation
The Body Translation
subsystem outputs the translation vector for the Simulation 3D UAV Vehicle block. This subsystem contains the UAV Body X Translation
which outputs the X-axis component of the translation vector, and the UAV Body Altitude
subsystem which outputs the Z-axis component of the translation vector. The Initial UAV Body Translation
constant determines the position of the UAV at the start of the simulation.
In this example, the Body Translation
subsystem is configured to output these X-, Y-, and Z- positions:
X-position — The UAV remains stationary on the X axis during the initial climb. After reaching 10 meters, the UAV starts to accelerate in the X direction at 2 meters per second squared.
Y-position — The UAV remains stationary on the Y axis during the entire simulation.
Z-position — The UAV initially starts at the ground, and takes off to a cruise altitude of 50 meters.
Rotor and Motor Rotations
The Rotor and Motor Rotations
subsystem outputs the Motor Rotation
and Rotor RPM
signals. These signals corresponds to the UAV_MotorN
rotation angles and UAV_RotorN
angular velocity inputs of the Simulation 3D UAV Vehicle block. This subsystem contains the Start Rotor RPM and Motor Tilt
subsystem which starts motor tilt after the UAV has reached an altitude specified in the Motor Tilt Altitude
constant. The Initial Front Motor Rotation
constant specifies the motor orientation at the start of the simulation.
In this example, the Rotor and Motor Rotations
subsystem is configured to output these rotor RPM and motor tilt:
Rotor RPM — Rotors gradually increase in angular velocity to a maximum of 800 RPM.
Motor tilt — Motor tilt angle starts at 0 degrees (vertically upward). Starting at an altitude of 10 meters, tilt angle is gradually increased to a maximum of 90 degrees (horizontally forward).
Combine Inputs
The Combine Inputs
subsystem combines the signals for the Rotation input into a matrix. This UAV model has four motor-rotor pairs, and only the front two motors tilt.
The subsystem assigns zeros for the inputs that are not applicable for this model. These consist of the rotations for motors 2 and 3, as well as the rotation inputs for motor-rotor pairs 5 through 8.
Run Simulation
To run the simulation:
1. Open Unreal Editor. Navigate to Maps in the Content Browser and double-click USCityBlock
to load the US City Block scene.
2. Open the Simulink model and click Run. After you click Run, Simulink model remains in the initialize state until you run the scene in Unreal Editor.
3. In Unreal Editor, click Play to run the scene.