主要内容

Simulation 3D UAV Vehicle

R2026b

Simulate UAV in 3D environment using Unreal Engine

  • Simulation 3D UAV Vehicle block for 3D UAV simulation in Simulink

Libraries:
UAV Toolbox / Simulation 3D

Description

Note

Simulating models with the Simulation 3D UAV Vehicle block requires Simulink® 3D Animation™.

The Simulation 3D UAV Vehicle block simulates an unmanned aerial vehicle (UAV) in a 3D environment rendered using the Unreal Engine® from Epic Games®. The block supports quadcopter, fixed-wing, and custom UAV types. The block uses the input (X, Y, Z) position and input (yaw, pitch, roll) attitude of the UAV in the simulation.

To use this block:

  • Add a Simulation 3D Scene Configuration block to your model.

  • Connect the Translation and Rotation input ports.

  • Set the block priority to -1 (right-click the block, select Properties, then on the General tab set Priority) so that it executes before the Simulation 3D Scene Configuration block (priority 0).

  • Set Sample time to -1 to inherit the sample time from the Simulation 3D Scene Configuration block.

For more information about execution order, see Block Execution Order.

Examples

expand all

Open the tiltRotorUAVModel.slx Simulink® model.

open_system("tiltRotorUAVModel")

Simulink model with Simulation 3D Custom UAV Pack block accepting body translation, rotation, motor tilt, and rotor RPM inputs connected to Simulation 3D UAV Vehicle and Scene Configuration blocks

This model uses the Simulation 3D UAV Vehicle block to simulate a custom Hexarotor UAV in 3D environment. The Type parameter is specified to Custom, and the Path to custom mesh is specified to /MathWorksUAVContent/UAVs/HexaRotorUAV/HexaRotor.HexaRotor.

Simulation 3D UAV Vehicle block mask showing the Type and Path to custom mesh parameter.

This model uses the Simulation 3D Custom UAV Pack block to generate the translation and rotation inputs. The block is configured to accept the body translation, body rotation, tilt angles for motors 1 to 6, and angular velocities of rotors 1 to 6.

Simulation 3D Custom UAV Pack block parameters with Motors 1-6 Tilt and Rotors 1-6 RPM enabled on the Propulsion tab

The Hexarotor custom mesh is configured with the bone hierarchy that is shown in the following image. For more details on how to configure custom UAV mesh for simulation in Unreal Engine, visit Prepare Custom UAV Vehicle Mesh for Unreal Engine Scenario Simulation.

Hexarotor UAV mesh bone hierarchy. Starting from front left of the UAV and moving counter clockwise when viewed from the top of UAV, is motor rotor pair 1 to 6.

In this example, the Hexarotor UAV is configured with the following input:

  • UAV_Body rotation angle — 0 radian of roll, pitch, and yaw angles.

  • UAV_Motor1 tilt angle — 0 radian.

  • UAV_Rotor1 angular velocity — 250 RPM, clockwise.

  • UAV_Motor2 tilt angle — pi/2 radian, oscillating at a rate of 1 rad/s.

  • UAV_Rotor2 angular velocity — 60 RPM, clockwise.

  • UAV_Motor3 tilt angle — 0 radian.

  • UAV_Rotor3 angular velocity — 250 RPM, counter-clockwise.

  • UAV_Motor4 tilt angle — 0 radian.

  • UAV_Rotor4 angular velocity — 250 RPM, counter-clockwise.

  • UAV_Motor5 tilt angle — pi/2 radian, oscillating at a rate of 1 rad/s.

  • UAV_Rotor5 angular velocity — 60 RPM, counter-clockwise.

  • UAV_Motor6 tilt angle — 0 radian.

  • UAV_Rotor6 angular velocity — 250 RPM, clockwise.

Run the tiltRotorUAVModel.slx Simulink model to start the simulation.

Hexarotor UAV simulation in 3D environment with tilting motors and spinning rotors

You can also run this example with an Octarotor UAV mesh by specifying the Path to custom mesh parameter of the Simulation 3D UAV Vehicle block as /MathWorksUAVContent/UAVs/OctaRotorUAV/OctaRotor.OctaRotor and running the model again.

Octarotor UAV simulation in 3D environment with tilting motors and spinning rotors

Extended Examples

Ports

Input

expand all

Translated position of the UAV, specified as a 1-by-3 vector

If Use geospatial coordinates for inputs and initial values parameter is disabled, specify the input as the X-, Y-, and Z-positions of the UAV in the Unreal Engine world coordinate frame. Units are in meters.

If Use geospatial coordinates for inputs and initial values is enabled, specify the input as the latitude, longitude, and altitude of the UAV in meters. The block places the UAV in Unreal Engine by evaluating the translation relative to the GeoOrigin that you specified.

For more information on the coordinate systems, see Coordinate Systems for Unreal Engine Simulation in UAV Toolbox.

Data Types: double

Rotation of the UAV, specified as a 1-by-3 vector or a 17-by-3 matrix. You can specify this input as a 1-by-3 vector for any value of the Type parameter, but if Type is Custom, you can alternatively specify Rotation as a 17-by-3 matrix.

  • 1-by-3 vector

    Contains the yaw, pitch, and roll angles of the UAV body, in radians. The UAV rotors rotate at a fixed angular velocity of 250 RPM (1500 deg/sec).

  • 17-by-3 matrix

    Tip

    Use the Simulation 3D Custom UAV Pack block to generate translation and rotation inputs for Custom UAV type with custom motor tilt angle and rotor angular velocity.

    For Custom type, row 1 specifies the yaw, pitch, and roll of the UAV body. Rows 2, 4, 6, 8, 10, 12, 14, and 16 specify the rotation angles for motors 1 through 8. Rows 3, 5, 7, 9, 11, 13, 15, and 17 specify the angular velocities for rotors 1 through 8. For motor-rotor pairs not used, set the corresponding rows to zero.

    This table summarizes the rows of the rotation matrix.

    • Each angular velocity row contains the angular velocities around the X-, Y-, and Z- axes of the corresponding UAV_RotorN mesh that you set up when exporting the mesh to Unreal Engine. Units are in revolutions per minute (RPM). The angular velocity sign convention follows the right-hand rule about each axis.

    • Each rotation angles row contains the yaw, pitch, and roll angles of the corresponding UAV mesh part, in radians.

    Matrix RowUAV Mesh Part
    1UAV_Body rotation angles
    2UAV_Motor1 rotation angles
    3UAV_Rotor1 angular velocities
    4UAV_Motor2 rotation angles
    5UAV_Rotor2 angular velocities
    6UAV_Motor3 rotation angles
    7UAV_Rotor3 angular velocities
    8UAV_Motor4 rotation angles
    9UAV_Rotor4 angular velocities
    10UAV_Motor5 rotation angles
    11UAV_Rotor5 angular velocities
    12UAV_Motor6 rotation angles
    13UAV_Rotor6 angular velocities
    14UAV_Motor7 rotation angles
    15UAV_Rotor7 angular velocities
    16UAV_Motor8 rotation angles
    17UAV_Rotor8 angular velocities

If you clear the Use geospatial coordinates for inputs and initial values parameter, the UAV body rotation angles are relative to the Unreal Engine world coordinate frame.

If you select the Use geospatial coordinates for inputs and initial values parameter, the UAV body rotation angles are relative to the local East-North-Up (ENU) frame at the current position of the UAV.

For more information on the coordinate systems, see Coordinate Systems for Unreal Engine Simulation in UAV Toolbox.

Data Types: double

Geospatial coordinates assigned to the origin point (0, 0, 0) of the Unreal Engine world coordinate frame, specified in the form [latitude longitude altitude]. Use this port to align the 3D simulation world with a real-world geographic location. latitude and longitude are in degrees, and altitude is in meters.

Dependencies

To enable this port, select the Use geospatial coordinates for inputs and initial values parameter.

Data Types: double

Parameters

expand all

Vehicle Parameters

Select the type of vehicle. To obtain the dimensions of each vehicle type, see these reference pages:

Reference path to the custom UAV mesh asset in your Unreal Engine project, specified as a character vector. The path must point to a static mesh asset in the Unreal Engine content browser. Add the mesh asset to the Unreal Engine project before running the simulation.

For steps to create and register a custom mesh asset, see Prepare Custom UAV Vehicle Mesh for Unreal Engine Scenario Simulation. For an example of how to obtain this path from the Unreal® editor, see Visualize VTOL UAV Mission over Urban Environment.

Dependencies

To enable this parameter, set the Type parameter to Custom.

Select the visual color of the UAV mesh in the 3D scene. This parameter affects only the appearance of the vehicle and does not affect sensor outputs or simulation results.

Dependencies

To enable this parameter, set the Type parameter to Quadcopter or Fixed wing.

Name of vehicle. By default, when you use the block in your model, the block sets the Name parameter to SimulinkVehicleX. The value of X depends on the number of Simulation 3D UAV Vehicle blocks that you have in your model.

The vehicle name appears as a selection in the Parent name parameter of any UAV Toolbox Simulation 3D sensor blocks in the same model as the vehicle. With the Parent name parameter, you can select the vehicle on which to mount the sensor.

Select this parameter to use geospatial coordinates for port inputs and initial values. When enabled:

  • The Translation input accepts [latitude, longitude, altitude] instead of [X, Y, Z].

  • The GeoOrigin input port becomes active and accepts the [latitude, longitude, altitude] of the Unreal Engine world origin.

  • Set Initial Georeference Origin (LLA) to match the geographic location of your simulation scene.

The block places the UAV relative to the GeoOrigin position.

Initial Values

Specify the initial position of your vehicle in one of these forms:

  • [X Y Z] when you clear the Use geospatial coordinates for inputs and initial values parameter. X, Y, and Z are the translation along the X-axis, Y-axis, and Z-axis, respectively, in the inertial Z-down coordinate system, in meters.

  • [latitude longitude altitude] when you enable the Use geospatial coordinates for inputs and initial values parameter. You must specify latitude and longitude in degrees, and altitude in meters.

Specify the initial georeference origin in the form [latitude longitude altitude]. You must specify latitude and longitude in degrees, and altitude in meters.

Dependencies

To enable this parameter, select the Use geospatial coordinates for inputs and initial values parameter.

Initial rotation of the UAV. The dimensions of this parameter depend on the value of the Type parameter. You can specify this parameter as a 1-by-3 vector for any value of the Type parameter, but if Type is Custom, you can alternatively specify this parameter as a 17-by-3 matrix.

See the Rotation input for details on specifying this value.

Sample Time

Sample time, Ts, specified as a positive scalar in seconds. The graphics frame rate is the inverse of the sample time.

If you set the sample time to -1, the block uses the sample time specified in the Simulation 3D Scene Configuration block.

Version History

Introduced in R2020b

expand all