Guidance model for multirotor UAVs
multirotor object represents a reduced-order guidance model
for an unmanned aerial vehicle (UAV). The model approximates the behavior of a closed-loop
system consisting of an autopilot controller and a multirotor kinematic model for 3-D
This object requires you to install the UAV Library for Robotics System
Toolbox™. To install add-ons, use
roboticsAddons and select the desired add-on.
For fixed-wing UAVs, see
model = multirotor creates a multirotor motion model with
double precision values for inputs, outputs, and configuration parameters
of the guidance model.
model = multirotor(DataType) specifies the data type precision
DataType property) for the inputs, outputs, and configurations
parameters of the guidance model.
Name— Name of UAV
"Unnamed"(default) | string scalar
Name of the UAV, used to differentiate it from other models in the workspace, specified as a string scalar.
Configuration— UAV controller configuration
UAV controller configuration, specified as a structure of parameters. Specify these parameters to tune the internal control behaviour of the UAV. Specify the proportional (P) and derivative (D) gains for the dynamic model and other UAV parameters. For multirotor UAVs, the structure contains these fields with defaults listed:
0.1 (measured in kg)
ModelType— UAV guidance model type
This property is read-only.
UAV guidance model type, specified as
DataType— Input and output numeric data types
Input and output numeric data types, specified as either
'single'. Choose the data type based on possible software or
hardware limitations. Specify
DataType when first creating the
This example shows how to use the
multirotor guidance model to simulate the change in state of a UAV due to a command input.
Note: To use UAV algorithms, you must install the UAV Library for Robotics System Toolbox®. To install, use
Create the multirotor guidance model.
model = multirotor;
Create a state structure. Specify the location in world coordinates.
s = state(model); s(1:3) = [3;2;1];
Specify a control command,
u, that specified the roll and thrust of the multirotor.
u = control(model); u.Roll = pi/12; u.Thrust = 1;
Create a default environment without wind.
e = environment(model);
Compute the time derivative of the state given the current state, control command, and environment.
sdot = derivative(model,s,u,e);
Simulate the UAV state using
ode45 integration. The
y field outputs the fixed-wing UAV states as a 13-by-n matrix.
simOut = ode45(@(~,x)derivative(model,x,u,e), [0 3], s); size(simOut.y)
ans = 1×2 13 3536
Plot the change in roll angle based on the simulation output. The roll angle (the X Euler angle) is the 9th row of the
Plot the change in the Y and Z positions. With the specified thrust and roll angle, the multirotor should fly over and lose some altitude. A positive value for Z is expected as positive Z is down.
figure plot(simOut.y(2,:)); hold on plot(simOut.y(3,:)); legend('Y-position','Z-position') hold off
You can also plot the multirotor trajectory using
plotTransforms. Create the translation and rotation vectors from the simulated state. Downsample (every 300th element) and transpose the
simOut elements, and convert the Euler angles to quaternions. Specify the mesh as the
multirotor.stl file and the positive Z-direction as
"down". The displayed view shows the UAV translating in the Y-direction and losing altitude.
translations = simOut.y(1:3,1:300:end)'; % xyz position rotations = eul2quat(simOut.y(7:9,1:300:end)'); % ZYX Euler plotTransforms(translations,rotations,... 'MeshFilePath','multirotor.stl','InertialZDirection',"down") view([90.00 -0.60])
The UAV Library for Robotics System Toolbox uses the North-East-Down (NED) coordinate system convention, which is also sometimes called the local tangent plane (LTP). The UAV position vector consists of three numbers for position along the northern-axis, eastern-axis, and vertical position. The down element complies with the right-hand rule and results in negative values for altitude gain.
The ground plane, or earth frame (NE plane, D = 0), is assumed to be an inertial plane that is flat based on the operation region for small UAV control. The earth frame coordinates are [xe,ye,ze]. The body frame of the UAV is attached to the center of mass with coordinates [xb,yb,zb]. xb is the preferred forward direction of the UAV, and zb is perpendicular to the plane that points downwards when the UAV travels during perfect horizontal flight.
The orientation of the UAV (body frame) is specified in ZYX Euler angles. To convert from the earth frame to the body frame, we first rotate about the ze-axis by the yaw angle, ψ. Then, rotate about the intermediate y-axis by the pitch angle, ϕ. Then, rotate about the intermediate x-axis by the roll angle, ϴ.
The angular velocity of the UAV is represented by [p,q,r] with respect to the body axes, [xb,yb,zb].
For multirotors, the following equations are used to define the guidance
model of the UAV. To calculate the time-derivative of the UAV state using these governing
equations, use the
function. Specify the inputs using
The UAV position in the earth frame is [xe, ye, ze] with orientation as ZYX Euler angles, [ψ, ϴ, ϕ] in radians. Angular velocities are [p, q, r] in radians per second.
The UAV body frame uses coordinates as [xb, yb, zb].
When converting coordinates from the world (earth) frame to the body frame of the UAV, the rotation matrix is:
The cos(x) and sin(x) are abbreviated as cx and sx.
The acceleration of the UAV center of mass in earth coordinates is governed by:
m is the UAV mass, g is gravity, and Fthrust is the total force created by the propellers applied to the multirotor along the –zb axis (points upwards in a horizontal pose).
The closed-loop roll-pitch attitude controller is approximated by the behavior of 2 independent PD controllers for the two rotation angles, and 2 independent P controllers for the yaw rate and thrust. The angular velocity, angular acceleration, and thrust are governed by:
This model assumes the autopilot takes in commanded roll, pitch, yaw angles,
ϕc] and a commanded total thrust
force, Fcthrust. The
structure to specify these inputs is generated from
The P and D gains for the control inputs are specified as
KDα, where α is either
the rotation angle or thrust. These gains along with the UAV mass, m, are
specified in the
Configuration property of the
From these governing equations, the model gives the following variables:
These variables match the output of the
 Mellinger, Daniel, and Nathan Michael. "Trajectory Generation and Control for Precise Aggressive Maneuvers with Quadrotors." The International Journal of Robotics Research. 2012, pp. 664-74.