actuators

: This research presents an analysis and management strategy for hovering hexacopter with one or more failing motors. Of late, multirotor drones have become particularly popular, and all drones have been increasing in popularity. Unlike a ﬁxed-wing drone, failure of motors in a multirotor craft may cause safety problems. Numerous published articles have proposed solving this problem by redesigning the control law or control gain. This approach, however, is difﬁcult to implement because change of control gain usually involves connecting external devices. This paper proposes to keep the control gain unchanged but reallocate the thrusts. Simulations are conducted on a hexacopter in various hovering modes. Some hovering state problems are investigated for the linearized dynamics but also numerically veriﬁed for the original nonlinear dynamics. In case some motors of a hexacopter fail in ﬂight, an allocation matrix is proposed to redistribute required thrusts to functional motors. Seven cases of motor failure are studied. This paper analytically proves that limited controllability for emergency landing is feasible in four scenarios at the linear level, but the other three scenarios are completely uncontrollable. Numerical simulations are presented to demonstrate the validity of our algorithm. An online video of real ﬂight also conﬁrms our results. This paper potentially helps the design of failure management of rotors and increases the successful rate of emergent landing.


Introduction
Drones have been widely used since 2010. In addition, drones are used for tasks such as scientific research, civil development, and military missions [1]. As drones become popular, many stakeholders are concerned with safe drone operation. A hexacopter drone has two more motors than does a quadrotor drone; this provides redundancy in the cases in which some motors fail. Drones equipped with the conventional control allocation schemes may crash if one or more motors fail during flight. Fault-tolerant control is crucial to drone safety and has been an extensively researched topic [2][3][4][5]. For a multirotor drone, failure of some motors may result in a period of uncontrolled flight or an uncontrolled crash landing. Two approaches are mainly employed to investigate drone motor failure: fault detection and isolation, which usually entails estimating the effectiveness of failed motors [6,7] and control allocation.
Several studies have been conducted on motor failure detection, maneuverability of drones with failed motors, and control allocation. When a drone suffers from motor failure, fast detection of failed motors is essential for follow-up responses. Some excellent work on this field can be found in [8][9][10]. A very recent and novel method of fault diagnosis using thermal imaging is presented in [11]. Refs. [12][13][14] considered the influence of multirotor configuration to the controllability and maneuverability. Though robustness of the drone subject to rotor failure was discussed in their work, only the case of one failed rotor were considered. Lu [1] proposed a complete active fault-tolerant control system for quadrotors subjected to one total rotor failure. Merheb [15] proposed a lookup table for transforming a quadrotor to a trirotor in the event of one total rotor failure. Tjønnås [16] proposed an algorithm that employs a positive-definite control efficiency matrix; by contrast, Falconí [2] proposed an algorithm in which the restrictions are released and the virtue control matrix is assumed to be full rank. Nagarjuna and Suresh designeds a safe landing sequence [17]. Wang and Zhang reshaped the control commands via sliding mode control algorithm [18]. Lee et al. employed two servomotors that control relative roll and pitch attitudes when one motor failure is detected to maintain the stability of the quadrotor [19].
Although the aforementioned systems are excellent, a few questions remain unanswered: first, most previous studies have considered quadrotor or hexacopter systems with one failed motor. The question as to how to address systems with more than one failed motor has not been answered. Second, Falconí [2] imposed the assumption that the virtue control matrix is full rank. However, in the event of motor failure in a multirotor vehicle, this assumption may not hold. Third, ref. [15,20] have proposed a lookup table to solve control allocation problems on a case-by-case basis. However, an algorithm that provides a general approach to the allocation problem is required. Fourth, most studies have discussed attitude control but not trajectory control. Hence, the question as to whether trajectory is also controllable under failed motors warrants answering. The presented work in this paper is inspired by [21]. There are still several differences: In [21], an octorotor was investigated, whereas we investigate a hexacopter. Secondly, ref. [21] approached the problem only with numerical simulations, whereas controllability is examined analytically in our work. Thirdly, Marks et al. only simulated altitude and attitude in [21], whereas we analytically and numerically show that recovery of hovering position is possible in some cases.
In this paper, we focus on the allocation of controls when some motors fail during flight. Figure 1 presents a block diagram of the motor failure management process, and this paper mainly focuses on the failure management portion, presented in the block of dark gray background. Assume that motors have failed during flight and that this failure has already been detected. The uneven distribution of forces results in the offset of the states from the nominal hovering states. For hovering states, the control reconfiguration algorithm generates new control distribution regarding functional motors. However, the perturbed flight states require more control effort than do nominal flight states. The extra control effort is managed and generated by applying the allocation algorithm detailed in Figures 3 and 4. The control allocation algorithm along with reconfigured nominal control is expected to restabilize the hexacopter during hovering flight. If not, this algorithm is expected to sufficiently stabilize the flight so that pilots can perform an emergency landing. There are three main advantages in using allocation of controls. First, only one control gain is required, even with failed motors; secondly, onboard emergency response is possible; thirdly, development process of controller is faster. Implementation of controllers requires a computing unit and other supporting components in an integrated circuit board, such as an onboard computer or a set of microchips. For a drone using an onboard computer, change of control gain or control law in response to failed motors may require an external, special device to "burn" parameters into the onboard computer, such as Pixhawk. Therefore, in general, parameters and control algorithms are not adjustable during flight in such cases. Although some computing units composed of microchips may modify their control parameters in flight, this process needs to be manipulated from the ground station. In contrast, the algorithm of control allocation along with control reconfiguration can be written in the onboard computing unit in advance. When encountering a motor failure event, the drone can respond to the emergency and stabilize itself autonomously. An alternative but similar manipulation is to prepare multiple control gains or control laws onboard, as suggested in this paper suggested with allocation matrices. This method requires longer developing period to develop, simulate, and verify controllers for various motor failure cases. Moreover, gain scheduling should also be considered for different controllers subject to change in drone configuration or variations in flight conditions. One set of control gain with the proposed allocation algorithm significantly shortens and simplifies the development process.
Specifically, the objective was to develop an approach that can be applied to safely land a hexacopter with one or more failed motors. In some cases, however, emergent and immediate landing may be difficult. Trajectory control with some failed motors is crucial under these circumstances. Assuming that failed motors are detected, our investigation focuses on control reconfiguration and control allocation. Instead of rotational speeds, force and moments are adopted as the control input in the equations of motion (EOMs). The force and moments are then distributed to the rotors. In cases in which some rotors have failed during flight, the required force and moments are allocated to the remaining functional motors if possible. This approach tolerates uncontrollable yaw but not uncontrollable pitch or roll, which is highly related to flight safety. According to our research, pitch or roll would become uncontrollable only if four or more motors fail. Therefore, this paper discusses situations involving the failure of only one, two, or three motors; such failures can be grouped into seven cases. The paper also proposes a general allocation algorithm for efficiently allocating thrust and moment loads to the remaining functional motors even when non-full-rank control allocation matrix is applied. Thus, the designated control law and control gain need not be changed due to motor failure. This assumption is relatively practical because change of control law or control gain takes relatively larger effort as discussed previously. Our algorithm considers the control of full states, including trajectory and attitude, and is verified through numerical simulations.
The rest of this paper is organized as follows: Section 2 describes the dynamics and EOMs. The applied control law and the general control allocation algorithm are presented in Section 3. In this paper, our algorithm applies a linearization approach for equation analysis and simulations are conducted in a nonlinear regime to demonstrate the validity of the algorithm. Section 4 discuses cases of failed motors and failure management. Several simulations are presented in Section 5 to verify the proposed algorithm. The final section concludes our work and summarizes the contributions.

Coordinate System and Rotor Numbering
A hexacopter is composed of six rotors. To keep the momentum of the whole vehicle neutral, the six rotors are arranged in three pairs, with the two rotors in each pair rotating in opposite directions ( Figure 2, left panel). The six rotors are separated form one another at an angle of 60 • . A Cartesian coordinate system, comprising the axes (i, j, k), with origin at the center of mass (CM) of the hexacopter is defined for further investigation. Because this coordinate system shifts along with the hexacopter, it is in the drone body-fixed frame (BF). The i-axis is defined so that the left rotor rotates counterclockwise (CCW) and the right rotates clockwise (CW) from the top view. Because the vehicle is rotationally symmetric, the direction i can be arbitrarily assigned as long as the aforementioned constraint is satisfied. The j-axis points rightward and is perpendicular to the i-axis. Finally, k = i × j completes the triad.
A local-vertical-local-horizontal (LVLH) frame, comprising the axes (I, J, K), is also defined. The I-axis points northward, J-axis points eastward, and K-axis points toward the center of the earth. Because the endurance of a hexacopter is much shorter than a day, the earth can be assumed to be static during a mission, and the LVLH frame can be regarded as inertial. A diagram depicting the concept is presented in the right panel of Figure 2.
A set of Euler angles (φ, θ, ψ) is employed to describe the rotation of the hexacopter, representing the rolling, pitching, and yawing angles, respectively. Throughout this paper, we adopt a yaw-pitch-roll sequence, also called 321-sequence, for rotations from the LVLH (inertial) frame to the BF. A rotation matrix R I2B associated with the set of Euler angles is defined to transform coordinates of a vector with respect to the LVLH frame to those with respect to the BF. Detailed formulation of R I2B can be found in [22]. A rotation matrix is orthonormal, satisfying R B2I = R −1 I2B = R T I2B . Additionally, a matrix T is employed to transform an angular velocity ω = pi + qi + rk to the time change rate of Euler angles (φ,θ,ψ), described by Equations (2) and (3) [22].
For further investigation, all rotors are assigned a number. All rotors in the CCW direction from the i-axis are designated as T 1 to T 6 , as depicted in Figure 2.

Hexacopter Dynamics
Let r = xI + yJ + zK denote the position of the hexacopter with respect to the LVLH frame and V = ui + vj + wk be the velocity of the CM. Accordingly, the kinematic equations can be expressed as follows:ṙ where Θ = (φ, θ, ψ), and In Equation (3), S φ = sin φ and C φ = cos φ. Notably, r and V are expressed in different coordinate systems. A rotation matrix R B2I should be applied to Equation (1) in actual computation processes. Moreover, T is not a rotation matrix, and singularities exist when θ = ±90 • . A hexacopter usually flies with a small pitch angle and is not influenced by singularities. An alternative solution to avoid singularity is the employment of quaternions.
The kinetic equations can be derived from Newton's laws of motion. Let ∑ F be the external forces exerted on the hexacopter and ∑ M be the external moments with respect to the CM. Newton's second law of motion describes the following: where I cm is the inertia tensor with respect to the CM in the BF. Because a hexacopter is usually symmetric to the ik and jk planes, the inertia tensor can be expressed as I CM = diag(I xx , I yy , I zz ).

Formulation of Forces and Moments
A previous study detailed the formulations of forces and moments [23], and the results of these formulations are cited herein directly. However, the formulations must be slightly modified because some definitions in this paper are unique.
The total force exerted on the hexacopter can be divided into four components: the thrust F t , rotor drag D r , air resistance D a , and weight W. Therefore, According to [23], the aforementioned forces can be formulated as follows: where b is the thrust factor, Ω i ≥ 0 is the rotational rate of the ith rotor, K T > 0 is a constant, ρ is the atmospheric density, C D is the drag coefficient, and S is the reference area; moreover, V = ||V||. The moments and torques comprise four sets: torques due to rotational rate difference between rotors M rd , torques due to gyroscopic effects M gy , and yaw counter torque M yc [24,25]. Hence, where M rd = M φ i + M θ j + M ψ k. M φ , M θ , and M ψ denote the roll, pitch, and yaw moments, respectively and can be further derived as follows: where d is the drag factor, and l is the distance of rotors from the CM, as illustrated in Figure 2. M gy and M yc are formulated as follows: where J r is the rotational inertia of the propeller, and Ω R = −Ω 1 + Ω 2 − Ω 3 + Ω 4 − Ω 5 + Ω 6 is the overall propeller speed.
In this paper, two aspects of control inputs can be considered: the rotation rates of rotors and the force-moment set. In the first case, u = u Ω = (Ω 1 , Ω 2 , Ω 3 , Ω 4 , Ω 5 , Ω 6 ) ∈ R 6 0+ , where R 0+ denotes non-negative real numbers; accordingly, the rotation rates of rotors are used as control inputs. In the second case, accordingly, the lift force as well as three moments are used as control inputs. The two control vectors are convertible and are employed in different scenarios.

Equilibrium Point
As mentioned, the aim of this paper is to develop an algorithm for the analysis and management of hexacopter motor failures. When a hexacopter incurs a rotor failure during flight, an emergent hovering is designed to be imposed, and the developed algorithm can be applied to manage the failure. After control is regained for the hexacopter, the hexacopter may continue its designated trajectory or perform an emergency landing. Therefore, the proposed algorithm can help regain hexacopter controllability during hovering.

Nominal Control for Equilibrium
Writing Equations (19)- (22) in matrix form at the equilibrium point yields the following: Alternatively,WΩ 0 =ū FM , where the bar over a variable denotes evaluation in nominal states, and the subscript "0" denotes no failed motor.W is a transformation matrix that transformsΩ 0 toū FM .

Linearized EOMs
The linearized system is expressed as follows: ∆ẋ = A∆x + B∆u, where the state matrix is A ∈ R 12×12 , and the control matrix is B = B Ω r ∈ R 12×6 or B = B FM ∈ R 12×4 . A and B can be derived through partial differentiation with respect to x and u evaluated at the equilibrium point, and calculations are provided in Appendix A.

Control Architecture
Feedback control laws are usually designed to stabilize a hexacopter and can generally be presented as follows: u = −K(t)(x(t) −x(t)) + x des (t), where K(t) denotes the feedback gain, x denotes the real-time state vector, and x des denotes the desired state vector. A different control law may result in a different gain K(t).
The control allocation architecture is shown in Figure 3, where ∆x = x −x. Let u c denote the control command computed from the control law. As mentioned, u c is given by lift force and three moments. In practice, the control signal should be allocated to and realized by the rotational speed of each rotor. The rotation of rotors in response to the control command then generates corresponding lift and moments, denoted as u, to stabilize the hexacopter. If all motors function well, the allocated rotational speeds should be identical to the actual rotational speed, leading to u c = u. If some motors fail, only the remaining operational motors can generate controls. Consequently, u c = u in such cases. The proposed algorithm forces u c = u for failed motors by reallocating control to the remaining motors if possible-the limitation of the algorithm.
In the implementation, ∆u FM is applied to prevent the adjustment of control gains due to motor failures. To compensate for the loss of the failed motors, the control commends are allocated to the remaining functional motors. Hence, we specify ∆u FM as ∆u because ∆u FM is the control vector obtained from the control law. ∆u Ω r is renamed as ∆R for simplicity. Moreover, we drop the ∆-sign in the following derivations for simplicity, leading to u = WR. Notably the following derivations are only linear approximations. Nominal controls should be considered and added if the original full nonlinear system is to be simulated. Moreover, Figure 4 presents the flowchart of the control allocation algorithm. The subscript "c" denotes the command derived from the control law, and a term without a subscript denotes the actual input in the implementation. Given a control command u c , the command for the rotational speeds R c can be derived by multiplying the allocation matrix M, given by R c = Mu c . On the other hand, ∆Ω r,i ≡ 0 if the ith motor is failed. Multiplied by R a , R simulate the actual rotation of rotors. For example, given the first and third motors fail, we obtain the effectiveness matrix R a = diag(0, 1, 0, 1, 1, 1) and the corresponding R = R a R c = (0, Ω r,2 , 0, Ω r,4 , Ω r, 5 , Ω r,6 ).
Linear Trans.

Matrix
Matrix According to Equation (30), In normal flight, R a = I 6 , and u c = u. When some motors fail, the design of the allocation matrix M becomes critical. The following questions are assessed in this paper: 1. Does M exist so that u c = u when some motors fail? 2. If yes, what is the best method to design M? if no, what is the best method to regain the control of the hexacopter?

Controllability of the System
When some motors fail during flight, the designated control command cannot be fully realized, causing loss of force and unbalanced moments. An ideal allocation algorithm will redistribute the rotational speeds of the remaining operational motors so that the lost thrust is compensated for. Obviously, not every failure situation can be compensated for. For example, in the special case that all six motors fail, the thrust will never be compensated for. Therefore, the effectiveness of the allocation algorithm depends on whether the system is controllable subject to a constrained control.
The controllability of the system in the specific allocation problem can be formulated as follows: consider a linear control systeṁ In our problem, the details of the state-space equations are presented in Appendix A. The controllable states and the corresponding control must be determined, and the domain of the actual control is given by Therefore, the problem can be reformulated by substituting Equation (34) into Equation (33) as follows:ẋ where B c = BWR a M. The controllability can be examined by studying the pair (A, B c ).

Failure Management
In this paper, we consider seven cases of motor failure: one case involving only a single failed motor, three cases involving two failed motors, and three cases involving three failed motors. The arrangement of the subsequent failed motors is based on motor 1 because the arrangement of the six motors on the hexacoptor is geometrically symmetrical. The failure cases are illustrated in Figure 5. The crosses on the motors signify that the motors have failed.

Design of Allocation Matrix
Failure management is discussed in this section. Once failed motors are detected, the allocation matrix M is adjusted to reallocate required rotor rotational speeds so that the designated control inputs can be realized. Because the function of M is to maintain u = u c , the following identity holds: Let W k = WR a denote the failed motors. For example, If Motors #1 and #4 fail, then R a = diag(0, 1, 1, 0, 1, 1) and W 14 = WR a . If all motors function normally, that situation is denoted by W 0 . On the basis of this definition, Equation (36) can be further simplified as follows: Taking the right pseudo-inverse of W k yields Clearly, Equation (38) satisfies Equation (37) given that W k W T k is invertible. In the case that W k W T k is singular, implying that full control of the hexacopter is impossible, the yaw control must be sacrificed. Let where W k1 ∈ R 3×6 and W k2 ∈ R 1×6 . If rank(W k1 )=3, W k1 W T k1 is invertible. Then, M is constructed as follows: Accordingly, Although the yaw control is not as designed and may fail to control the yaw motion, this situation is acceptable: first, the yaw motion is independent of other states in the linear sense, and failure in yaw control does not affect the propagation in other states; second, uncontrolled yaw motion does not influence the flight safety considerably whereas uncontrolled pitch or roll motion may cause a crash.
If rank(W k1 ) < 3, flight safety cannot be achieved for the hexacopter. These cases are out of the scope of this paper and are not discussed.

Controllability
A system without failed motors must be fully controllable. This fact can also be proved as follows: The controllability matrix U formed by the pair (A, B c ) is full rank, indicating that all states are controllable.

Controllability and Stabilizability
The control matrix B c is expressed as B c = BW 1 M 1 . The structure of B c is identical to Equation (A17), and that of B 3 identical to Equation (A20). However, B 4 is modified as follows: We can derive the controllability matrix U and assess the rank. Rank(U) = 10 < 12. Hence, this is an uncontrollable system. This result is consistent with those proposed in [12]. An alternative approach can be achieved by defining the controllability matrix as follows: where λ is an eigenvalue of A. Those uncontrollable eigenvalues reduce the rank of U alt . A has ten unstable eigenvalues at 0 and two stable eigenvalues at −K T /m. By scanning through all eigenvalues of A, we conclude that the system is unstabilizible because the uncontrollable eigenvalues are the 0 values. According to control theory, controllable states can be found in the column space of U, denoted as R(U). Executing manipulations yields R(U) = Sp e 1 , e 2 , e 3 , r 4 1 , r 5 1 , e 7 , e 8 , e 9 , r 10 1 , r 11 where e i ∈ R 12 is a standard basis in the vector space, and r 4 1 = 0, 0, 0, 1, 0, − dI xx bl I zz , 0, · · · , 0 , r 5 1 = 0, 0, 0, 0, 1, − √ 3dI yy bl I zz , 0, · · · , 0 , r 10 1 = 0, · · · , 0, 1, 0, − dI xx bl I zz , The subscript r i denotes a failed motors. This result explains that only specific initial conditions in the yaw motion can be stabilized when our algorithm is applied in a case in which opposite motors have failed.

Case 2: Two Opposite Motors Fail
In this case, two opposite motors are assumed to have failed, as shown in Figure 5. Without loss of generality, we use Motor #1 and #4 as an example. Other opposite pairs of failed motors lead to similar results.

Case 3: One Working Motor in Between
In this case, we assume one working motor in between two failed motors, as shown in Figure 5. Without loss of generality, this paper uses failed Motors #1 and #3 as an example.

Allocation Matrix Design
In this case, R a = diag(0, 1, 0, 1, 1, 1), and W 13 is attainable by W 13 = WR aΩ . Only the 2nd and 5th columns are nonzeros, and this indicates that rank(W 13 ) = 2. Accordingly, pitch and roll are uncontrollable. Hence, this scenario is out of the scope of this paper.

Controllability and Stabilizability
The control matrix B c is calculated as B c = BW 13 M 13 . The structure of B c is identical to Equation (A17), and those of B 3 and B 4 are identical to Equations (A20) and (A21), respectively. Because Equations (A20) and (A21) are derived under the assumption of normal flight, the system is controllable.
Notably, the system is controllable because we restricted our attention to stabilize yaw motion. The system should be controllable if and only if yaw stability is not considered. In contrast to Case 1 and Case 2, in which the yaw motion is uncontrollable at the linearized level, yaw stability is not considered at the nominal level in this case. Therefore, we can expect the divergence of the yaw motion to be greater and faster than those in Case 1 and Case 2. The allocation matrix M 13 is provided in Equation (A24).

Case 4: Adjacent Motors in Failure
In this case, two adjacent motors are assumed to have failed, as shown in Figure 5. Without loss of generality, we consider Motors #1 and #2 as examples.

Allocation Matrix Design
In Case 4, R a = diag(0, 0, 1, 1, 1, 1), and W 12 is attainable by W 12 = WR aΩ . Only the 3rd and 6th columns are nonzeros, and this indicates that rank(W 12 ) = 2. Accordingly, pitch and roll are uncontrollable. Hence, this scenario is out of the scope of this paper.
The alternative approach of releasing yaw control is also investigated for this case. After a similar manipulation procedure to that in the preceding cases, we can obtain that one solution is (c 1 , c 2 , c 3 , c 4 ) = (Ω r , 0, 0,Ω r ), whereΩ r = 4 mg/(2b). Consequently, according to Equation (27), nominal control can be derived as follows:ū Ω r = (0, 0,Ω r , 0, 0,Ω r ). Since the result is identical to that in the full approach, this case is uncontrollable.

Three Motors in Failure
In this section, the three motors are assumed to have failed simultaneously. Potential cases are demonstrated in Figure 5, and they are numbered as Case 5, Case 6, and Case 7. Without loss of generality, motors #1, #3, and #5 are used as an example of failure for Case 5; motors #1, #2, and #4 are used as an example of failure for Case 6; and motors #1, #2, and #3 are used as an example.
The control matrix B c is calculated as B c = BW 135 M 135 . The structure of B c is identical to Equation (A17), and that of B 3 identical to Equation (A20). However, B 4 is modified as follows: Through a similar analysis process, we realize that this an uncontrollable and unstabilizable system.
The subscript r i denotes the failed motors.
Consider the alternative approach, which entails releasing the constraint on yaw at the nominal level. We obtain (c 1 , c 2 , c 3 , c 4 ) = (Ω r , 0, 0,Ω r ), whereΩ r = 4 mg/(2b). This result is identical to Case 4, and we argue that this case is uncontrollable. In this case, the only solution to Equation (27) with a vector in Equation (28) subject to the constraintΩ r,1 =Ω r,2 =Ω r,3 = 0 is (c 1 , c 2 , c 3 ) = (0, 0, 0), leading toū Ω r = 0 6×1 . This implies that nominal rotational rates to stabilize the hexacopter do not exist. We can thus conclude that full controllability of this system is impossible.
Consider the alternative approach, which entails releasing the constraint on yaw at the nominal level. One possible solution is (c 1 , c 2 , c 3 , c 4 ) = (0,Ω r , −Ω r ,Ω r ). Consequently, according to Equation (27), nominal control can be derived as follows:ū Ω r = (0, 0, 0,Ω r , −Ω r , −Ω r ). Because all entries of the vector must be greater than zero, this approach is infeasible. Hence, we argue that this case is fully uncontrollable.

Summarization of Cases Study
After studying potential failure cases, we conclude that 1. the pilot is able to regain controllability of states other than yawing motion when two opposite motors have failed; 2. for the case with only one failed motor (Case 1 and Case 2), the best strategy is to turn off the opposite motor and perform the same maneuver as in the previous scenario; 3. for the case with two failed motors with one working motor in between (Case 3), the pilot is able to regain controllability of states other than yawing motion. In this scenario, however, the hexacopter tends to spin and wobble severely. 4. for the case with three failed motors with one working motor in between (Case 5), the pilot is able to regain controllability of states other than yawing motion. Similar to the previous scenario, the hexacopter tends to spin and wobble severely. 5. for other cases, it is very markedly difficult for the pilot to regain controllability and safely land the hexacopter.

Controller and Simulation Parameters
We present the simulation of an example flight mission to verify the proposed algorithm. Table 1 lists the simulation parameters of the hexacopter. An LQR controller is designed to stabilize the linearized dynamics of the hexacopter with the three weighting matrices being set as follows: Q = diag(5, 5, 5, 10, 10, 1, 1, 1, 1, 10, 10, 1) R = diag(1, 1, 1, 1) The feedback gain K in Section 3.1 is given by K = R −1 B T P + N T , where P satisfies the continuous algebraic Riccati equation [27].
The initial offset in the simulations is given by x 0 = x 0 pos x 0 ang x 0 vel x 0 avl T = (x 0 1 , x 0 2 , · · · , x 0 12 ), where x 0 pos = (0, 0, 0.1) m is the position offset, x 0 ang = (0.05, −0.05, 0.1) rad is the attitude offset, x 0 vel = (0.01, −0.01, 0.1) m/s is the velocity offset, and x 0 avl = (0, 0, 0) rad/s is the angular offset. Because we simulate a situation in which the control is subject to reconfiguration due to the sudden loss of motors, we can set the initial control offset as u 0 FM = (0, 0, 0, 0). For a performance comparison, these initial conditions are employed throughout the cases, except for some specific cases.

Verification of Case 0
This case represents a control scenario with no motor failure. According to the results in Section 4.2, the linearized system is fully controllable. Figure 6 illustrates that all states can converge to 0 values, which represent the nominal states. The control input is shown in Figure 7. ∆u and ∆u c are identical, as predicted. The rotational speeds of the six motors are presented in Figure 8. These rotational speeds are the actual rotational speeds, computed using Ω i =Ω r,i + ∆Ω i , where ∆Ω i ∈ ∆R and ∆R = R a M∆u c . The speeds are identical to the nominal speeds eventually.

Verification of Case 1 and Case 2 5.3.1. Arbitrary Initial Condition
The failure of Motor #1 is simulated in this section. According to the reconfiguration result in Section 4.3, Motor #4 should be turned off to maintain the hexacopter's balance. However, turning Motor #4 off also prevents the stabilization of the linearized system at the linear level. This scenario is identical to Case 2, where Motors #1 and #4 lost power simultaneously due to failure. The aforementioned arbitrary initial condition set is employed in this simulation. Figures 9-11 present the simulation results.
All states in Figure 9 converge to zero except ψ. Notably, ψ remains constant with the convergence of the yaw rate r. The control inputs are shown in Figure 10. ∆T t , ∆M φ and ∆M θ are generated to control the system, whereas ∆M ψ remains at zero due to the failure and deactivation of the motors. The rotational speeds of the six motors are presented in Figure 11. The speeds of Motors #1 and #4 are zero, and the speeds of the other motors are increased to reshape the thrust and torques.

Motor 6
Allocated Normal Figure 11. Rotational speeds of motors in Case 1.

Controllable Initial Condition
According to control theory, initial conditions from any controllable set in a partly controllable system should be controllable. This section presents the verification of our algorithm because it is unlikely for a hexacopter to fall into this initial condition subject to motor failure in a real flight. The controllable initial condition set is provided in Section 4.3.3.
In this simulation, (x 0 1 , · · · , x 0 5 , x 0 7 , · · · , x 0 11 ) are identical to the aforementioned initial conditions. However, x 0 6 is obtained from the corresponding element of x 0 4 r 4 1 + x 0 5 r 5 1 . Similarly, x 0 12 is obtained from the corresponded element of x 0 10 r 10 1 + x 0 11 r 11 1 . The state responses are displayed in Figure 12. All states converge to zero, including ψ. Figure 13 shows the control response. ∆T t , ∆M φ and ∆M θ are derived to control the system, whereas ∆M ψ remains at zero due to the failure and deactivation of the motors. These results demonstrate that ψ is controllable even if ∆M ψ is not available or derived. The rotational speeds of the six motors are presented in Figure 14.

Verification of Case 3
The simultaneous failure of Motors #1 and #3 is simulated in this section. According to the analysis in Section 4.5, the yaw motion is uncontrollable at the nonlinear level. Therefore, to maintain the safety of the hexacopter, we must give up the yaw motion and try to stabilize other states. Through this strategy, all states other than the yaw motion should be controllable.
The aforementioned arbitrary initial condition set is employed in this simulation. Figures 15-17 present the simulation results. Figure 15 converge to zero except ψ and r. The control inputs are shown in Figure 16. Unlike Case 1 and Case 2 where r converges to zero and ψ remains constant, in the present scenario, r converges to a constant and ψ diverges.
As for the control inputs, we sacrifice the yaw moment to save other states. Hence, ∆M ψ maintains divergence, whereas ∆T t , ∆M φ , and ∆M θ function normally. The rotational speeds of the six motors are presented in Figure 17. The speeds of Motors #1 and #3 are zero, and those of the others are increased to reshape the thrust and torques. Moreover, the nominal speed of Motor #2 is 4 √ 2 times more than those of Motors #4, #5, and #6.

Verification of Case 4
The simultaneous failure of Motor #1 and #2 is simulated in this section. According to the analysis in Section 4.6, this system is uncontrollable at both nonlinear and linearized levels. Figure 18 presents a simulation with the aforementioned initial conditions. All states diverge considerably fast.

Verification of Case 5
According to Sections 4.7.1-4.7.3, only Case 5 has limited controllability over the failed hexacopter. The proposed algorithm has the capability of predicting uncontrollable systems, as demonstrated in Section 5.5. Therefore, this section simulates potential responses in Case 5, where Motors #1, #3, and #5 are assumed to have failed simultaneously.

An Arbitrary Initial Condition
Similar to Case 3, demonstrated in Section 5.4, the yawing motion is uncontrollable at the nonlinear level. Therefore, to maintain the safety of the hexacopter, we must give up the yawing motion and try to stabilize other states. With this strategy, all states other then yawing motion should be controllable.
The aforementioned arbitrary initial condition set is employed in this simulation. Figures 19-21 present the simulation results. All states in Figure 19 converge to zero except ψ and r. The control inputs are graphed in Figure 20, similar to the responses in Case 3.
For the control inputs, we sacrifice the yaw moment to save other states. Hence, ∆M ψ is maintained in a state of divergence, whereas ∆T t , ∆M φ , and ∆M θ function normally. The rotational speeds of the six motors are presented in Figure 17. The speeds of Motors #1, #3, and #5 are zeros, and others increase their speeds to reshape the thrust and torques.

Controllable Initial Condition
As aforementioned, this section is merely to verify our algorithm, because it is very unlikely for a hexacopter to fall into this initial condition subject to motor failure in a real flight. The controllable initial condition set is provided in Section 4.7.1.
In this simulation, (x 0 1 , · · · , x 0 5 , x 0 7 , · · · , x 0 11 ) are identical to the aforementioned initial conditions. However, x 0 6 is obtained from the corresponding element of x 0 3 r 3 135 . Similarly, x 0 12 is obtained from the corresponding element of x 0 9 r 9 135 . The state responses are shown in Figure 22. All states converge to zeros, including ψ. Figure 23 shows the control response. ∆T t , ∆M φ and ∆M θ are generated to control the system, whereas ∆M ψ maintains zero due to the failure of the motors. One can see that ψ is controllable even thought the system has zero ∆M ψ . The rotational speeds of six motors are presented in Figure 24.

Formulation of Nonlinear Controller
In our previous analysis, most cases are uncontrollable for yawing motion. At the nonlinear level, attitude dynamics is coupled. As a result, uncontrollability of yawing motion may eventually cause divergence of the whole vehicle. This section intends to qualitatively understand the validity of our algorithm with numerical examples.
The flow chart for simulations of nonlinear system is presented in Figure 25. The simulations are divided into two parts: one part simulates the nominal trajectory, (i.e., the hovering states in this research); the other part simulates the actual trajectory. The control gain obtained from linearized system is employed in the nonlinear system directly. The state offset is determined by ∆x = x −x, where the over bar denotes nominal states or nominal control. In this simulation, the hexacopter is to track the nominal trajectory, leading to the reference command ∆u r =ū −ū = 0. In the simulations, the initial conditions of the nominal trajectory are set as the hovering state. Without loss of generality, we letx =ȳ =z = 0. Because the values of (x,ȳ,z) do not affect the simulation results, this setting helps to clearly display the propagation of the position offset in the actual response. The differential equations are the original nonlinear EOMs in Equations (A1)-(A12). ∆x 0 is the initial condition vector used in the simulations of linearized cases. Moreover, only four of the seven cases are partly controllable. Among the four cases, Case 1 and Case 2 are identical whereas Case 3 and Case 5 are similar. Therefore, we only present the simulations of Case 2 and Case 3 as examples.

Case 2 as an Example
In Section 5.3, ψ remains constant and r converges to zero due to the lack of yawing control. Other states are stabilized and converge to zeros as expected. Figures 26-28 present the simulations of nonlinear response under identical initial offset as in Section 5.3.
In the linear level, states are decoupled. Nonconvergence of ψ does not influence other states. In nonlinear level, all states are coupled. To control the position, nonconvergence of ψ causes small oscillation of φ and θ, leading to wobbling of the hexacopter. The feedback of wobbling furthermore causes the divergence of ψ gradually, implying that the hexacopter spins. This is different from linear response. Except for uncontrollable yawing motion, other states are controllable, the hexacopter is roughly maneuverable, and it can be landed safely. One can see this phenomena in a real flight video [28].

Case 3 as an Example
In Section 5.4, ψ diverges very fast due to unbalanced yawing moment. This is the cost for the controllability of other states at the linear level. However, uncontrollable yawing motion at the nonlinear level may cause problems in controlling the whole hexacopter in real flight.
Figures 29-31 present the simulations of nonlinear response under identical initial offset as in Section 5.4. From the simulations, one can see that ψ diverges even more severely at the nonlinear level, implying that the hexacopter spins considerably. However, despite small oscillations in the planar motion and some offset in the z-direction, the position of the hexacopter is quite steady. This implies that, by applying our algorithm, the hexacopter must spin sharply, wobble, move around the hovering position, and move slightly higher or lower after Motors #1, #3, and #5 are lost. Although this may appear somewhat scary, the hexacopter is maneuverable and can be landed safely. Perhaps this scenario is too difficult for a human pilot to handle; we did not find any real-flight clips that featured human pilots managing such emergencies.

Conclusions
This paper proposes a control allocation algorithm for hexacopters subject to motor failure during flight. More specifically, a hovering hexacopter is considered in the algorithm. The main goal of this paper is to create states that allow the pilot to gain limited control of the hexacopter and perform emergent landing. Potential cases of motor failure include failure of one, two, or three motors, leading to seven scenarios. Failure of more than three motors is uncontrollable, and, hence, out of the scope of this paper. To avoid from change of control or control gain, which may require additional effort during flight, this research solves the motor failure problem by retaining the previous allocation of the control gain but reallocating the rotational speeds. Specifically, the following results are presented: (a) an allocation matrix is proposed to redistribute the control forces so that it is possible to regain (limited) controllability without modifying control gain; (b) seven cases are studied to analyze their respective controllability; (c) numerical simulations in both linearized dynamics and original dynamics also verify the derived results. According to the derivation and simulations, it has been proven that 1. the pilot is able to regain controllability of states other than yawing motion when two opposite motors have failed; 2. for the case with only one failed motor, the best strategy is to turn off the opposite motor and perform the same maneuver as in the previous scenario; 3. for the case with two failed motors with one working motor in between, the pilot is able to regain controllability of states other than yawing motion. In this scenario, however, the hexacopter tends to spin and wobble severely. 4. for the case with three failed motors with one working motor in between, the pilot is able to regain controllability of states other than yawing motion. Similar to the previous scenario, the hexacopter tends to spin and wobble severely. 5. for other cases, it is very markedly difficult for the pilot to regain controllability and safely land the hexacopter.

Future Work
At the current stage, this paper focuses on the study of the allocation algorithm and the verification of the algorithm through numerical simulations. In the future, some perspective studies are considered, such as implementation of the algorithm in a hexacopter, development of allocation algorithm in a tilted-rotor craft, generalization of this study to cruise states, and so on.

Conflicts of Interest:
The authors declare no conflict of interest.