Quadrotor Control for Tracking Moving Target, and Dynamic Obstacle Avoidance Based on Potential Field Method

The purpose of this paper is obstacle avoidance and moving target tracking for a quadrotor. Solving the obstacle crossing problem for the quadrotor includes two parts. The first part is controlling the attitude and position. The second part is path planning to pass obstacles. In this paper, the attitude and position of the quadrotor are controlled by super-twisting sliding mode control (SMC) and non-singular terminal super-twisting SMC. The simulation results of these two methods were compared. In the non-singular terminal ST-SMC method, the convergence time was approximately 5% less than the super-twisting SMC method. Also, the non-singular terminal ST-SMC method has more ability to remove disturbances. Because of the better results, the non-single terminal ST-SMC was used to control the position and attitude of the quadrotor to cross obstacles and track the target. In the second step, to cross obstacles, the potential field path planning algorithm is used. This method is a combination of attraction towards the target and repulsion from obstacles. The results of the simulation of crossing the obstacles were presented in four missions. In the first mission, the obstacles and the target are static, and in the second mission, the obstacles are static, and the target is moving. In the following, the obstacles and the target are dynamic; in the last mission, a combination of static and dynamic obstacles is considered, and the target is moving. The simulation results of four missions show that the quadrotor does not hit obstacles and reaches the desired goal, till the applied method is successful. doi: 10.5829/ije.2023.36.10a.01


INTRODUCTION 1
During the last decade, attention to autonomous robots has increased. Instead of predicting appropriate actions for all possible states in the algorithm, robots are programmed in such a way that by having a certain level of intelligence to perform the desired action in a special situation, they can make decisions on their own [1,2]. An essential aspect of intelligence in designing a robot's path is identifying obstacles and avoiding them in an unknown environment.
Solving the obstacle avoidance problem for flying robots includes two steps. In the first step, the position and attitude are controlled, and in the second step, path planning is applied to pass the obstacles.
Because of the nonlinear dynamics of the quadrotor, nonlinear methods are used to control the position and *Corresponding Author Institutional Email: toloei@sbu.ac.ir (A. Toloei) attitude of the quadrotor. Due to the ability to overcome namic nonlinearities and eliminate disturbances and low sensitivity to system parameter changes and disturbances, and no need for accurate modeling, the sliding mode method is often used for the quadrotor system [3][4][5]. In the nonlinear approach was used to stabilize the quadrotor, and the controller was verified through simulation and experimental [3]. Karami et al. [5] presented an inner and outer loop control where sliding mode control was applied in both loops. In the SMC method is used to control the UAV [6]. The results showed the success of the applied method, but the chattering phenomenon has not been removed in this work. Matouk et al. [7] presented a second-order SMC controller to control the attitude and position of the quadrotor. The effect of external disturbances has been ignored. Noordin et al. [8] also used SMC to control the position and height of the UAV. In this research, external disturbances were ignored and the sat function was used to remove the chattering phenomenon.
In this paper, to remove chattering, super-twisting SMC controller and super twisting nonsingular terminal SMC are used to control the system. Also, the role of the controller in reducing the effect of disturbances is considered.
Path planning methods for obstacle avoidance are placed in two categories. The first category deals with routing in the presence of static obstacles, and the second method examines passing dynamic obstacles. A* Algorithm, Genetic Algorithm, Differential Evolution, Ant Colony Optimization, and Particle Swarm Optimization are in the first category. Algorithm A* is an important algorithm in dealing with static obstacles. This method considers the heuristic search of the path to pass the obstacles according to the shortest path. The most important advantage of this method is direct search. The problems of this method are the high amount of calculations and the lack of guarantee the optimal solution [9,10]. Through direct action on the object, the genetic algorithm can obtain search space without determining rules [11,12]. The most important feature of this method is the strong global search, and defect of this method is poor stability. The advantages and disadvantages s of another path planning method to avoid obstacles, Differential Evolution, are similar to the genetic algorithm, but in this method, the probability of mutation is higher [13]. In the ant colony algorithm method, the behavior of an ant is used to show a practical solution to the path optimization problem [14]. This method has high efficiency, but the speed of convergence is slow in the early stages. In the particle swarm optimization method, the search time is fast, but the convergence speed in the next steps is slow [15]. Various path planning methods have been applied to avoid dynamic obstacles, for example, Fuzzy Logic Algorithm, Neural Network, Rapidly-exploring Random Trees, Artificial Potential Field, Neural Network, Deep Reinforcement Learning, and Reinforcement Learning. The problems of the Rapidly-exploring Random Trees method are high space for calculations and poor real-time performance, but it has a high ability to search [16]. In the Fuzzy logic algorithm, the volume of calculations is small, but it relies on highly specialized knowledge [17]. Among the advantages of Neural Network, we can mention strong learning ability and simple learning rules, but this method has disadvantages, such as long training time and difficulty obtaining samples [18]. In deep reinforcement learning, the dimensions are reduced, and the training time is long [19]. Among the methods of avoiding collision with obstacles, the virtual potential field method is more used in the aerospace industry. The advantages of this method are simple structure, good real-time performance, fast path planning speed. The obstacle crossing for the quadrotor with disturbance was presented by Zhao et al. [20]. In this article the obstacles are assumed to be static. Kondo and Tsuchiya [21] used the potential field method to create sequential paths to pass through dynamic obstacles. In this article, the target is considered static. Yan et al. [22] defined variables such as speed and relative acceleration and discussed crossing obstacles based on the improved potential field. The obstacles in this article are static, and the target is dynamic. In the artificial potential method, a factor was added to the repulsion function to avoid the local minimum problem [23]. This research is limited to twodimensional environments.
In previous works, it has not been investigated the non-collision of dynamic and static obstacles with moving target tracking simultaneously. In this paper, quadrotor control in an environment with dynamic and static obstacles with moving target tracking is discussed. In the first part, the quadrotor dynamic modeling is given. Attitude and position control is done by the SMC method. In the following, the comparison of super twisting controller and the super twisting nonsingular terminal SMC has been discussed. In the next section, the obstacle avoidance of the quadrotor with static obstacles with a fixed target, and the obstacle avoidance with moving obstacles and target are discussed. At the end, the combination of fixed and moving obstacles with a dynamic target is investigated. Finally, the simulation results are presented.

DYNAMIC MODEL OF QUADROTOR
The dynamic model of the quadrotor can be obtained in two ways: Newton-Euler and Euler-Lagrange [24]. Here the six degrees of freedom model is obtained according to the Newton-Euler method. The following equation introduces the total rotors velocity and the rotor velocity vector: where ( 1 , 2 , 3 , 4 ) are the speeds of the four rotors.
The following equation shows the effect of the motion vector on the quadrotor dynamics.
where is the length from the center of mass to each rotor, is the thrust force coefficient, and is the drag force coefficient. The matrix , which represents the motion matrix multiplied by the locust velocity square 2 and produces the motion vector ( ), is defined as follows. ( The quadrotor dynamic equations are as follows: In these equations, , the moment of total rotation of inertia about the rotor axis, (U, V, W) the speed vector of the quadrotor, (P, Q, R) roll, pitch, and yaw, and , , and are the moments of inertia in the x, y, and zaxis, whose values are given in Table 1.
Also, the rotors speed inputs 1 , 2 , 3 , and 4 are obtained from the following equations:

SLIDING MODE CONTROLLER
The SMC method is recognized as one of the efficient approaches to design controllers for nonlinear dynamic systems. The main advantage of SMC is low sensitivity to changes and disturbances of system parameters, which eliminates the need for detailed modeling. SMC reduces the complexity of feedback design. In the following, the design of two SMC methods has been discussed.

1. Super Twisting Smc
ST-SMC is designated to decrease the chattering phenomena for a quadrotor with a relative degree of one. The variable dynamics of the sliding surface are [3]: With limited conditions: So that Γ , Γ , and Φ are positive constant values. Control inputs in ST-SMC are designed as follows: where: The convergence conditions are stated in the following equation : For ρ = 1, the algorithm converges exponentially to the origin. For the systems where 0 = ∞ and there is no limitation in control, the algorithm can be simplified as follows: The control inputs consist of two parts [16]: equivalent part and reaching one as: where is obtained by setting the sliding surface derivative equal to zero, and satisfies the Lyapunov stability condition of the sliding surface. Finally, the control commands are obtained as follows:  (12), and Figure 6 represents the attitude of the quadrotor using ST-SMC. The control parameters are prearranged in Table 2.
As it is clear from Figures 1 and 2, the sliding surfaces of position and attitude converge to zero in less than 0.8 seconds which is a favorable time.
In Figures 3 and 4, the control commands of the quadrotor are shown, which show that the chattering phenomenon did not occur and there is no strong oscillation. In addition, the convergence to zero happened in about 2 seconds which is a favorable time.     Figure 5 shows the state of the quadrotor where the angles ( , , ) have converged in less than 2 seconds, and overshoot and overshoot is less than 5%. Figure 6 shows the position of the quadrotor in 3D space, which shows that it has tracked the reference path well. In this figure, the reduction of the effect of disturbances using the ST-SMC method is shown.
The simulation results of ST-SMC indicate the success of the applied method. However, in order to obtain better results, the non-singular terminal super-twisting SMC will also be applied in the next section.

2. Nonsingular Terminal Super Twisting Smc
The purpose of the terminal SMC is to reduce the sliding surface convergence time to zero. For this purpose, the sliding surface is considered as follows [25,26]: where; and are constant and positive numbers. Considering the following control: where > 0, the surface (13), and the 1 and 2 will converge to zero in finite time.
Proof. The nonlinear system is considered as follows: where ( ) is the uncertainty or disturbance of the system.

( ) ≤
where is the maximum disturbance and is a positive number. According to Equation (13) For > 0 , ̇2 ≤ and for < 0 , ̇2 ≥ , showing that 2 = 0 is not an attractor and there is a neighborhood of 2 = 0 such that for a > 0 as | 2 | < , there exist ̇2 ≤ − for > 0 and ̇2 ≥ for < 0.
The crossing from 2 = to 2 = − for > 0 , and from 2 = − to 2 = for < 0 happens in a limited time. If | 2 | > , from Equation (16) we get switching line = 0 in finite time because ̇2 ≤ − for > 0 and ̇2 ≥ for < 0. As a result, the sliding sliding mode = 0 is obtained from any point of the finite time. Therefore, the sliding surface Equation (13) is obtained Disturbances in the finite time, and states will reach zero in the finite time. As a result, the proof is completed.
In this controller, like the ST-SMC controller is obtained by setting the sliding surface derivative equal to zero, and satisfies the Lyapunov stability condition of the sliding surface. Therefore, the control inputs for the quadrotor were achieved as follows: The reach time is obtained by setting the derivative of the sliding surface equal to zero: where is the time that reaches zero. Table 3 shows the values .
In Figure 7, it is clear that the sliding surfaces of the position reach zero at the desired time. The convergence of ( , , ) is at 0.09, 0.0145, and 0.02 seconds, respectively.
In Figure 8, the slide surfaces of the attitude are presented. The time to reach zero ( , , ) is 0.45,  0.23 and 0.051, respectively, which is a favorable convergence time. Figure 9 shows the control commands. As it is known, the chattering phenomenon did not happen in the commands.  Figure 10 shows the control commands. Chattering phenomenon is not observed in these commands and the convergence has happened at the favorable time. Figure 11 shows the attitude of the quadrotor. In this figure, extreme fluctuation is not observed and the convergence ( , , ) happened in 1, 0.7, and 1.5 seconds, which is acceptable. Figure 12 shows the position of the quadrotor in the spiral path in 3D. ( , , ) track the reference path well. This figure shows the reduction of the disturbance effect by the applied controller.
The simulation results of both super-twisting SMC and nonsingular terminal super-twisting SMC controllers showed that the two controllers had eliminated the chattering phenomenon. In both controllers, the convergence time of the attitude and position is favorable, but the convergence time is less in the nonsingular terminal super twisting controller. This controller is more capable of reducing the effects of disturbances. Also, the results of these two controllers were compared with data reported in literature [27], which showed that the convergence time is higher in the controller discussed by Habibi et al. [27], and chattering also occurred in the control commands. Because of the better results of the nonsingular terminal ST-SMC, this method was applied to control the attitude and position of the quadrotor to cross obstacles. The control parameters are given in Table 4.

ARTIFICIAL POTENTIAL FIELD MODEL
Khatib [28] proposed the path planning artificial potential field (AFP). In AFP, the robot is assumed to be a point inside the potential fields. This method combines attraction towards the target and repulsion from obstacles. Figure 13 shows the AFP method, where T shows the target and O shows the obstacles.
The control of the plant by the potential field method is as follows : where, , , , respectively, represent the potential of attraction, the potential of repulsion, and the potential virtual field. Gradient functions are as follows: where is the attraction of the plant and is the force created by ( ), that leads to repulsion from the obstacle.
is directly related to the distance between the plant and the target. The attraction coefficient is considered, and the attraction potential field ( ) is as follows: In addition, ( ) is a positive continuous, and differentiable function, and the effect of this potential is Figure 13. Potential field method in the limited region around the barrier. As a result, the ( ) is: where 0 is the safe distance from the obstacles.
The potential algorithm for crossing obstacles is investigated in three missions. In the first mission, six obstacles were considered; their specifications are listed in Table 5. At this stage, the obstacles are considered static, and the target is fixed.
The simulation of quadrotor crossing obstacles in two dimensions is presented in Figure 14. As it is clear in this The simulation of quadrotor obstacles avoidance in three dimensions is presented in Figure 15. which shows that the quadrotor has successfully passed through the obstacles and reached the target.
In the second mission, as in the first mission, the obstacles are fixed, but the target is considered dynamic. Figure 16 shows the passage of the quadrotor through obstacles in two dimensions. In this figure, the quadrotor from the point (-10, -20) reaches the target at the point (10, 43) after passing the obstacles and moves with it to reach the point (5,43). The target moves from point (25,43) to point (5,43). These results show the success of the potential method. Figure 17 shows the crossing of obstacles in three dimensions, which shows the success of the AFP method. In the third mission, obstacles and targets are dynamic. The initial position of the obstacles is shown in Table 3, and the speed of the obstacles is shown in Table  6. Figures 18-23 show the passage of dynamic obstacles during the flight. Figure 18 shows the initial position of the quadrotor and the target. The initial position of the quadrotor is (-10, -20), and the initial position of the target is (45, 43). Figure 19 shows the position of the quadrotor after passing the obstacles during the flight. In this figure, the target has moved and reached the point (38, 43).

Figure 19.
Obstacle avoidance with dynamic obstacles and moving target while crossing obstacles Figure 20 shows the position of the quadrotor at the moment of reaching the target. The location of the target and the quadrotor is (36, 43). Figure 21 shows the movement of the quadrotor with the target at the end of the flight. The position of the quadrotor and target is (27,43). Figures 18,19,21,and 21 show the passage of the quadrotor past each obstacle from the beginning of the flight to reaching the target. Figure 22 shows the path of the quadrotor passing through moving obstacles and reaching the dynamic target in two dimensions. In this figure, the red line shows the movement path of the quadrotor, and the green dashed line shows the path of the target. Figure 23 also shows the path of the quadrotor passing moving obstacles and reaching the dynamic target in three dimensions. In the last mission, the obstacles are a combination of static and dynamic. The target in this mission is moving. The velocities of the obstacles are given in Table 7 Figure 23 shows the quadrotor crossing obstacles during flight. The position of the quadrotor in this figure is (10, 0) and the target is at the point (40, 43). Figure 25 shows the moment the quadrotor reaches the target. The position of the quadrotor and target is (35, 43). Figure 26 shows the crossing of dynamic and static obstacles and the movement of the quadrotor with the target.   Figure 28 presents dynamic and static obstacle avoidance and quadrotor movement with dynamic purpose in three dimensions.

TABLE 7. Obstacles velocity
As it is clear from Figures 14 and 15, the quadrotor has been able to pass through fixed obstacles and fixed targets in two and three dimensions. Figures 14 and 15 also show the path of crossing fixed obstacles in two and three dimensions with a moving target. Figures 18-21 show the successful passage of the quadrotor through the dynamic obstacles at the beginning and the end of the path. Figure 22 also shows the path of the quadrotor from the beginning of the flight to reaching the target and following it. Figure 23 also presents this path in three dimensions. Figures 23-26 also show the success of passing the obstacles during the flight. Figures 27 and 28 show this path in two and three dimensions, respectively. As a result, the simulation results show the success of the AFP method in passing dynamic and static obstacles and tracking the target.

CONCLUSION
In this article, the quadrotor crossing dynamic and static obstacles and target tracking in four missions are presented. Solving the problem of crossing obstacles has been done in two parts. The first part deals with controlling the position and attitude, and in the second part, the path planning to pass the obstacles is done using the artificial potential field method. In the first part, super twisting and nonsingular terminal super twisting were compared to control the position and attitude. Convergence time in nonsingular terminal super-twisting controller is less, and the effect of disturbances is reduced more. As a result, the non-singular terminal supertwisting method was used to control the attitude and position in crossing the obstacles. The simulation results of crossing the obstacles using the AFP method also showed that in the first mission, where the obstacles and the target were static, the quadrotor successfully crossed the obstacles and reached the target. In the second mission, where the obstacles were fixed, and the target was moving, the quadrotor crossed the obstacles and reached the target and moved along with target. The success of the applied method is evident in the third mission, which is the obstacles and target were dynamic. In the last mission, where the obstacles were a combination of static and dynamic and the target was moving, the quadrotor successfully crossed the obstacles and reached the target, and moved along with it. As a result, the simulations showed the effectiveness of the applied method.
In future articles, the method implemented in this article can be used in the formation flight of flying robots and maintaining continuity after crossing obstacles.