Fuzzy Logic Control for Quadrotor Stability
Fuzzy Logic Control for Quadrotor Stability
http://www.imavs.org/pdf/imav.2019.22
crease/decrease their rotation speed to increase/reduce the Given both the dynamics and kinematics, the system
generated thrust, resulting a change in altitude. To change equations can be arranged to form the state-space vector
the roll angle, the pairs of motors 1 and 2 increase/decrease x = [ẋ ẏ ż φ̇ θ̇ ψ̇ ]T ∈ R6 . Taking into con-
the rotation in comparison to the pair 3 and 4, generating a sideration the simplification for small angles of movement,
disbalanced thrust, and therefore changing the roll angle. To [φ̇ θ̇ ψ̇]T = [p q r]T [4], where p, q and r make up the
change the pitch angle, the process is analogous to the roll vector ωB , the state-space equations are described in Equa-
angle, however the pair of motors that changes the rotation tion 3.
speed are 1 and 4 or 2 and 3. On the other hand, to change
the yaw angle, the pair of motors 1 and 3 changes its rotation
in comparison to motors 2 and 4, increasing or decreasing the
fBz
resultant torque applied to the vehicle.
ẍ = −(sin ψ sin φ + cos ψ sin θ cos φ)
m
2 Q UADROTOR M ODELLING
fBz
The quadrotor dynamic movements described in Section
ÿ = −(− cos ψ sin φ + sin ψ sin θ cos φ)
m
3 are modelled based on Newton-Euler equations for 3D mo-
tion of rigid bodies and described in [3] and shown in Equa-
fBz
tion 1, where m is the drone‘s mass, I is a diagonal matrix
z̈ = (g − cos θ cos φ)
m
with the drones inertia parameters around the x, y and z axis
(3)
( Ixx , Iyy , Izz ), vB is the vector with the drones velocity in
Iyy − Izz mBx
the body-fixed reference system, ωB is the vector with the
φ̈ = θ̇ψ̇ +
I Ixx
drones angular velocity in the body-fixed reference system
xx
and fB and mB are the vectors with the external forces and
Izz − Ixx mBy
moments, respectively, applied to the drone.
θ̈ = φ̇ψ̇ +
I Iyy
yy
m(v˙B + ωB ∧ vB ) = fB
(1) ψ̈ = Ixx − Iyy φ̇θ̇ + mBz
Izz Izz
I ω˙B + ωB ∧ (IωB ) = mB
The forces and moments generated by the rotation of the 3 T YPICAL C ONTROL S TATEGY
motors are described as in Equation 2 where l is the distance
between the propeller and the vehicle CoG (center of gravity), The quadrotors stability is achieved by using a closed
b is the thrust coefficient of the motor-propeller setup, d is the loop control system, based on feedback from inertial mea-
aerodynamic drag coefficient, the Ωn represent the rotation surements. Typically, UAVs have an embedded 9DOF IMU
speed of the n-th motor, fBx , fBy and fBz make up the fB (9 Degrees of Freedom Inertial Measurement System), with
vector and mBx , mBy and mBz make up the mB vector, both three-axis accelerometers, three-axis gyroscopes and three-
from Equation 1. axis magnetometers that provide the attitude angles used to
control its stability.
Since attitude estimation requires numerical integration
fBx = −mg sin θ
based on measured angular velocities, the systems are sub-
jected to cumulative errors due to noisy measurements.
fBy = mg cos θ sin φ
Therefore, control systems include fusion filters that merges
data from multiple sensors, such as linear complimentary fil-
2 2 2 2 ters and Extended Kalman Filters [2].
fBz = mg cos θ cos φ + b(Ω1 + Ω2 + Ω3 + Ω4 )
(2) Nested PID controllers are the most widely used strategy
√ for stability control of rotating wing UAVs. They actuate on
mBx = 22 lb(Ω21 + Ω22 − Ω23 − Ω24 ) the desired moments of the vehicle, based on feedback from
the sensors and attitude commands. The attitude commands
√
2 2 2 2 2 can be given directly by the pilot or be provided by an au-
mBy = 2 lb(Ω1 − Ω2 − Ω3 + Ω4 )
tonomous trajectory control algorithm, that relies on other
ways to measure the vehicle position (i.e GPS) and provide
mBz = d(−Ω21 + Ω22 − Ω23 + Ω24 )
the specific attitude commands for the desired trajectory.
The system kinematics is modelled using a ZYX Euler Since this paper is not focused on trajectory control, but
Rotation from the body fixed reference system to the inertial on stability and altitude control, it will be based on the case
reference system. of a manual flight mode,as highlighted in red in Figure 2.
4 F UZZY C ONTROL
A fuzzy control system consists of 4 basic elements,
shown in Figure 5. First, the fuzzification module, that is
responsible for converting specific input values to fuzzy sets.
The knowledge base is composed by the rules that define the
control strategy for the system, which are usually extracted
from a specialist. The inference system process the fuzzified
inputs according to the rules from the knowledge base to infer
the actions of the fuzzy controller. Finally, the defuzzification
module converts the fuzzy sets, generated by the inference
system, back to exact values that are used in the control pro-
cess [5].
N Z P
Degree of Membership
1
0.8
0.6
0.4
0.2
Figure 7: Nested Fuzzy-PID for Yaw Control -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5
Derivative of Z Error (m/s)
5 I MPLEMENTATION
The model was implemented in Simulink/Matlab, using The output for the altitude controller was divided in 5
the Simscape toolbox. The parameters used for the drone membership functions: Down Big (DB), Down (D), Maintain
were extracted from the Crazyflie 2.0 Nano drone, a small (M), Up (U) and Up Big (UB).
quadrotor with open source software that allows the user to
personalize its firmware and implement different control ap-
proaches. Therefore, developing the fuzzy control for this DB D M U UP
Degree of Membership
1
drone is a first step to implement it in a real setup.
0.8
and the PID gains, used during the initial simulations, were 0.4
sualization of the vehicles movements. -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Rover Output
Fuzzy membership functions and rules were implemented
by using the Fuzzy Logic Design toolbox, that provides visual Figure 10: Output Membership Function - Rover
interfaces for easy tuning of the parameters.
Sections 5.1, 5.2 and 5.3 shows the tuned membership
functions and rules for the controllers developed. For all Table 1 show the set of rules used in the knowledge base
controllers, the centroid was used as defuzzification method of the fuzzy inference system for the altitude controller.
while minimum was used as implication method.
XX
XXX Error
X NB N Z P PB
5.1 Altitude Hold Derivative XXXX
N DB D D M U
The error in altitude input was divided in 5 membership Z DB D M U UB
functions: Negative Big (NB), Negative (N), Zero (Z), Pos- P D M U UB UB
itive (P) and Positive Big (PB). Its derivative was divided in
3 membership functions: Negative (N), Zero (Z) and Posi- Table 1: Fuzzy Rules for Altitude Control
tive(P)
1
Since the model being used is symmetrically in the x and
y direction, the roll and pitch movements presents the same
0.8
0.6
dynamic. Therefore, the same controller was capable of con-
0.4
trolling both angles.
0.2
The error in the roll and pitch angle input was divided in
0
NB N Z P PB
5.3 Yaw Angle
Degree of Membership
0.8 The error in the yaw angle input was divided in 5 member-
0.6
ship functions: Negative Big (NB), Negative (N), Zero (Z),
0.4
Positive (P) and Positive Big (PB). Its derivative was divided
0.2
in 3 membership functions: Negative (N), Zero (Z) and Posi-
tive(P)
0
Degree of Membership
1
Figure 11: Input Membership Function - Roll/Pitch Error
0.8
0.6
0.4
0.2
N Z P
Degree of Membership
1
0
0.8 -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5
Yaw Error (rad)
0.6
0.4
Figure 14: Input Membership Function - Yaw Error
0.2
-0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5
Derivative of Roll/Pitch Error (rad/s)
N Z P
Degree of Membership
0.6
0.4
The output for the roll/pitch derivative reference was di- 0.2
tive (N), Zero (Z), Positive (P) and Positive Big (PB). -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5
Derivative of Yaw Error (rad/s)
NB N Z P PB
Figure 15: Input Membership Function - Derivative of Yaw
Degree of Membership
1
Error
0.8
0.6
0.4 The output for the yaw derivative reference was divided
0.2 in 5 membership functions: Negative Big (NB), Negative (N),
0 Zero (Z), Positive (P) and Positive Big (PB).
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
dRollRef/dPitchRef (rad/s)
0.6
0.4
Table 2 shows the set of rules used in the knowledge base 0.2
of the fuzzy inference system for the roll and pitch controller. 0
-10 -8 -6 -4 -2 0 2 4 6 8 10
XXX
XXX Error NB N Z P PB
Pitch Angle
Derivative XXXX Reference
N NB NB N Z P 0.2 Fuzzy
PID
Z NB N Z P PB
Angle(rad)
P N Z P PB PB 0
0 5 10 15 20 25 30
Time(s)
6 R ESULTS
Figure 19: Pitch Angle Control
After completing the tuning for the Fuzzy membership
functions and rules, simulations were performed by giving
reference values for the 4 variables simultaneously. The val- Yaw Angle
2
ues given for reference were selected considering reasonable Reference
maneuvers for a quadcopter. Figures 17, 18, 19 and 20 shows 1
Fuzzy
PID
the results obtained.
Angle(rad)
0
To provide a benchmark to evaluate the performance of
the designed fuzzy controller, simulations were performed
-1
using the traditional PID controller with gains set accord-
ing to the standard values that come out-of-the-box with the -2
Crazyflie 2.0 Nano. 0 5 10 15 20 25 30
Time(s)