Guidance model for fixed-wing UAVs
fixedwing 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 fixed-wing kinematic model for 3-D
For multirotor UAVs, see
model = fixedwing creates a fixed-wing motion model with
double precision values for inputs, outputs, and configuration parameters
of the guidance model.
model = fixedwing(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 behavior of the UAV. Specify the proportional (P) and derivative (D) gains for the dynamic model and other UAV parameters. The structure for fixed-wing UAVs contains these fields with defaults listed:
[min max]angle in radians)
ModelType — UAV guidance model type
This property is read-only.
UAV guidance model type, specified as
DataType — Input and output numeric data types
'double' (default) |
Input and output numeric data types, specified as either
'single'. Choose the data type based on possible software or
Simulate A Fixed-Wing Control Command
This example shows how to use the
fixedwing guidance model to simulate the change in state of a UAV due to a command input.
Create the fixed-wing guidance model.
model = fixedwing;
Set the air speed of the vehicle by modifying the structure from the
s = state(model); s(4) = 5; % 5 m/s
Specify a control command,
u, that maintains the air speed and gives a roll angle of
u = control(model); u.RollAngle = pi/12; u.AirSpeed = 5;
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 based on this simulation.
simOut = ode45(@(~,x)derivative(model,x,u,e), [0 50], s); size(simOut.y)
ans = 1×2 8 904
Plot the change in roll angle based on the simulation output. The roll angle is the 7th row of the
You can also plot the fixed-wing trajectory using
plotTransforms. Create the translation and rotation vectors from the simulated state. Downsample (every 30th element) and transpose the
simOut elements, and convert the Euler angles to quaternions. Specify the mesh as the
fixedwing.stl file and the positive Z-direction as
"down". The displayed view shows the UAV making a constant turn based on the constant roll angle.
downsample = 1:30:size(simOut.y,2); translations = simOut.y(1:3,downsample)'; % xyz-position rotations = eul2quat([simOut.y(5,downsample)',simOut.y(6,downsample)',simOut.y(7,downsample)']); % ZYX Euler plotTransforms(translations,rotations,... 'MeshFilePath','fixedwing.stl','InertialZDirection',"down") hold on plot3(simOut.y(1,:),-simOut.y(2,:),simOut.y(3,:),'--b') % full path xlim([-10.0 10.0]) ylim([-20.0 5.0]) zlim([-0.5 4.00]) view([-45 90]) hold off
UAV Coordinate Systems
The UAV 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].
UAV Fixed-Wing Guidance Model Equations
For fixed-wing UAVs, the following equations are used to define the
guidance model of the UAV. Use the
function to calculate the time-derivative of the UAV state using these governing equations.
Specify the inputs using the
The UAV position in the earth frame is [xe, ye, h] with orientation as heading angle, flight path angle, and roll angle, [χ, γ, ϕ] in radians.
The model assumes that the UAV is flying under a coordinated-turn condition, with zero side-slip. The autopilot controls airspeed, altitude, and roll angle. The corresponding equations of motion are:
Va and Vg denote the UAV air and ground speeds.
The wind speed is specified as
for the north, east, and down directions. To generate the structure for these inputs, use
k* are controller gains. To specify these gains,
Configuration property of the
From these governing equations, the model gives the following variables:
These variables match the output of the
 Randal W. Beard and Timothy W. McLain. "Chapter 9." Small Unmanned Aircraft Theory and Practice, NJ: Princeton University Press, 2012.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2018b