scieee AI-readable full text Open interactive document viewer

Motion planning and control of unmanned aerial vehicles

Carbó Cubero, Paula

Abstract

The emerging autonomous industry has recently allowed the fast and low cost production of unmanned aerial vehicles (UAVs). The autonomy of these robots could have plenty of applications in today's society.The first challenge, therefore, is making autonomous vehicles move around safely in dynamic environments and optimising the path they should follow. This project focuses precisely in understanding all the parts that have to come together in order to achieve this purpose. This is done by making a mathematical model for the UAV, a study of the sensors needed to estimate the UAV?s state, then designing a controller for the trajectory tracking and using an artificial potential field function for the navigation control. Computer simulations are performed to test the theoretical findings and evaluate the proposed methods. The last part of this thesis is an empirical study on how this project could be brought to real life, by means of implementing together all the parts studied separately in an UAV.

Full text

Universitat Polit` ecnica de Catalunya and Kungliga Tekniska H¨ ogskolan Bachelor’s Thesis Motion Planning and Control of Unmanned Aerial Vehicles A dissertation submitted to the Escola T`ecnica Superior d’Enginyeria de Telecomunicaci´o de Barcelona Universitat Polit`ecnica de Catalunya by Paula Carb´o Cubero In partial fulfillment of the requirements for the degree in TELECOMMUNICATIONS TECHNOLOGIES AND SERVICES ENGINEERING July 2, 2018 supervised by Christos Verginis Sandra Bermejo Abstract The emerging autonomous industry has recently allowed the fast and low cost production of unmanned aerial vehicles (UAVs). The autonomy of these robots could have plenty of applications in today’s society. The first challenge, therefore, is making autonomous vehicles move around safely in dynamic environments and optimising the path they should follow. This project focuses precisely in understanding all the parts that have to come together in order to achieve this purpose. This is done by making a mathematical model for the UAV, a study of the sensors needed to estimate the UAV’s state, then designing a controller for the trajectory tracking and using an artificial potential field function for the navigation control. Computer simulations are performed to test the theoretical findings and evaluate the proposed methods. The last part of this thesis is an empirical study on how this project could be brought to real life, by means of implementing together all the parts studied separately in an UAV. i Resum L’emergent ind´ustria aut`onoma ha perm`es recentment la producci´o r`apida i de baix cost de vehicles aeris no tripulats (UAV). L’autonomia d’aquests robots podria tenir una gran varietat d’aplicacions en la societat actual. El primer repte, per tant, ´es que els vehicles aut`onoms es moguin amb seguretat en entorns din`amics i que optimitzin el cam´ı que han de seguir. Aquest projecte se centra precisament en entendre totes les parts que s’han de reunir per aconseguir aquest objectiu. Aix`o es fa elaborant un model matem`atic per al UAV, un estudi dels sensors necessaris per estimar l’estat del UAV, dissenyant un controlador per al seguiment de traject`oria i utilitzant una funci´o de camp potencial artificial per al control de la navegaci´o. Les simulacions permeten provar les troballes te`oriques i avaluar els m`etodes proposats. L’´ultima part d’aquesta tesi ´es un estudi emp´ıric sobre com aquest projecte es podria portar a la vida real, mitjan¸cant la implementaci´o conjunta de totes les parts estudiades per separat en un UAV. ii Resumen La emergente industria aut´onoma ha permitido recientemente la producci´on r´apida y de bajo coste de veh´ıculos a´ereos no tripulados (UAV). La autonom´ıa de estos robots podr´ıa tener muchas aplicaciones en la sociedad actual. El primer desaf´ıo, por lo tanto, es conseguir que los veh´ıculos aut´onomos se muevan de forma segura en entornos din´amicos, optimizando el camino que deber´ıan seguir. Este proyecto se enfoca precisamente en comprender todas las partes que deben unirse para lograr este prop´osito. Esto se hace mediante un modelo matem´atico para el UAV, un estudio de los sensores necesarios para estimar el estado del UAV, luego dise˜nando un controlador para el seguimiento de trayectoria y trabajando con una funci´on de campo potencial artificial para el control de la navegaci´on. Simulaciones permiten probar los hallazgos te´oricos y evaluar los m´etodos propuestos. La ´ultima parte de esta tesis es un estudio emp´ırico sobre c´omo este proyecto podr´ıa llevarse a la vida real, mediante la implementaci´on conjunta de todas las partes estudiadas por separado en un UAV. iii Acknowledgments I want to thank my supervisor at Kungliga Tekniska H¨ogskolan (KTH), Christos Verginis, for all the valuable help and advice during this project. I also want to thank my KTH colleage, Vilhelm Dinevik, for starting this project with me. Many thanks to my Universitat Polit`ecnica de Catalunya (UPC) supervisor too, Sandra Bermejo, for allowing me to choose the course of my thesis. Finally, thanks to my family and friends, specially Jordi Altay´o, for their immeasurable help and support during these months. iv Revision history, approval record and document distribution list Table 1: Revision history. Revision Date Purpose 0 01/04/2018 Document creation 1 29/04/2018 Document revision. Changes proposed to KTH report by Christos Verginis. 2 21/05/2018 Document revision. KTH report approval by Christos Verginis. 3 05/06/2018 Document revision. Extension of the report. 4 02/07/2018 Document revision. UPC approval by Sandra Bermejo. Table 2: Document distribution list. Name e-mail Paula Carb´o Cubero paulacarbocub[email protected] Vilhelm Dinevik [email protected] Christos Verginis cv[email protected] Sandra Bermejo [email protected] Table 3: Document summary. Written by: Reviewed and approved by: Date: 02/07/2018 Date: 21/05/2018 Name: Paula Carb´o Cubero Name: Christos Verginis Position: Project author Position: Project supervisor at KTH Date: 02/07/2018 Name: Sandra Bermejo Broto Position: Project supervisor at UPC v Contents 1 Introduction 1 1.1 Background............................................ 1 1.2 Context and statement of purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Quadcopter modelling 3 2.1 Overview ............................................. 3 2.2 Kinematics ............................................ 3 2.3 Dynamics ............................................. 5 3 Trajectory tracking 7 3.1 Linearquadraticregulator.................................... 7 3.2 EnhancedPIDforhovering ................................... 9 4 Multi-UAV navigation controller with collision avoidance 11 4.1 Artificialpotentialfields..................................... 11 4.2 Localminimaproblem...................................... 13 5 MatLab simulations for the controllers 14 5.1 LQR performance as a tracking controller . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.2 Potential fields performance as a navigation controller . . . . . . . . . . . . . . . . . . . . 15 6 Sensor modelling and feedback 18 6.1 Inertial Measurement Unit - GY-85 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1.1 Triple axis accelerometer - ADXL345 . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.1.2 Triple axis gyroscope - ITG3205 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.1.3 Triple axis magnetometer - HMC5883L . . . . . . . . . . . . . . . . . . . . . . . . 19 6.2 Global Positioning System (GPS) receiver - ublox NEO 6M . . . . . . . . . . . . . . . . . 19 6.3 Infrared sensors - Sharp GP2Y0A02YK0F . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.4 Ultrasonic sensors - HC-SR04 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.5 Bluetooth module - AT-09 BLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6.6 Sensorfusion ........................................... 22 7 BLDC motor and electronic control 23 7.1 Choosing the BLDC motors, Electronic Speed Controller (ESC)s and battery . . . . . . . 24 8 ATmega2560 microcontroller unit 25 8.1 Pulse Width Modulation (PWM) generation with 16-bit timer . . . . . . . . . . . . . . . . 25 9 UAV design 26 9.1 3Dprintedbody ......................................... 26 9.2 Printed Circuit Board (PCB)design .............................. 27 10 Discussion, conclusion and future development 29 11 Budget 31 Terms and Abbreviations 32 vi List of Figures 1.1 Complete control loop diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.1 Quadrotor with propellers and the two reference frames. . . . . . . . . . . . . . . . . . . . 3 2.2 Euler angles φ, θ, ψ......................................... 4 3.1 Block diagram for individual quadrotor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2 PID diagram for height control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3 PID diagram for roll control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.4 PID diagram for pitch control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.5 PIDdiagramforyawcontrol. .................................. 10 5.1 Step response for the Euler angles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.2 Step response for angular velocities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.3 Step response for linear velocities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5.4 Stepresponseforpositions. ................................... 15 5.5 Environment from first perspective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5.6 Environment from second perspective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5.7 Environment from third perspective. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 5.8 Distance from vehicles’ surface to any other obstacle’s surface. . . . . . . . . . . . . . . . 16 5.9 Distance from vehicles to their respective goal. . . . . . . . . . . . . . . . . . . . . . . . . 16 5.10Velocitiesforeachvehicle..................................... 16 5.11 Multi-Unmanned Aerial Vehicle (UAV) avoidance case. . . . . . . . . . . . . . . . . . . . 17 5.12 Distances to the other UAVs’ surfaces from the vehicle’s surface in the multi-UAV avoidancecase. ............................................. 17 5.13Localminimascenario....................................... 17 5.14 UAV’s velocity for the local minima scenario. . . . . . . . . . . . . . . . . . . . . . . . . . 17 6.1 GY-85 Inertial Measurement Unit (IMU)module. ...................... 18 6.2 UbloxNEO6MGPSreceiver................................... 19 6.3 Infrared obstacle detection diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.4 Sharp GP2Y0A02YK0F infrared module. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.5 Ultrasonic obstacle detection diagram [Hirata et al., 2008]. . . . . . . . . . . . . . . . . . . 21 6.6 HC-SR04 ultrasonic obstacle detection module . . . . . . . . . . . . . . . . . . . . . . . . 21 6.7 AT-09bluetoothmodule. .................................... 22 7.1 BLDC motor diagram [Renesas, ]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 9.1 Design for 3D printed UAV from isometric view. . . . . . . . . . . . . . . . . . . . . . . . 26 9.2 Design for 3D printed UAV from top perspective. . . . . . . . . . . . . . . . . . . . . . . . 27 9.3 Proposed PCB for the electronic circuitry. . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 vii List of Tables 1 Revisionhistory. ......................................... v 2 Documentdistributionlist. ................................... v 3 Documentsummary........................................ v 11.1 Estimated budget for components and materials. . . . . . . . . . . . . . . . . . . . . . . . 31 viii Chapter 3 Trajectory tracking Since the UAV will need to follow a certain path given by a high-level navigation controller, there is the need to implement a low-level controller, a tracking controller, so the UAV moves as fast and smooth as possible to reach the desired state. The whole system in this project could be described with a block diagram as the one pictured in Figure 3.1, that has already been seen before. Navigation Control Tracking Control System u Measurements r e y − x Figure 3.1: Block diagram for individual quadrotor. Where ris our reference signal, ideally obtained from a path planning algorithm for navigation, and uis the tracking control output. The first control strategy to use is LQR, a feedback controller that is able to optimise a certain cost function to provide optimal control. This also requires more computing power, therefore another control method is studied, an ehanced version of a simple PID controller, that could be easily implemented in the microcontroller chosen for the real life version of this project. 3.1 Linear quadratic regulator The first tracking controller studied during this thesis uses a linear quadratic regulator to achieve optimal control. For the simulations to be more simple, the system dynamics used were up to Equation (2.11) and Equation (2.12), and the control action is therefore considered as in Equation (3.1). u=ftτxτyτzT(3.1) Where ft[N] is the total force and τx,τyand τz[N m] are the torque in each of these directions, expressed in the body frame. The mathematical model up until Equation (2.12) can be expressed as a nolinear function according to Equation (3.2). ˙x=f(x,u) (3.2) And it has to be linearised and expressed on the linear state space form as seen in equations (3.3) and (3.4), according to [Sabatino and Johansson, 2015]. ˙x=Ax +Bu (3.3) 7 y=Cx (3.4) First of all, an equilibrium point has to be chosen for the system to be linearized around it, ˆ x(t) and ˆ u(t) will be these equilibrium points for the state and the control input. With the model described in Equation (2.9), Equation (2.11) and Equation (2.12), the matrixes Aand Bfrom Equation (3.3) can be calculated thanks to a first Taylor order approximation for Equation (3.2), as in Equation (3.5) and Equation (3.6). A=δf(x,u) δxx=ˆ x u=ˆ u (3.5) B=δf(x,u) δux=ˆ x u=ˆ u (3.6) For the Cmatrix, we can consider that all the variables that form the state vector from Equation (2.10) can be measured, therefore it can simply be the identity matrix. With the model rewritten according to Equation (3.3) and Equation (3.4), we verify that all the states of the system are both observable and controllable. In order to check the observability and controllability of the system two matrices Oand Cdefined as following. O=          C CA CA2 CA3 . . . CA11          ∈R(3.7) C=B BA BA2BA3· · · BA11 ∈R(3.8) The system is controllable and observable if Cand Ohave full rank. The controller used in this section is, as mentioned above, an LQR. It utilises a cost function and minimises said cost function to optimise the controller [Glad, 2006]. This tracking controller requires two weight matrixes, Qand R, that will allow some fine-tuning when taking into account the main parameters of the controller’s time response, such as the overshoot, the rise time or the settling time. Q=CTCα1(3.9) Where α1is a scaling factor for the Qmatrix. The Qmatrix and the identity matrix Rare then implemented into the following cost function J. J=Z∞ 0 (xT(t)Qx(t) + uT(t)Ru(t))dt (3.10) Jis then minimised to obtain the optimal LQR controller Kwith the given α1. This gives us the linear state feedback in Equation (3.11). u(t)=−K[x(t)−r(t)] (3.11) where Kcan be written as K=R−1BTS(3.12) 8 Sis, as stated in [Bresciani, 2008], the solution of the Riccati’s algebraic equation: SA +ATS−SBR−1BTS+CTQC = 0 (3.13) The motivation behind using a LQR, is that it usually has a small steady-state errors[Argentim et al., 2013]. It would be reasonable to focus on getting the deviations from the optimal track to be as small as possible, hence minimising the error. 3.2 Enhanced PID for hovering A different control method has also been studied so it can be easily implemented in the real life project, since the microcontroller’s computing power is not excessively high and the UAV will not be expected to do fast and accurate maneuvers. A simple PID code can be used to guarantee the control of four variables from the final modelling of the system in Equation (2.20). Since the objective for the real life UAV is for it just to hover, the chosen variables to be controlled are the three Euler angles φ,θand ψ [rad] and height z[m] [Bresciani, 2008]. The hovering condition for the UAV implies that the Euler angles φand θ(roll and pitch) will be low at all times. This also makes the transfer matrix TΘ(φ, θ) from Equation (2.7) really close to the identity matrix, therefore the angular velocity in the body frame ωBand the Euler rates in the Earth frame ˙ηEwill be practically the same. This is why the angular accelerations will be directly considered as the Euler angle accelerations. Assuming all these conditions, Equation (2.20) can be simplified in the dynamics of the system that will be finally used for the PID control in Equation (3.14) [Bresciani, 2008].                  ¨z=−g + cos θcos φU1 m ¨ φ=U2 Ixx ¨ θ=U3 Iyy ¨ ψ=U4 Izz (3.14) The PID control technique is based on scaling, deriving and integrating an error over time to obtain the control output signal that should be sent to the actuators of the system. By knowing de desired state of the variables zd,φd,θdand ψd, the error between these and their real measured value can be calculated. In chapter 6, the sensors that are able to measure this state are studied. Four independent PID structures are used to control each of the control output vector variables, as can be seen in Figure 3.2, Figure 3.3, Figure 3.4 and Figure 3.5. These structures are not regular PID structures, because they integrate some specific modules, like a mixer of the measured zvalues to estimate more accurately the height of the UAV, and a saturation block to limit the integrator action as to avoid nonlinear behavior of the system (integral wind-up) [Bresciani, 2008]. The constant values Ki,Kpand Kzare the constants that allow fine-tuning of the algorithm. Mixer Kp z Ki z Kd z SAT 1 s s m cos φcos θ z+U1 zIR zSONAR g + zd − − + + + ez Figure 3.2: PID diagram for height control. 9 Kp roll Ki roll Kd roll SAT 1 s s Ixx φ+U2 + φd − − + eroll Figure 3.3: PID diagram for roll control. Kp pitch Ki pitch Kd pitch SAT 1 s s Iyy θ+U3 + θd − − + epitch Figure 3.4: PID diagram for pitch control. Kp yaw Ki yaw Kd yaw SAT 1 s s Izz ψ+U4 + ψd − − + eyaw Figure 3.5: PID diagram for yaw control. After the values of the control vector U1,U2,U3and U4have been found, the inverted movement matrix from Equation (3.15) can be used to know the equivalent rotational speed every motor should acquire so the desired state for the Euler angles and height is reached.                  Ω2 1=1 4bU1−1 2b l U3−1 4dU4 Ω2 2=1 4bU1−1 2b l U2+1 4dU4 Ω2 3=1 4bU1+1 2b l U3−1 4dU4 Ω2 4=1 4bU1+1 2b l U2+1 4dU4 (3.15) 10 Chapter 4 Multi-UAV navigation controller with collision avoidance This chapter studies one method to find the optimal path to follow from an initial position to a goal. In the case presented in this paper, we consider multiple UAVs flying towards their respective goals, in an environment filled with obstacles. Some proposed graph-search methods to solve this problem are Rapidly-exploring Random Tree (RRT) algorithms or A* search algorithms and other Dijkstra extensions. Nonetheless, these techniques do not perform very well when the test environment is constantly changing. These methods excel at finding the appropriate path to follow in a labyrinth-like environment. However, if the environment is different in every iteration, these algorithms are inefficient since the UAV may end up following an inefficient path [M. Lavalle, 1999, Yershov and LaValle, 2011]. Another way of dealing with this specific problem is based on artificial potential fields, which is used in this report. We choose this method because it is a simple and efficient algorithm that can navigate the UAV to its goal. It provides a closed form solution, therefore it is computationally efficient. With this technique a high computational speed and an optimised path can be achieved, with simple and elegant calculations[Ge and Cui, 2002]. The main objective in this chapter is to provide an efficient solution for multi-UAV navigation while avoiding collisions with each other and the obstacles in the environment. 4.1 Artificial potential fields Artificial potential fields consist of the sum of an attractive and a repulsive potential. In this case the goal generates the attractive potential and the obstacles generate repulsive potentials. This will determine the motion of the UAV by following the negative gradient of the potential field. In our case we have a random number of vehicles vi∀i∈ {1, ...N}, each with its respective goal gi∀i∈ {1, ...N}, and also a random number of obstacles oj∀j∈ {1, ...M}. All the vehicles and obstacles are modelled as spheres. All UAVs have the same radius ri=r, while obstacles have different radiuses Rj. We can define a new variable qi=xiyiziTwith the linear position of one UAV, of a goal with qgoal,i and of an obstacle with qobst,j. The distances from the center of a UAV to a goal or an obstacle are calculated with the Euclidean norm, according to (4.1) and (4.2) respectively. In the calculation of the distance to an obstacle, the radius of the object is taken into account, if it is an obstacle or another UAV (4.3). ρgoal,i(qi,qgoal,i) =kqi−qgoal,ik(4.1) ρobst,i,j(qi,qobst,j, a) =kqi−qobst,jk − a(4.2) a∈ {Rj, r | ∀j}(4.3) The repulsive and the attractive potentials are calculated according to [Amato, 2004], and are de- 11 scribed by equations (4.4) and (4.5) respectively. Uatt,i(qi,qgoal,i) =    1 2ξ1ρ2 goal,iif ρgoal,i≤d dξ2ρgoal,iif ρgoal,i> d (4.4) Urep,i,j(qi,qobst,j, a) =    1 2η(1 ρobst,i,j−1 ρ0) if ρobst,i,j≤ρ0 0 if ρobst,i,j> ρ0 (4.5) The dparameter is the distance from the goal where the attractive function changes from a conic to a parabolic well configuration. The constant ρ0is the sensing radius of the UAV. Finally, ξ1,ξ2and η are positive scaling factors that allow potential adjustment. The potential fields’ desired force on the UAV is calculated by (4.6), since the negative gradient of a potential field −∇Uis a vector that points in the direction of steepest descent. ~ F(q) = −∇U(q) (4.6) This leads to (4.7) and (4.8), that show how these repulsive and attractive forces are calculated. ~ Fatt,i(qi,qgoal,i) =    −ξ1(qi−qgoal,i) if ρgoal,i≤d −dξ2(qi−qgoal,i) kqi−qgoal,ikif ρgoal,i> d (4.7) ~ Frep,i,j(qi,qobst,j, a) =      η(1 ρobst,i,j−1 ρ0)( 1 ρ2 obst,i,j )(qi−qobst,i,j) kqi−qobst,i,jkif ρobst,i,j≤ρ0 0 if ρobst,i,j> ρ0 (4.8) There are two reasons for splitting the attractive potential and force functions into two parts. In the case of a parabolic configuration for all the space, there is a linear dependence on the force with the distance between the UAV and the goal, hence the force grows indefinitely when the UAV is far from the goal. At the same time, in the case of a conic configuration for all the space, there is a singular point in the goal that could make the UAV oscilate around it. The solution is to combine both configurations, by making the force constant when far from the goal with a conic configuration, and then using a parabolic function when reaching the goal to avoid the singularity. When a UAV is moving, it also considers other vehicles as obstacles, if these are inside the UAV’s sphere of influence. This means that for each UAV i∈ {1, ...N}we can define an associated set Ni={k∈ {1, ...N}:kqi−qkk ≤ ρ0}. Finally, the repulsive and attractive potentials and forces are added, according to (4.9) and (4.10), in order to obtain the total potential field and force. Utotal,i=Uatt,i(qi,qgoal,i) + X ∀j Urep,i,j(qi,qobst,j, Rj) + X ∀k∈Ni Urep,i,k(qi,qk, r) (4.9) ~ Ftotal,i=~ Fatt,i(qi,qgoal,i) + X ∀j ~ Frep,i,j(qi,qobst,j, Rj) + X ∀k∈Ni ~ Frep,i,k(qi,qk, r) (4.10) To simplify the simulations, first order dynamics are assumed for the quadcopter model. This means that the control signal u(t) can be estimated as the velocity obtained from the negative gradient of the potential, as can be seen in (4.11). ui(t) = ˙qi(t) = −∇Utotal,i(qi(t)) (4.11) 12 4.2 Local minima problem The potential fields method has some clear limitations. The most important problem to solve is the local minima situation, where a vehicle can get stuck and therefore never arrive at its goal. This means that ~ Ftotal,i= 0 for some i(4.12) and ~ Fatt,i(qi,qgoal,i)6= 0 for some i(4.13) Since the attractive force is not zero, the vehicle has not arrived to its goal yet. However, the force acting on it is zero, meaning that it will not move, the potential will be the same, and the force will not change either. Local minima situations occur when the obstacle percieved by the Unmanned Aerial Vehicle (UAV) is symmetric inside its sphere of influence, therefore the attractive and the repulsive forces cancel each other. The vehicle getting stuck is not an option in a real case scenario, therefore local minima situation should be avoided by combining potential fields with another algorithm or function that acts differently when detecting this configuration. There are some other problems, for example the difficulty of passing between closely-spaced obstacles or inherent oscilations in the trajectory when near obstacles, as stated by Koren and Borenstein in [Koren and Borenstein, 1991]. 13 Chapter 5 MatLab simulations for the controllers Both the LQR controller developed in chapter 3 and the multi-UAV navigation controller studied in chapter 4 have been implemented in MatLab to test their validity and performance with respect to what was expected. 5.1 LQR performance as a tracking controller For the trajectory tracking we constructed the linear state-space equations of the mathematical model in a MatLab script using the initial starting position as the equilibrium point. The equations described in section 3.1 for controllability and observability were then used to ensure that the system was observable and controllable. MatLab tools were used to design a LQR with Ras an identity matrix and the scaling factor α1for Qset to 50. The step responses of the system were analysed, which produced the results shown in Figure 5.1, Figure 5.2, Figure 5.3 and Figure 5.4 where one can see that the steady state error is zero for all step responses, which was the main objective for the trajectory tracking part. Figure 5.1: Step response for the Euler angles. Figure 5.2: Step response for angular velocities. 14 Figure 5.3: Step response for linear velocities. Figure 5.4: Step response for positions. 5.2 Potential fields performance as a navigation controller For the navigation part a script was developed to test the guidance of the potential field function by simulating a random number of UAVs in the range [5,7] and obstacles in the range [50,100]. The initial and goal configurations for the UAVs, and the center of the obstacles, are random within a 30×30×30 m3 cube. Obstacles can not appear too close to the quadcopters or their goals. Obstacles have a random radius between 0.3 m and 2 m. Each UAV has a radius of 25 cm and a sphere of influence of 2 m. These values are inspired by real-life situations, in the case we considered a relatively large UAV. For the sphere of influence, the most common ultrasonic sensors, placed in the adequate places, allow sensing up to 2 m without any problem. For the scaling factors, we used ξ1= 1, ξ2= 0.3 and η= 1. The value of ξ1is assigned so that the UAVs have a desired velocity of around 1 m swhen far from the goal. Both the attractive and the repulsive potentials have the same scaling by setting ηto the same value as ξ1, to prevent collisions with obstacles. When closer to the goal, the scaling factor is lowered to avoid oscillations around the goal. The distance to change from conic to parabolic well is set to d= 1 m so the velocity of the UAV is restricted most part of its flight. The algorithm works by calculating, for each vehicle, the distance to the goal and if an obstacle is close enough to be detected. The potential function is calculated consequently. Then as stated in Equation (4.11), the drone advances in space with a set discrete time step of 0.1 s, to assure that the UAVs do not move for a long period of time without checking the state and the environment. Figure 5.5: Environment from first perspective. Figure 5.6: Environment from second perspective. 15 Figure 5.7: Environment from third perspective. Figure 5.8: Distance from vehicles’ surface to any other obstacle’s surface. Figure 5.9: Distance from vehicles to their respective goal. Figure 5.10: Velocities for each vehicle. In Figure 5.5, Figure 5.6 and Figure 5.7, it can be seen that each UAV (represented by a colour) reaches its goal (represented by a of the same colour) while avoiding the obstacles that it encounters throughout its path. In Figure 5.9 we can see the distance from the vehicle’s surface to its goal at each time step. The distance between the surface of a UAV and its closest obstacle’s surface (static or dynamic) its always above zero, as can be seen in Figure 5.8. In Figure 5.10, we can see the velocity for all UAVs in each time step. 16 Chapter 7 BLDC motor and electronic control The motors used in almost all UAV applications are electronic brushless DC (BLDC) motors. These motors are preferred over brushed motors because they have higher power to weight ratio, less mechanical wear, lower noise and higher efficiency, and they are also smaller than brushed motors. They also have a precise control, that allows the user to select the force that should be generated, by means of controlling the rotational speed of the motor. In general, these motors are used in applications where the motor needs to have a long life or can not be checked often, or when they have to be powered by batteries. Figure 7.1: BLDC motor diagram [Renesas, ]. BLDC motors have a static part - the stator, that consists of a certain number of coils, and a moving part - the rotor, that consists of a permanent magnet. To control the rotation of the motor, the current through the coils has to be activated with a certain value, direction and timing. If this is done correctly, the coils generate a magnetic field that always repels the permanent magnet on the rotor, therefore making the motor spin in a certain direction and with a certain speed. As can be seen in Figure 7.1, the rotor would be rotating clockwise, since coil on top is activated to attract the north pole of the rotor, and the coil on bottom right attracts its south pole. This allows the user to control precisely the speed of the rotor, and therefore the torque needed. But this also makes the generation of the signals to deliver to the coils more difficult. To achieve smooth rotation, the current that should be delivered to each coil corresponds to a sinusoidal wave. In the case of having the equivalent of three coils, three sinusoidal waves will need to be delivered to each of these, the same wave but with a 120◦phase difference. The easiest way to control BLDC motors electronically is through an electronic speed controller (Electronic Speed Controller (ESC)). This system allows to contol the speed of the rotors just by adjusting the duty cycle of a Pulse Width Modulation (PWM) pulse. ESCs can be connected directly to a battery and they are distinguished mainly according to the maximum current they can supply to the BLDC. 23 7.1 Choosing the BLDC motors, ESCs and battery For this project, the chosen BLDC motors were 920 KV rotors. The KV constant is expressed in rpm V, and it is used to know how fast the rotor will spin according to the voltage provided, or how big will be the torque generated. Low KV motors will generate more torque with less power consumption. For this application, low-KV motors have been chosen, since the main objective of autonomous UAVs, generally speaking, is to perform a certain task with safety, and the UAV is not required to travel that fast. High KV motors are generally used for drone races. With load (propeller), the estimated current consumption for one motor is around 14.5 A. Therefore, the selected ESC should be able to handle +20 A. The chosen one is a 30 A ESC, that allows to control the speed of the motor thanks to adjusting the duty cycle of a 60 Hz PWM signal. With a width of 1 ms for the motor is turned off and a with of up to 2 ms corresponds to the fastest motor rotational speed. The battery chosen to power these devices is a 4-cell lithium-ion polymer battery. It gives 14.8 V, has an electric charge of 4 A h and a 30C rate discharge. It weighs approximately 415 g, and it will be the heavier component of the UAV. Since it has to feed four motors it won’t last very long, but it’s usual for this kind of applications, where there is always a tradeoff between power and weight. 24 Chapter 8 ATmega2560 microcontroller unit Atmel ATmega2560 is an 8-bit microcontroller that has been chosen basically because of its peripheral features. It has 6-channel 10-bit Analog to Digital Converter (ADC), four 16-bit Timer/Counter modules with a separate prescaler, and 86 Programmable I/O Lines. This microcontroller has been chosen mainly because of its 16-bit timers, since the four PWMs are the only outputs the system has to generate. Its several serial pins also allow connecting both the GPS and the bluetooth modules without the need of a software serial library implementation. 8.1 PWM generation with 16-bit timer ATmega2560 has four 16-bit timers with three comparators each, that allow to generate a 60Hz high resolution PWM signal. The 60 Hz frequency can not be achieved with regular prescalers directly, so these timers have to be configured in Fast PWM mode, where the OCRnA register can be set as the TOP value, that will fix the value of the frequency. By knowing that the base frequency of the ATmega2560 is 16 MHz and setting an 8 prescaler, the TOP value will need to be as stated in Equation (8.1). 8 16 MHz ·T OP =1 60 Hz →T OP = 33333 (8.1) Note that by setting an 1 prescaler (no prescaler option) the TOP value needed would not fit in a 16-bit register, hence using a 8 prescaler. Since the register OCRnA for comparer A is being used to adjust the frequency, comparers B and C can be used in non-inverting mode for the compare output mode, so the output signal is high until a match toggles, then the output value is cleared. This way, the duty cycle of the PWM signal can be adjusted as explained in Equation (8.2) and Equation (8.3). PWMwidth = 1 ms →OCRnB/OCRnC = 2083 (8.2) PWMwidth = 2 ms →OCRnB/OCRnC = 4166 (8.3) As can be observed, the PWM signal will have a resolution of 2083 levels between the 1 ms and the 2 ms pulse width, which is certainly a quite accurate precision. If the same PWM signal would need to be done with a 8-bit timer, this resolution would be much less. This would not be accurate enough for a smooth tracking control, so the 16-bit timers from ATmega2560 are really useful. Finally, Timer 1 and Timer 3 are used for the four PWM signal generation, that will control each of the four BLDC motors. 25 Chapter 9 UAV design 9.1 3D printed body As explained in chapter 2, the body of a quadcopter consists of a plus-shaped base, and the motors are situated in the ends of the arms with a specific configuration depending on the direction they spin. For the modelling of the system done in this thesis, one of the main assumptions is that this device is symmetrical and that the center of mass is situated in the middle of the quadcopter. Therefore, the experimental UAV will need to have these characteristics. It also has to be as light as possible, so 3D printing the structure is one of the best options since it is cheap, the material is light, and it requires less time to work manually on it. The proposed structure is shown in Figure 9.1 and Figure 9.2. The body has a + shape and it has two floors so there is enough space for the electronic circuitry. There are two extensions on the upper floor to leave more space to electronics, these are really light (around 18 g versus the 400 g of the battery) and they will not affect the structure properties. The battery will be mounted on the middle space between both bases of the body, the motors will be mounted on each arm, and the ESCs will rest on the space in between the arms. Figure 9.1: Design for 3D printed UAV from isometric view. 26 Figure 9.2: Design for 3D printed UAV from top perspective. 9.2 PCB design There are a lot of sensors that need to be used, almost all of them need to be placed on top of the UAV. The ones used for obstacle detection need to be distributed around the body of the vehicle. The PCB has to include the ATmega2560 microcontroller, all the sensors considered in chapter 6 and the four PWM outputs for the Brushless DC (BLDC) motor control. The design also has to take into account that the sensors that are mounted on the PCB take a considerable amount of space, and that the other components will need sockets to be connected to the microcontroller. 27 Figure 9.3: Proposed PCB for the electronic circuitry. 28 Chapter 10 Discussion, conclusion and future development This thesis had a lot of chapters that were state of the art studies on how to model the UAV system, different techniques on how to control it and which drivers should be used to link together all the different blocks that conform the whole system. Therefore, the discussion is focused on the results that were obtained from the MatLab simulations, how they could be further improved and which other methods could be useful for this kind of applications. As mentioned in section 5.1, Figure 5.1, Figure 5.2, Figure 5.3 and Figure 5.4 all show a steady state error of zero, which is the case for all 12 outputs from the feedback system. This implies that the LQR is working the way it was intended to and that we actually have full control of the UAV. The parameters Q and R were heuristically chosen, the rise, settling and overshoot times can therefore be further improved by tuning the values of Q and R. This could be a subject to study in a future projects within the field. As seen in section 5.2, the potential field method has been proved to be reliable in not allowing UAVs to collide with each other or with other obstacles, as can be seen in the multi-drone-avoidance case in Figure 5.11. It also provides good enough safe margins of more than 0.5 m of minimum distance between a moving UAV and any other type of static or dynamic obstacle, as can be seen in Figure 5.8. The velocities of the different UAVs, as seen in Figure 5.10, are appropriate for this case study, in terms of real life UAV capabilities. The vehicles should not be slow but neither too fast to assure obstacle detection with enough margin to avoid them in time. This is due to the discrete nature of the computer unit that implements the controller and the sensor’s measurements. Therefore, an ’open environment’ velocity of around 1 m sin our case is considered to be safe. Since we can see in Figure 5.8 that the safe margin is large, the velocity could also be increased. As explained in page 13, potential fields can be problematic in some specific cases, this should be solved before this method can be used to test how UAVs would move in more realistic environments, e.g a city-like environment. As can be seen in Figure 5.13, the geometries where a UAV can get stuck in a local minima of a plain potential field function are not complex, but also not likely to happen. To assure that the vehicle can not get stuck in any situations, more than one path planning algorithm should be implemented in the high-level controller for the UAV. To conclude, there is just left to say that the project goals have been met by developing a full and detailed mathematical model relatable to a real UAV. Also by providing two robust methods, LQR and PID tuning, for the low-level tracking controller. Finally, by studying and testing a really simple but trustworthy path planning function, potential fields, that have been proved to be reliable at providing adequate data for the high level motion planning controller. All the blocks and components necessary for a real life implementation of an UAV, such as the BLDC motors and drivers, 3D modelling of the body and the PCB design, have been studied and tested to work as expected, so with more time, all these parts could be implemented in a operational autonomous aerial vehicle. Future projects could work on studying the methods necessary to implement the path planning algorithm with the help of smart cameras. It requires a lot more computing power, but the results are much 29 more efficient and reliable when considering navigation controlling. 30 Chapter 11 Budget The main cost of this project is the cost of the real life components that have been bought or manufactured for the real life UAV implementation, and presented in Table 11.1. Table 11.1: Estimated budget for components and materials. Component Amount Price/Unit [Euro] Total [Euro] IMU GY-85 1 6.50 6.50 GPS ublox NEO 6M 1 14.5 14.5 AT-09 BLE 1 1.65 1.65 SONAR HC-SR04 5 0.90 4.5 IR Sharp GP2Y0A02YK0F 6 20.60 123.6 BLDC motors 920Kv 4 4.45 17.8 ESC 30A 4 3.10 12.40 4S Lithium Polymeter (LiPo) battery 1 24.60 24.60 LiPo Battery charger 1 24.60 24.60 ATmega2560 1 10 10 PCB manufacturing 1 5 5 Material Amount Price / gram [Euro] Total [Euro] PLA 420 g 0.018 7.56 TOTAL [Euro] 252.71 31 Terms and Abbreviations ADC Analog to Digital Converter. 25 BLDC Brushless DC. 27, 29, 31 BLE Bluetooth Low Energy. 21, 31 DOF Degrees of Freedom. 18 ESC Electronic Speed Controller. vi, 23, 24, 26, 31 GPS Global Positioning System. vi, vii, 18, 19, 25, 31 I2C Inter-Integrated Circuit. 18 IMU Inertial Measurement Unit. vii, 18, 19, 22, 31 KTH Kungliga Tekniska H¨ogskolan. iv, v, 1 LiPo Lithium Polymeter. 31 PCB Printed Circuit Board. vi, vii, 2, 27–29, 31 PWM Pulse Width Modulation. vi, 23–25, 27 UAV Unmanned Aerial Vehicle. vii, 13–24, 26, 27, 29, 31 UPC Universitat Polit`ecnica de Catalunya. iv, v, 1 32