Visualize VTOL UAV 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
To open the example livescript and directory which contains the Simulink project file, first run openExample('uav/VisualizeVTOLFlightMissionOverUrbanEnvironmentExample')
in the command window.
You must open the VTOLRefApp.prj project file to access the Simulink model, supporting files, and project shorcuts that this example uses.
% Open the Simulink project after running openExample('uav/VisualizeVTOLFlightMissionOverUrbanEnvironmentExample') 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. To see these shortcuts, you must open and view the Project shortcuts tab.
To set up the aircraft plant model and base controller, click the Getting Started button in the project shortcuts or run the setupPlant
helper function.
setupPlant;
Initialized VTOL model. Enabled hover configuration. Enabled hover guidance mission.
Set Up Mission with Unreal Visualization
To set up a guidance mission that is visualized in Unreal Engine environment, click Set up City Mission in the Project Shortcuts tab, or use the setupCityMission
helper function.
setupCityMission;
Initialized city mission.
Point Model to Unreal Engine Project
Open the Visualization
subsystem of the VTOLTiltrotor
model.
load_system("VTOLTiltrotor") open_system("VTOLTiltrotor/Visualization")
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
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
To launch Unreal Editor, click Open Unreal Editor in the Simulation 3D Scene Configuration block in the Photorealistic
subsystem.
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. Finally, 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 VTOLAsset
in the Content Browser pane to open the Asset Details window.
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.
To copy the reference path to this asset, right-click the VTOLAsset
skeletal mesh object in Content Browser pane and click Copy Reference.
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 Environment
Navigate to Maps in Content Browser and click on USCityBlock
to load the US City Block scene.
Run the VTOLTiltrotor.slx
simulink model. When Simulink sits at initializing
, click Play in Unreal Editor. To better visualize UAV, zoom out using mouse scroll.
Optionally, to change the simulation speed so that the simulation runs at real time for smoother visualization, enable Pacing in the Run > Simulation Pacing in Simulink.
Summary
In this example, you visualized a VTOL aircraft mission in 3D simulation environment. Next, learn how to customize the VTOL configuration and controller.
See Also
Design and Tune Controller for VTOL UAV | Simulation 3D Scene Configuration | Simulation 3D UAV Vehicle