1. Introduction
In recent years, multirotor UAVs (commonly known as drones) have become popular and widely used. Compared to traditional helicopters, drones have a simper mechanical structure, which is easier to control [
1]. As a result, drones are widely used for aerial filming. They have potential applications in search and rescue operations, environment monitoring, law enforcement, precision agriculture, traffic management, delivery, etc.
The most commonly used drones are quadcopters or quadrotor helicopters. Drones with more rotors, however, have a higher thrust-to-weight ratio and a greater load capacity but generally, higher energy consumption. However, a drone with more rotors, such as a hexacopter, can consume lower energy under certain mass distribution conditions than a quadrotor with the same material and the same motor, as demonstrated in Sun’s research [
2]. This study investigates the enhancement of the potential of a hexacopter through the development of an optimised sliding mode control (SMC) model. Although more research has focussed on quadrotors, the core of the flight control structure is similar for both quadrotors and hexacopters.
In order to meet the requirements of remote control and the autonomous flight of a drone, designing a flight controller is a critical task. The study of control usually starts from the PID control theory. The traditional PID control approach can partially meet these requirements. Salih et al. applied the PID control approach for the remote control of a quadcopter. The results show that the controller responds quickly. However, there are obvious oscillations and overshoots [
3]. Mustapa et al. applied PID control for the altitude controller of a quadcopter. Altitude control is a relatively simple part of a drone flight controller, which can be addressed by the classic PID approach [
4].
Agha [
5] and Abidali [
6] each studied the PID controller as a baseline controller for solar-powered drones and used other approaches to improve the performance. Bouabdallah’s early work on quadrotor flight control was mainly focused on the backstepping control approach, which was validated in experiments [
7]. Bouabdallah also studied the sliding mode control (SMC) approach with Siegwart [
7,
8,
9]. J.A. Ricardo Jr and D.A. Santos studied a smooth second-order SMC for a hexacopter for position and attitude control problems [
10]. Moya et al. studied SMC for a drone and confirmed its advantages over PID controllers [
11]. In Chiew et al.’s research about altitude and yaw control of a quadcopter, second-order SMC outperformed PD control in all considered performance indicators. [
12] Abrougui et al. proposed a robust SMC scheme to stabilise the attitude of a hexacopter during waypoint tracking [
13].
Tuning is a critical process of control approaches development; it refers to adjusting the coefficients of the controller to improve performance. Agha, for example, used the Ziegler–Nichols tuning method in the case of PID control, and both Agha and Abidali used fuzzy logic theory to improve the performance of the PID controllers [
5,
6]. The tuning of SMC has also been studied, for example, Concha et al. developed a tuning algorithm for SMC and applied it into attenuating the structural vibration. [
14] Nekoukar and Dehkordi applied fuzzy logic-based theory on a sliding mode controller of a quadcopter, which achieved robust past tracking. [
15]
Optimisation algorithms have been widely used in tuning, for example, particle swarm optimisation (PSO) and grey wolf optimisation (GWO). Both approaches involve biomimicry to obtain the optimal solution. They are characterised by the fact that they do not require in-depth knowledge of the system to obtain the optimal solution; just as animals arriving in a new environment can also obtain their prey quickly in some way. So, these approaches have a wide range of applications. Liu et al. applied PSO on SMC for a vector machine [
16]; Kumar et al. utilised PSO- and GWO-optimised SMC on frequency regulation. [
17] These approaches have also been applied to drones; for example, PSO has previously been used for tuning the PID control of a quadrotor UAV by Noordin et al. [
18] and Yin et al. [
19]. Qu et al. developed a hybrid GWO algorithm and applied it on the path planning of a drone. [
20] However, the study of optimisation-based SMC optimisation for controlling a hexacopter is limited. This study improves the SMC flight controller by using optimisation approaches, such as PSO and GWO.
2. Dynamical Model
Two coordinate systems are needed to describe the translational and rotational movement of a hexacopter. They are the inertial coordinate (
OiXiYiZi), based on earth, and the body-fixed coordinate (
ObXbYbZb) attached to the centre of mass of the drone. For a hexacopter,
Xb-axis is on a strip,
Yb-axis is on an angle bisector of two strips, and
Zb-axis is defined by the right-hand rule, as demonstrated in
Figure 1. The position of the drone is expressed by vector
r in inertial coordinate:
Moreover, the velocity of the drone is expressed in body-fixed coordinate:
The attitude of the drone is described by Euler angles
, which expresses roll, pitch, and yaw angles, respectively. In addition, the transformation between inertial and body-fixed coordinates depends on the attitude angles. The two coordinates are coincident initially, and the drone rotates around the
z, y, and
x axes, as shown in
Figure 2.
O1 × 1Y1Z1 and
O2X2Y2Z2 are two intermediate coordinates after the first and second rotation; accordingly,
and
are the intermediate velocity vectors. The mutual orientation of the coordinates is described by the rotation matrix
[
21].
The transformation of velocities between the body-fixed and inertial frames is given as:
The same angular velocity is expressed differently in different coordinate systems. The vector
ω denotes the angular speed of the drone in body-fixed coordinates where
,
, and
are the angular velocities of hexacopter in the body frame; the vector
is the attitude vector in the earth-fixed frame.
The transformation matrix for the angular speed is as follows:
The transformation of the angular speed is:
Equation (9) is the Newton–Euler equation of motion, which describe the equilibrium of forces of a drone in body coordinate:
where
F is the force vector and
N is the torque vector,
I3 is a 3 × 3 identity matrix, and
M is the inertia matrix:
The force is determined by the gravity of the drone and the thrust generated by the rotors, the aerodynamic resistance. The equation of force with transformation can be expressed as Equation (11):
where
is the mass of the drone,
is gravitational acceleration, and
is the total thrust generated by the propellers.
In Equation (12), is the thrust coefficient, and to are the angular speeds of the corresponding propellers.
The aerodynamic resistance of the drone cannot be ignored. The direction of the drag is opposite to the direction of the movement,
,
and
are the aerodynamic resistances or drags in
x, y, and
z direction. [
22,
23]
In Equation (13),
is the air density;
are the drag coefficients, which are dimensionless numbers, depending on the angle of attack (AOA).
are dimensionless lift coefficients dependent on the AOA; A is the area of the drone in contact with the air when flying vertically upwards.
The torque vector
:
where
is the torque produced by the propellers;
is the propeller gyroscopic torque,
is the inertial counter-torque;
is the torque due to the aerodynamic drag.
For a hexacopter, the torque produced by the propeller is [
24,
25]:
where
is the thrust factor,
is the drag torque constant, and
is the arm length;
and
are the torque due to thrust about
x-axis on body-fixed frame;
is the torque about the
z-axis, which is dominated by the torque from the drag of the blade.
The propeller gyroscopic effect results from a change of angular momentum of propellers due to the rotation of the hexacopter. It is given by the cross-product of the angular velocity of the hexacopter and the angular momentum of a propeller. The expression is:
where
is the moment of inertia of the rotor (a propeller and a motor).
The inertial counter-torque is the torque required to balance the torque of rotors. The torque is given by the product of the rotor moment of inertia and angular acceleration. Applying the rotation form of Newton’s third law; the counter torques are numerically equal to the rotors torques but in opposite directions. The counter-torque only appears on the
z-axis (of the body-fixed frame):
where
to
are the angular accelerations of the corresponding propellers.
The drone is also affected by aerodynamics during its rotation. The expression of the torque caused by aerodynamics is:
,, and are the drag torque coefficients.
According to Newton–Euler Equation, the acceleration and angular acceleration of the drone in body-fixed coordinate can be calculated with the following equation:
The drone’s velocity can be calculated by integrating the acceleration and then transforming the velocity to inertial coordinate by Equations (3) and (4). Likewise, the position can be calculated by integrating the velocity. Similarly, the attitude angle can be calculated by two integrations and one transformation.
3. Control of Hexacopter
The objective of the control is to make the drone fly autonomously following a desired trajectory. The desired trajectory includes the desired position (
x, y, z) and the desired yaw angle. The pitch and roll angles are supposed to be small, but they control the position. A state vector is defined [
11]:
The 12-state variables are the position in the inertial axis, attitude angles, and their time derivatives (or speed). The 12 state variables correspond to six degrees of freedom. The flight controller can be divided into six sub-controllers, corresponding to the state variables or degrees of freedom. The rotation sub-controllers are roll sub-controller, pitch sub-controller, and yaw sub-controller; the position sub-controllers are z (altitude) sub-controller, x sub-controller, and y sub-controller.
The state of the drone is determined by the thrust and torque provided by the rotors, the control vector of the hexacopter is defined as:
After simplification, the dynamical model for the flight controller, the time derivative of the state vector is:
The propeller gyro effect and inertial counter-torque are neglected in this equation.
is the control variable of roll sub-controller;
is for pitch sub-controller;
is for yaw sub-controller.
and
are an expansion of the control variables and are determined by the attitude angles and
They are the control variables of
x and
y sub-controllers. In addition, conversely, the commanded pitch and roll angle (
x1c, x3c in the form of state variables) can be calculated by the control variables
and
. When the pitch and roll angles are small,
The flight control scheme for a hexacopter is indicated in
Figure 3. The input variables are the desired position and yaw angle. First, input the desired position to the position sub-controllers to get the commanded control variable
and commanded pitch and roll angles. Then, input the desired yaw angle and commanded pitch and roll angles to the rotation sub-controllers to get the control variables
,
and
. The control variables are inputted into the system. The system estimates the actual position and attitude and then feeds back to the sub-controllers.
The control strategy applied in the position and rotation sub-controllers is the sliding mode control approach. It is an iterative method based on Lyapunov stability theory. A sliding surface is designed to drive the state space, and the controller makes the state space reach the sliding surface. When the sliding surface is reached, the controller keeps the state on the neighbourhood of the sliding surface [
26]. For a second-order system, such as the roll sub-controller:
Define the setpoint
x1d and the error
:The sliding surface is defined as follows:
With
defined by
where
is a positive constant.
To make the state approach, the sliding mode is equivalent with stabilising
to zero, a positive definite Lyapunov candidate function for s is defined as:
Then, if
,
for all time. Following the exponential reaching law:
where
and
are positive constants, the three coefficients of one sliding mode controller. In addition,
is a negative definite function. Apply this control approach to a hexacopter with Equation (22), following the exponential law, the rotation sub-controllers:
And the position sub-controllers:
to are the difference between the desired value and real value or error. to and to are the control coefficients. In the sliding mode flight controller of the drone, each sub-controller has three coefficients; there are 6 sub-controllers with 18 coefficients. These coefficients have been tuned based on previous experience, the requirements for an autonomous flight can be achieved in this way. However, further improvements can be made by means of optimisation.
4. Optimisation
PSO and GWO have been used to optimise the controllers by tuning the coefficients in this study. Both of these optimisation approaches are derived from biomimicry. PSO is inspired by the social behaviour and dynamical movements with the communication applicable in insects, birds, and fish; GWO is inspired by grey wolves’ social hierarchy and hunting process.
In PSO, all particles are in search of an optimal position. This position is unknown, but it is possible to compare which particle is in a better position. Each particle decides where to move next based on the best position it has experienced and the best position of all the particles [
18].
Equation (39) expresses the direction and position of a particle in the next iteration. is the iteration number, is the direction, and X is the position. P is the best position reached by the particle, and G is the best position reached by the swarm. and are random numbers between 0 and 1; and are positive constants as the coefficients. is usually equal to 1 and .
In GWO, four groups are defined in the algorithm to simulate the social hierarchy of grey wolves [
27]:
Alpha (α)—the leaders, called alpha, are responsible for decision-making, such as hunting, sleeping place, time to wake, etc.
Beta (β)—this is the second level. They are the subordinate wolves, and they help the alpha wolves with decision making.
Delta (δ)—like beta wolves, they must submit to alpha and beta wolves but dominate the other wolves.
Omega (ω)—the followers.
During the hunting process, the exact location of the prey is unknown. Therefore, the alpha, beta, and delta wolves have more experience and knowledge about hunting to estimate the prey’s position more accurately. The hunting is guided by alpha, beta, and delta; the omega wolves are followers.
The following equations represent the mathematical model of the hunting behaviour:
In Equation (40),
is the current iteration. Thus,
Xα, Xβ, and
Xδ are the three best positions or the positions of alpha, beta, and delta wolves.
X is the position of any wolf in the group;
C1, C2, and
C3 are random numbers.
In Equation (41),
,
, and
are adaptive numbers; these two equations define how the wolf moves with the guide of the leaders. The random numbers and adaptive numbers are defined with
where
and
are random numbers between 0 and 1, max is the number of iterations. The process of the GWO algorithm is indicated in
Figure 4. The three groups of wolves with the highest fitness are alpha, beta, and delta wolves. The position and identity of the wolves are updated in each loop. The system then proceeds to the next iteration (Iter = Iter + 1) until the maximum number of iterations is reached (Iter == max).
At first, the roll sub-controller was used to test the performance of the optimisation algorithms. The 30 degrees step response tested the sets of coefficients of the roll sub-controller. The optimal coefficients are unknown during the optimisation of a sliding mode controller. A total of 10 sets of coefficients are generated randomly, such as ten particles or wolves. The integral of time multiplied absolute error (ITAE, Equation (43)) measured in simulation has been taken as the objective function.
where
represents the error at a certain operation time.
ITEA reflects the accumulated error in the control as an indicator to judge the performance of a controller. So, three coefficients refer to the position of a particle or a group of wolves. The smaller the ITAE, the better the position. Initially, the coefficients
,
and
are 20, 4, and 4, respectively, these coefficients are based on some previous experiences and manual tunings. The step time of the input signal is at 2 s, and the final value is 30 degrees. The original ITAE is 8.616. The roll sub-controller has been optimised four times with the number of iterations 3, 5, 10, and 15 with the two optimisation approaches. With the increase in iterations, the ITAE reduced significantly. The detail of the comparisons is in
Table 1 for PSO and
Table 2 for GWO.
As can be seen from
Table 1 and
Table 2, the effectiveness of the two optimisation algorithms can be compared by comparing ITAE. GWO outperformed PSO by 6.6% and 7.2% in three and five iterations, respectively, in terms of optimisation; in 10 and 15 iterations, the advantage reduced to 4.7% and 3.5%. After more than ten iterations, the sub-controllers improved by both optimisation algorithms and were close to optimal. However, the performance of GWO is always slightly better than PSO. The coefficients were set to
and
. Other coefficients have been tried but with no better performance. The purpose of using these optimisation methods is to tune the controller. Still, the PSO itself also has coefficients that need to be adjusted. This includes its three coefficients and the initial direction of motion, which all impact the optimisation results. Whereas all the coefficients of the GWO are random numbers or can vary linearly depending on the number of iterations. The GWO shows better performance; therefore, the overall flight controller is optimised using GWO.
In
Table 3, the rise time, the peak time, the overshoot, and the settling time of each optimised roll sub-controller have been compared. All these four response parameters have improved after optimisation. The performances of the sub-controllers optimised over 10 and 15 iterations are very similar; there was only a 0.3% difference in the ITAE. The sub-controller with 15 iterations should be selected if only numerical results are considered. However, from
Figure 5, in the performance of the sub-controllers with 10 and 15 iterations, when the simulated value exceeds the target value, there was some oscillation before reaching the peak. This oscillation occurs when the sub-controller has undergone more than five iterations of optimisation. When all rotation sub-controllers work in tandem, these oscillations can introduce further instability into the flight of the drone. So finally, the roll sub-controller, optimised through five iterations, was selected for further design. With the optimisation of five iterations, the rise time was reduced by 52.9%; the peak time was reduced by 45.2%, the overshot reduced by 1.9%, and the ITEA reduced by 59.7%. With the exception of the overshot, the improvement in all other aspects is remarkable.
The other sub-controllers have also been optimised by GWO with a similar process. The roll and pitch motions of the drone are very similar, so the pitch sub-controller used the same coefficients as the roll controller. These two sub-controllers were optimised first because they are essential for stable flight and are used to control the translational movement of the drone.
The yaw sub-controller has been optimised secondly. The control of the yaw angle is relatively less important than the other two attitude angles. Thus, when optimising the yaw sub-controller, it is also important to consider its influence on the other two attitude angles. The method used is to simultaneously give a 30 degrees step response command to all three attitude angles. To minimise the sum of the three angles ITAE is used as the optimisation target.
Then, the altitude sub-controller has been optimised. A 2 m step response was given to the system. The optimisation target is to minimise the ITAE of the motion in
z-direction. The
x and
y sub-controllers have been optimised last as the thrust and attitude angles determine the translational motion. They need to be optimised based on the optimised rotation sub-controllers and the altitude sub-controller. The process is the same with the altitude sub-controller. Due to the similarity of the two translational movements, the two sub-controllers use the same coefficients. The original and optimal coefficients are shown in
Table 4.
The optimisation effect of the roll angle sub-controller has been certified in a test bench. In addition, the entire flight controller has been verified in simulation with a designed trajectory.
5. Test Bench
A preliminary test bench was carried out to test the flight controller. This test bench is a two-motor system, motors are fixed to the ends of a carbon fibre board, and an axis is fixed in the middle with a bearing, as shown in
Figure 6. The system has one degree-of-freedom motion, the roll angle. The test bench helps lock some degrees of freedom to avoid system damage and reduce control complexity [
6]. This test bench is equivalent to the roll motion of the drone; it was used to test the roll sub-controller. Using the following equation:
Where
is the angle between the system and horizontal plane, it can be measured by an IMU,
is the distance between propeller and axis, which is easy to measure,
and
are the speeds of the two propellers.
is the moment of inertia of this testing device. In this experiment, the moment of inertia of the system is measured by the oscillation of a bifilar suspension (
Figure 7).
The moment of inertia can be calculated using Equation (45). is the mass of the system, is the acceleration due to gravity. is the rope length; is the distance between the wires; and is the period of the swing, which a stopwatch can measure. This test bench was applied to test the different controllers in the roll angle step response; the control algorithm was translated to codes and implemented to a microcontroller
(Arduino Uno).
6. Results
The optimised roll sub-controller was verified in the test bench, as shown in
Figure 8 and
Table 5. In quantitative analysis, the integration of absolute error (IAE, Equation (46)) is also used in the analysis. This indicator does not take time into account. IAE is more valuable in trajectory tracing. In
Table 4, the IAE and ITAE in the simulation, as well as in the experiment are compared; E-ITAE and E-IAE refer to the ITAE and IAE in the experiment. In this step response, the step time is 0, so the ITAE is smaller than the simulation in the optimisation process. In the simulation, the IAE and ITAE were reduced by 39.13 and 58.33, respectively, while in the experiment, the E-IAE and E-ITAE were reduced by 19.35 and 10.39, respectively. The situation is caused by the vibration in the results given by the sensor, nevertheless, the effect of the optimisation is remarkable. Moreover, due to the results’ vibration, in
Figure 8, it is difficult to visualise the difference between the original system and the optimised system.
The whole optimised flight controller has been implemented in Simulink for simulation with the mathematical model. First, the inputs of the controller have to be confirmed. During the control of the autonomous flight, the system’s inputs are the desired position (x, y, z) and yaw angle (). The outputs of the flight controller are the commanded speeds of the motors; the commanded speeds are inputted into the dynamical model for simulation.
A trajectory was designed to test the flight controller to face extreme conditions. In the test trajectory, the drone rises 2 metres in the first second and then starts moving along a circular trajectory, and simultaneously the drone should rotate 360 degrees; the simulation time is 20 s. All the six degrees of freedom motion are involved in this trajectory. The equation of trajectory is as follows:
The trajectory is shown graphically in
Figure 9. The designed trajectory was used to test both the original and optimised flight controller, and the results are presented in
Figure 10 and
Figure 11.
From 0 to 2 s, the drone started to rotate and rise; there was no translational movement or roll and pitch. From the th second, the drone was required to move towards both x and y directions, so the commanded roll and pitch angle appeared. The commanded roll and pitch angle is limited to +/− 30 degrees in both original and optimised controllers to maintain a stable flight. The two figures clearly show that the drone with the optimised controller follows the designed trajectory more closely. This result does not only come from intuition but is confirmed numerically.
Quantitative analysis is more convincing. In
Table 6, both ITAE and IAE in six degrees of freedom motion have been compared. ITAE is a kind of time-weighted measurement. Applying ITAE on step response is necessary, since it is important to consider a steady-state error. However, for this trajectory, some significant errors appear in the late stage due to the complexity of the desired value; it is not reasonable to compare ITAE in this case. So, the measurement without time weighted or IAE has been compared too. However, all the error measurements of the drone with optimised sub-controllers are smaller.
Table 6 also gives the percentage of the improvement. The most improved is the yaw sub-controller with 73.2% error reduction. The performance of the
x and
y sub-controllers has also improved by close to or more than 50%. Relatively small improvements were made to the altitude controller. Mainly the coefficients of the original
z sub-controller are closer to optimal compared to the other sub-controllers. The above four sub-controllers, which receive direct commands regarding the desired trajectory, have all been significantly optimised. The roll and pitch controllers receive instructions from the position sub-controllers. When the position sub-controllers are optimised, the angle commands are given more aggressively to achieve a fast response. This poses a greater challenge to the roll and pitch sub-controllers. Despite this, the cumulative control error of the roll and pitch sub-controllers for the same trajectory is reduced by 15.6% and 22.4%. This is a further indication of the success of the optimisation.