Visualize VTOL Flight Mission Over Urban Environment
This example shows how to visualize a vertical takeoff and landing (VTOL) aircraft in Unreal Engine® while flying a mission within an urban environment. In the previous examples, the control design for a tiltrotor VTOL has been previously tuned through hover, transition and fixed wing flight. This example leverages the custom actor workflow in UAV Toolbox™ to visualize aircraft performance in a photorealistic environment.
Prerequisites
Download and install UAV Toolbox Interface for Unreal Engine Projects. For more information about installing and setting up the UAV Toolbox Interface, see Install Support Package for Customizing Scenes.
This example uses a 3D Game Asset Urban Air Mobilty Vehicle dataset, which contains a fbx file of a VTOL UAV and is approximately 6 MB in size. Download the VTOLAsset
ZIP file from the MathWorks website, then unzip the file.
zipFile = matlab.internal.examples.downloadSupportFile("uav","data/VTOLAsset.zip"); filepath = fileparts(zipFile); dataFolder = fullfile(filepath,'VTOLAsset'); unzip(zipFile,dataFolder)
Getting Started
Open the VTOL MATLAB project.
prj = openProject("VTOLApp/VTOLRefApp.prj");
This example uses MATLAB Project shortcuts. Use the highlighted project shortcuts for setting up the model and the photrealistic simulation. You can use the other project shortcuts for tuning the hover, fixed-wing, transition configurations. To see these shortcuts, you must open and view the Project editor tab.
Click Getting Started in Project Shortcuts tab to set up the aircraft plant model and base controller. You can also set up the model and controller programmatically by using the setupPlant
helper function.
setupPlant;
Initialized VTOL model. Enabled hover configuration. Enabled hover guidance mission.
Open the Visualization
subsystem of the VTOLTiltrotor
model.
load_system("VTOLTiltrotor") open_system("VTOLTiltrotor/Visualization")
Set Up Unreal Visualization
Click Photorealistic Visualization in the Project Shortcuts tab to configure the VTOLTiltrotor
Simulink® model to use the Unreal Engine to simulate the VTOL mission. This shortcut also configures the VTOL aircraft with some predefined control gains and a guidance mission. You can also configure the aircraft programmatically by using the setupPlant
helper function.
setupCityMission;
Initialized city mission.
Point Model to Unreal Engine Project
Open the Photorealistic
subsystem in the Visualization
subsystem.
open_system("VTOLTiltrotor/Visualization/Photorealistic")
Open the Simulation 3D Scene Configuration block mask and set the Scene source parameter to Unreal Editor
and supply the path to the AutoVrtlEnv
Unreal Engine project on your system. If you do not have the AutoVrtlEnv
file, you must download the UAV Toolbox Interface for Unreal Engine Projects support package to complete this step. The installation and set up process for the UAV Toolbox Interface for Unreal Engine Projects includes setting up the AutoVrtlEnv
file.
Import VTOL Vehicle into Unreal Engine Scene
To use the VTOL asset in Unreal Engine scenes, you must import the asset into Unreal Engine. After importing the asset, you do not need to import the VTOL asset again for future use in Unreal Engine.
Launch Unreal Editor
In the Photorealistic
subsystem, click Open Unreal Editor in the Simulation 3D Scene Configuration block to launch Unreal Editor from MATLAB.
Import VTOL Asset into Unreal Engine Scene.
Click Add/Import in Unreal Editor and select New Folder from the context menu. Create a folder called EVTOL
in the Content Browser pane and then open the EVTOL
folder.
Click Add/Import again and then select Import to Game/EVTOL
. Navigate to the folder that the VTOLAsset
is saved in and select the VTOLAsset
file to open the FBX Import Options dialog box.
To select a skeleton mesh, you must first open the Skeleton
drop down list and click the View Options drop down. Then select both Show Engine Content
and Show Plugin Content
to add the UAV_Skeleton
mesh option to the Skeleton
drop down list. Then select UAV_Skeleton
.
Set the Import Uniform Scale parameter to 0.25
in FBX Import Options to scale the VTOL asset to a smaller, more realistic size.
To finish the import of asset, click Import in Unreal Editor.
Customize VTOL Asset
Double click to select VTOL Asset
in the Content Browser pane to open the Asset Details window.
Now you need to select the element of the VTOL skeletal mesh that to be the main body of the vehicle and name it VehicleBody
. For this VTOL asset, select Element 1
, the fuselage, as the main body. You can verify that Element 1
is the fuselage by selecting isolate
to see which body the element is representing. Set the Slot Name of Element 1
to VehicleBody
. Then save the VTOL asset
Now right-click the VTOLAsset
skeletal mesh object in Content Browser pane and click Copy Reference
to copy the reference path to this asset.
In the Simulation 3D UAV Vehicle block of the Photorealistic
subsystem, set the Type parameter to Custom
and then set the Path to custom mesh parameter to the reference path.
Visualize VTOL Mission in Urban City Mission
Navigate to Maps in Content Browser and click on USCityBlock
to load the US City Block scene.
Run the VTOLTiltrotor
Simulink Model.
sim("VTOLTiltrotor");
When Simulink sits at initializing
, click Play in Unreal Editor. Zoom out using mouse scroll to visualize UAV flying a mission over the city. You can optionally enable Pacing in the Run > Simulation Pacing tab within Simulink to change the simulation speed so that the simulation runs at real time for smoother visualization.
Summary
In this example, you visualized a VTOL aircraft mission in 3-D simulation environment. Next, learn how to customize the VTOL controller.
See Also
Design and Tune Controller for VTOL UAV | Simulation 3D Scene Configuration | Simulation 3D UAV Vehicle