Multi-Instance Guidance Model

Libraries:
UAV Toolbox /
Algorithms
Description
Examples
Open the reducedOrderMultiUAVModel.slx
Simulink® model. The model uses the Multi-Instance Guidance Model block to simulate multiple UAVs with reduced order fixed-wing kinematic models, and a UAV Animation block to visualize the result.
open_system("reducedOrderMultiUAVModel")
Initial Condition of UAV
This model simulates the flight of four UAVs. Each UAV starts the simulation in the same position, air speed, heading angle, roll angle, and roll angle velocity. However, each UAV have different initial heights:
UAV 1 — 50 meters
UAV 2 — 60 meters
UAV 3 — 70 meters
UAV 4 — 80 meters
The initial condition is specified in the Initial State parameter of the Multi-Instance Guidance Model block.
Configuration of UAV
UAV 1, UAV 2, and UAV 3 are configured with default controller configuration. UAV 4 is confiigured with a proportional gain of the height controller of 1
, and a proportional gain of the flight path angle controller of 1
. This configuration is specified in the Configuration parameter of the Multi-Instance Guidance Model block.
Control Input
This model uses the Bus Creator block to create the control input bus. The bus name is specified in accordance with the Control Bus Name parameter of the Multi-Instance Guidance Model block.
The bus contains these elements:
Height
— Sets UAV 1, 2, 3, and 4 to have heights of 50, 60, 70, and 100 meters, respectively.AirSpeed
— Sets all UAV to have an air speed of 20 m/s.RollAngle
— Sets UAV 1, 2, 3, and 4 to have roll angles of -0.3, 0, 0.3, and 0 radians, respectively.
Environment Input
This model uses the Bus Creator block to create the environment input bus. The bus name is specified in accordance with the Environment Bus Name parameter of the Multi-Instance Guidance Model block.
The bus contains the following elements:
WindNorth
— Sets all UAV to have north wind velocites of 0 m/s.WindEast
— Sets all UAV to have east wind velocites of 0 m/s.WindDown
— Sets all UAV to have down wind velocites of 0 m/s.Gravity
— Sets all UAV to have a gravitational accelerations of 9.8 m/s2.
Visualizing State Output
Before visualizing the state output, the model performs these operations on the elements of the bus output by the Multi-Instance Guidance Model block.
Multiplies the
<Height>
signal by a gain of –1 to match the z-axis direction of the UAV Animation block. The model then combine the height signal with<North>
and<East>
signals into a matrix. The model transposes the matrix so that each row contains the translation of each UAV, and connects the matrix to the Translation port of the UAV Animation block.Combines the
<HeadingAngle>
,<FlightPathAngle>
, and<RollAngle>
signals into a matrix. The model transposes the matrix so that each row contains the rotation angle of each UAV, and connects the matrix to the Rotation port of the UAV Animation block.The vector specified to the UAV Type input of the UAV Animation block indicates that all three UAVs are fixed-wing, while the UAV Mesh Configuration input sets the colors of UAVs 1, 2, 3, and 4 to red, green,blue, and black, respectively.
Run the Simulink model, and observe the simulation result from the UAV Animation window.
Ports
Input
Control input for UAVs, specified as a bus. Specify each element of the bus as a 1-by-N vector, where N is the number of UAVs that you want to simulate.
If you set the Model Type property to
MultirotorGuidance
, you must specify a bus with these elements:
Roll
— Roll angle of each UAV in radians.Pitch
— Pitch angle of each UAV in radians.YawRate
— Yaw rate of each UAV in radians per second.Thrust
— Vertical thrust of each UAV in Newtons.
If you set the Model Type property to
FixedWingGuidance
, you must specify a bus with these elements:
Height
— Height of each UAV above the ground in meters.Airspeed
— Airspeed of each UAV in meters per second.RollAngle
— Roll angle of each UAV in radians.
Specify the name of the control input bus by using the Control Bus Name property.
Environment inputs, specified as a bus. Specify each element of the bus as a 1-by-N vector, where N is the number of UAVs that you want to simulate.
If you set the Model Type property to
MultirotorGuidance
, you must specify a bus with
Gravity
element which contains the gravitational acceleration for
each UAV in the z-axis direction of the inertial frame in meters per second
squared.
If you set the Model Type property to
FixedWingGuidance
, you must specify a bus with these elements:
WindNorth
— Wind velocity in the north direction for each UAV in meters per second.WindEast
— Wind velocity in the east direction for each UAV in meters per second.WindDown
— Wind velocity in the downward direction for each UAV in meters per second.Gravity
— Gravitational acceleration for each UAV in the z-axis direction of the inertial frame in meters per second squared.
Specify the name of the environment input bus by using the Environment Bus Name property.
Data Types: bus
Output
Simulated UAV state, returned as a bus. Each element in the bus is a matrix or vector with N columns, where N is the number of UAV that you simulate.
If you set the Model Type property to
MultirotorGuidance
, the block returns the state output as an
eight-element bus with these elements:
<WorldPosition>
— 3-by-N matrix of UAV positions. Each column of the matrix contains the xyz-position of a UAV in meters.<WorldVelocity>
— 3-by-N matrix of UAV velocities. Each column of the matrix contains the xyz-velocity of a UAV in meters per second.<EulerZYX>
— 3-by-N matrix of UAV Euler angles. Each column of the matrix contains the Euler angles of a UAV in z-,y-,x-axis (yaw-pitch-roll) rotation sequence.<BodyAngularRateRPY>
— 3-by-N matrix of UAV angular rates. Each column of the matrix contains the angular rate of a UAV with respect to the x-,y-, and z- axes (roll rate, pitch rate, and yaw rate, respectively) in radians per second.<Thrust>
— 1-by-N vector of UAV thrusts. Each element of the vector contains the thrust of a UAV in newtons.
If you set the Model Type property to
FixedWingGuidance
, the block returns the state output as a bus
with eight elements, where each element is a 1-by-N vector. The bus
contains these elements:
<North>
— Position in the north direction for each UAV in meters.<East>
— Position int he east direction for each UAV in meters.<Height>
— Height above the ground for each UAV in meters.<AirSpeed>
— Speed relative to the wind for each UAV in meters per second.<HeadingAngle>
— Angle between the ground velocity and north direction for each UAV in radians.<FlightPathAngle>
— Angle between the ground velocity and north-east plane for each UAV in radians.<RollAngle>
— Angle of rotation along the body x-axis for each UAV in radians per second.<RollAngleRate>
— Angular velocity of rotation along the body x-axis for each UAV in radians per second.
Specify the name of the state output bus by using the State Bus Name property.
Data Types: bus
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Guidance model type for all UAVs. Select MultirotorGuidance
to
simulate multirotor UAVs or FixedWingGuidance
to simulate fixed wing
UAVs.
Specify the number of UAVs to simulate as a positive integer.
Specify the input and output numeric data types as double
or
single
.
Code generation
— Simulate model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time, but the speed of the subsequent simulations is comparable toInterpreted execution
.Interpreted execution
— Simulate model using the MATLAB® interpreter. This option shortens startup time but has a slower simulation speed thanCode generation
. In this mode, you can debug the source code of the block.
Initial UAV state tab, specified as multiple table entries. In all initial state descriptions, N is the number of UAVs that you are simulating.
For multirotor UAVs, you must specify these initial states:
World Position — 3-by-N matrix. Specify each column of the matrix as the initial xyz-position of a UAV in meters. The default value for each UAV is
[0;0;0]
.World Velocity — 3-by-N. Specify each column of the matrix as the initial xyz-velocity of a UAV in meters per second. The default value for each UAV is
[0;0;0]
.Euler Angles (ZYX) — 3-by-N matrix. Specify each column of the matrix with the initial Euler angles of a UAV in z-,y-,x-axis (yaw-pitch-roll) rotation sequence. The default value for each UAV is
[0;0;0]
.Body Angular Rates — 3-by-N matrix. Specify each column of the matrix as the initial angular rate of a UAV with respect to the x-,y-, and z-axes (roll rate, pitch rate, and yaw rate, respectively) in radians per second. The default value for each UAV is
[0;0;0]
.Thrust — 1-by-N vector. Specify each element of the vector as the initial thrust of a UAV in newtons. The default value for each UAV is
0
.
For fixed-wing UAVs, you must specify these initial states as 1-by-N vectors:
North Position — Initial position in the north direction for each UAV in meters. The default value for each UAV is
0
.East Position — Initial position in the east direction for each UAV in meters. The default value for each UAV is
0
.Height — Initial height above the ground each for each UAV in meters. The default value for each UAV is
0
.Air Speed — Initial speed relative to the wind for each UAV in meters per second. The default value for each UAV is
0
.Heading Angle — Initial angle between the ground velocity and north direction for each UAV in radians. The default value for each UAV is
0
.Flight Path Angle — Initial angle between the ground velocity and north-east plane for each UAV in radians. The default value for each UAV is
0
.Roll Angle — Initial angle of rotation along the body x-axis for each UAV in radians per second. The default value for each UAV is
0
.Roll Angle Rate — Initial angular velocity of rotation along the body x-axis for each UAV in radians per second. The default value for each UAV is
0
.
Tunable: No
UAV controller configuration tab, specified as multiple table entries. In all controller configuration descriptions, N is the number of UAVs that you are simulating.
For multirotor UAVs, specify these parameters:
PD Roll — N-by-2 matrix. Specify each row of the matrix as the proportional and derivative gains of the roll angle controller for a UAV. The default value for each UAV is
[3402.97 116.67]
.PD Pitch — N-by-2 matrix. Specify each row of the matrix as the proportional and derivative gains of the pitch angle controller for a UAV. The default value for each UAV is
[3402.97 116.67]
.P YawRate — N-by-1 vector. Specify each element of the vector as the proportional gain of the yaw rate controller for a UAV. The default value for each UAV is
1950
.P Thrust — N-by-1 vector. Specify each row of the vector as the proportional gain of the thrust controller for a UAV. The default value for each UAV is
3900
.Mass — N-by-1 vector. Specify each element of the vector as the mass of a UAV in Kg. The default value for each UAV is
0.1
.
For fixed-wing UAVs, specify these parameters:
P Height — N-by-1 vector. Specify each element of the vector as the proportional gain of the height controller for a UAV. The default value for each UAV is
3.9
.P Flight Path Angle — N-by-1 vector. Specify each element of the vector as the proportional gain of the flight path angle controller for a UAV. The default value for each UAV is
39
.PD Roll — N-by-2 matrix. Specify each element of the matrix as the proportional and derivative gains of the pitch angle controller for a UAV. The default value for each UAV is
[3402.97 116.67]
.P Air Speed — N-by-1 vector. Specify each element of the vector as the proportional gain of the air speed controller for a UAV. The default value for each UAV is
1
.Min/Max Flight Path Angle — N-by-2 matrix. Specify each element of the matrix as the minimum and maximum flight path angle for a UAV in radians. The default value for each UAV is
[-pi/2 pi/2]
This tab contains the State Bus Name, Control Bus Name, and Environment Bus Name parameters, which specify the name of the output state bus, the input control bus, and the input environment bus, respectively. Each bus has a default name based on the UAV model and input type.
Model Type Parameter | Default State Bus Name | Default Control Bus Name | Default Environment Bus Name |
---|---|---|---|
FixedWingGuidance | FixedWingGuidanceStateBus | FixedWingGuidanceControlBus | FixedWingGuidanceEnvironmentBus |
MultirotorGuidance | MultirotorGuidanceStateBus | MultirotorGuidanceControlBus | MultirotorGuidanceEnvironmentBus |
To use multiple guidance models in the same Simulink model, specify bus names for each Multi-Instance Guidance Model block that do not intersect with one another.
More About
For fixed-wing UAVs, these equations define the guidance model of the UAV:
These equations result in these state variables:
where:
xe, ye, and h are the north position, east position, and height of the UAV in the inertial frame, respectively
χ, γ, and ϕ are the course angle, flight path angle, and roll angle of the UAV, respectively.
Va and Vg are the air and ground speeds of the UAV.
Vwn, Vwe, and Vwdare the wind speeds of the UAV in the north, east, and down directions, respectively.
kP* and kD*are controller proportional and derivative gains of the UAV, respectively.
C is the control input.
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.
These equations define the guidance model for multirotor UAVs.
The model governs the acceleration of the UAV center of mass in inertial coordinates as:
where:
xe, ye, andhare the north position, east position, and height of the UAV in the inertial frame, respectively
m and g are the mass and gravitational acceleration of the UAV, respectively
Fthrust is the total force created by the propellers applied to the multirotor along the –zb axis.
Reb is the rotation matrix that rotates the inertial frame to the body frame:
where ψ, ϴ, and ϕare the yaw, pitch, and roll angles, respectively. c and s are abbreviations for cos and sin, respectively.
The model uses two independent proportional-derivative (PD) controllers to control the roll and pitch angles, and two independent proportional (P) controllers to control the yaw rate and thrust.
These equations determine the angular velocity, angular acceleration, and thrust:
where:
ψ, ϴ, and ϕ are the yaw, pitch, and roll angles, respectively
p,q, and r are the angular rotation with respect to xb,yb, and zb, respectively.
kP* and kD*are the proportional and derivative gains of the controller, respectively.
c is the control input
Fthrust is the thrust of the UAV
These equations result in these state variables:
References
[1] Beard, Randal W., and Timothy W. McLain. “Design Models for Guidance.” In Small Unmanned Aircraft: Theory and Practice, 175–87. Princeton, NJ: Princeton University Press, 2012
[2] Mellinger, Daniel, Nathan Michael, and Vijay Kumar. “Trajectory Generation and Control for Precise Aggressive Maneuvers with Quadrotors.” The International Journal of Robotics Research 31, no. 5 (April 2012): 664–74. https://doi.org/10.1177/0278364911434236.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2025a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)