• No results found

Analysis of autonomous flight algorithms for an unmanned aerial vehicle

N/A
N/A
Protected

Academic year: 2021

Share "Analysis of autonomous flight algorithms for an unmanned aerial vehicle"

Copied!
63
0
0

Loading.... (view fulltext now)

Full text

(1)

SLAM APFA

G G

Master Thesis Report

Analysis of autonomous flight algorithms for an unmanned aerial vehicle

Mattias Sjöberg

May 7, 2018

Spring 2018

Master Thesis, 30 ECTS

(2)
(3)

Abstract

Unmanned Aerial Vehicles (UAV) have been heavily studied in the past decade, where autonomous flights have been a popular subject. More complex applica- tions have led to higher requirements on the autonomous flight algorithms and the absence of performance data complicates the selection of what algorithm to use for various applications. Therefore, this thesis focused in analyzing the performance difference between two methods, Simultaneous Localization And Mapping (SLAM) and Artificial Potential Field Approach (APFA), which are planning and reactive algorithms, respectively.

Fundamental dynamics were applied, Feedback Linear Controllers

(FBLC)s for stabilization and an odometry position model combined with an inverse dynamics technique that linearizes the non-linear odometry model.

The SLAM approach was set up in four steps: landmark extraction which uses a point distance based method for segment separation, combined with a Split-And-Merge algorithm for extracting linear landmarks, data association that validates the landmarks, Extended Kalman Filter (EKF) that uses the landmarks together with the odometry model for estimating the position of the UAV, and a modified TangentBug as the reactive algorithm. The APFA was constructed of two functions, an attractive and a repulsive function.

The two methods were implemented on the robotics simulation platform Virtual Robot Experimentation Platform (V-REP), where a quadcopter was used as the model for the UAV. All theory was implemented onto the quad- copter model and embedded scripts were used for communication within V- REP, mainly through internal Application Programming Interface (API) - functions. Furthermore, a script was written that randomly generates three different types of simulation environments.

The implementation of both methods was analyzed in reaching an arbi- trary goal position in terms of: the most successful, the most time efficient and the safest navigation path. Another thing analyzed was the time- and space-complexity of both implemented methods.

The results stated that the implemented APFA and the SLAM approach had approximately equal success rate, SLAM had the safest navigation, was the most time efficient, and had the highest time- and space-complexity for a worst case scenario. One of the conclusions were that improvements could be done in the implementations.

Future work includes adding a proper damping method, improving the flaws in the implemented methods as well as to use V-REP as a Robot Op- erating System (ROS)-node for creating a Software In The Loop (SITL)- simulation, in order to achieve more realistic simulations.

Keywords: UAV, SLAM, Split-And-Merge, APFA, V-REP, Inverse dynamics, FBLC, EKF.

(4)

Acknowledgements

I would like to express my gratitude to both my supervisors, Saqib Sarker and Anna Filipsson for being there as a helping hand, still leaving a lot of room for my own innovation and creativity. Also, I would like to thank all the people in Cybercom Group AB that are working at the Kista office for creating such a great working environment.

Mattias Sjöberg, Umeå, May 2018

(5)

Contents

List of Figures List of Tables List of Algorithms

1 Introduction 1

1.1 Background . . . 1

1.2 Purpose . . . 2

1.3 Objective . . . 3

1.4 Outline . . . 3

2 Theory 4 2.1 Quadcopter dynamics . . . 4

2.1.1 Equilibrium conditions . . . 6

2.1.2 Damping and Constraint . . . 6

2.2 Control Design . . . 7

2.2.1 Navigation system . . . 7

2.2.2 Model . . . 8

2.2.3 Dynamic inversion . . . 8

2.2.4 Feedback Linear Controllers . . . 9

2.3 Range sensors . . . 10

3 Methods 12 3.1 Simultaneous Localization And Mapping . . . 12

3.1.1 Landmark Extraction . . . 14

3.1.2 Data Association . . . 17

3.1.3 Extended Kalman Filter . . . 17

3.1.4 TangentBug . . . 19

3.2 Artificial Potential Field Approach . . . 22

3.2.1 Determination of unknown parameters . . . 24

4 Implementation 25 4.1 Equipment . . . 25

4.1.1 Software . . . 25

4.1.2 Hardware . . . 26

4.2 Modelling . . . 26

4.2.1 Quadcopter . . . 26

4.2.2 Sensors . . . 27

4.2.3 Feedback Linear Controllers . . . 29

(6)

4.3 Application Programming Interface . . . 29

4.4 Simulation environments . . . 30

5 Analysis 32 5.1 Model and Methods . . . 32

5.2 Performance . . . 34

5.2.1 Time efficiency . . . 34

5.2.2 Successful- and Safe-navigation . . . 34

5.2.3 Time- and Space-complexity . . . 34

6 Results 35 6.1 Evaluations . . . 35

6.1.1 Model dynamics . . . 35

6.1.2 Control and Stabilization . . . 36

6.1.3 Extended Kalman Filter . . . 39

6.1.4 Artificial Potential Field Approach parameters . . . 39

6.2 Performance . . . 41

6.2.1 Time efficiency . . . 41

6.2.2 Successful- and Safe-navigation . . . 43

6.2.3 Time- and Space-complexity . . . 45

7 Discussion 46 7.1 Evaluation of implementation . . . 46

7.2 Performance . . . 47

8 Conclusion and Development 48

Bibliography 49

(7)

List of Figures

2.1 Quadcopter dynamics . . . 4

2.2 Position update system . . . 7

2.3 Proportional-Integral-Derivative controller . . . 9

3.1 Simultaneous Localization And Mapping process . . . 13

3.2 Artificial Potential Field Approach process . . . 23

4.1 Quadcopter model . . . 27

4.2 3D-Sensor beam pattern . . . 27

4.3 Quadcopter geometry . . . 28

4.4 Simulation environments . . . 31

5.1 Customized user interface . . . 33

5.2 Repulsive test . . . 33

6.1 Velocity versus velocity rate, without inverse dynamics . . . . 35

6.2 Velocity versus velocity rate, with inverse dynamics . . . 36

6.3 Robustness test translational acceleration . . . 38

6.4 Robustness test rotational acceleration . . . 38

6.5 Extended Kalman Filter convergence . . . 39

6.6 Standard deviation for the APFA straight-line-test . . . 40

6.7 Quadcopter trajectory in the repulsive test . . . 40

6.8 Average time for different simulation environments . . . 42

6.9 Average time for all simulation environments. . . 42

6.10 Average collision rates for different simulation environments . 43 6.11 Average collision rates for all simulation environments. . . 43

6.12 Average minimum rates for different simulation environments . 44 6.13 Average minimum rates for all simulation environments. . . . 44

(8)

List of Tables

2.1 Range sensor properties . . . 11

3.1 Modifications of the TangentBug algorithm . . . 21

4.1 Computer specifics . . . 26

4.2 Sensor properties . . . 28

4.3 Quadcopter geometric values . . . 28

4.4 GPS properties . . . 29

6.1 Feedback Linear Controllers parameter values . . . 37

6.2 Model stability limitations . . . 37

6.3 Tuning parameters for the APFA . . . 41

6.4 Average performance result of both methods . . . 45

6.5 Time- and space-complexity . . . 45

(9)

List of Algorithms

1 Split-And-Merge . . . 16 2 Modified TangentBug . . . 20 3 Memoization . . . 22

(10)

List of Acronyms

AFA Autonomous Flight Algorithms APF Artificial Potential Field

APFA Artificial Potential Field Approach API Application Programming Interface DA Data Association

EKF Extended Kalman Filter FBLC Feedback Linear Controller FOV Field Of View

FOVH Field Of View Horizontally FOVV Field Of View Vertically GCS Ground Control Station GPS Global Positioning System

IEKF Iterative Extended Kalman Filter KF Kalman Filter

LE Landmark Extraction LMS Least Mean Squares LTG Local Tangent Graph

MILP Mixed Integer Linear Programming MP Mission Planner

MSE Mean Squared Error

ODCA Obstacle Detection Collision Avoidance OMPL Open Motion Planning Library

OS Operating System

PDBM Point-Distance-Base-Method PD Proportional-Derivative

PID Proportional-Integral-Derivative PRM Probabilistic Roadmap

QGC QGroundControl

RMSE Root Mean Square Error ROS Robot Operating System SAM Split-And-Merge

SLAM Simultaneous Localization And Mapping SITL Software In The Loop

TB TangentBug

UAV Unmanned Aerial Vehicle UI User Interface

UKF Unscented Kalman Filter

V-REP Virtual Robot Experimentation Platform

(11)

Chapter 1 Introduction

1.1 Background

Unmanned Aerial Vehicles (UAV) have been heavily studied in the past decade.

One of several motivations for this is that the hardware has improved a lot, giving rise to varieties of applications e.g. delivering mail, providing internet in disaster- and hard-to-reach-areas, filming, and much more[1]. Studies have been made in many fields where autonomous flights have been a recurring sub- ject. UAVs are now required to navigate in complex terrains, unknown envi- ronments and at distances where manual control is impossible. A well known solution for handling the long distances is to integrate cameras onto the UAV and connect it to a ground station that will manage the communication. Usu- ally one can set up flight paths in know Ground Control Stations (GCS) like Mission Planner1 (MP) or QGroundControl2 (QGC). However, the question how to direct the UAV in complex and unknown environments still remains.

Planning a route for an UAV can be done by using a flight controller with integrated software and an external Global Positioning System (GPS), together with a GCS. A general setup of the UAV uses a GPS and integrated sensors[2]

such as accelerometer, magnetometer, gyroscope, and barometer when direct- ing itself to the nearest way point. The absence of range sensors makes the UAV unaware of obstacles that can occur during its flight e.g. buildings, trees, and other obstacles, which normally would have been avoided in a manual flight by the human interception. The unknown obstacles can be avoided by integrating different sensors and uploading an Autonomous Flight Algorithm (AFA) onto the UAV, where the main process is often referred to as Obstacle Detection and Collision Avoidance system (ODCA). All the integrated sensors can then, in real time, send the obtained data to the ODCA system that will utilize it to complete an autonomous flight.

1Mission Planner is a free open source software available for Windows.

2QGroundControl is a free open source software available for Windows, OS X, Linux, iOS and Android.

(12)

1.2 Purpose

Numerous variations of AFAs for UAVs exist, where some algorithms are more widely used then others. However, it is not easy being a novice in the field and to know what is the appropriate approach to use for different applica- tions. In the research papers studied about AFAs most of the advantages and disadvantages have been clearly stated, but without much reference and anal- ysis. A few stated properties were that the SLAM approach is more complex than the APFA and the APFA have no global convergence guarantee[3][4][5][6].

Learning what approach to use takes time, not least finding an efficient and working solution. That is why this thesis is directed towards individuals interested in which approach of two of the most frequently used AFAs that are the most successful in reaching an arbitrary position, have the best time- and space-complexity, have the safest navigated flight, and the highest time efficiency for various simulation environments.

Multiple studies were made using various AFAs, where the AFAs from the prior studies to this thesis can be divided into two main groups:

• Planning and Reaction - Commonly based on the concept of Simul- taneous Localization And Mapping (SLAM)[7][8][9][10][11], with various range sensors and reaction algorithms[5][12].

• Pure Reaction - Recently more commonly based on steering the UAV to a positively charged goal position and avoiding the negatively charge obstacles using an Artificial Potential Field Approach (APFA)[13][14]

[15][3][16], which concept originates from the Artificial Potential Field method (APF)[17].

Other known planning concepts are:

• Geometric difference - Frequently applied for applications involving multiple UAVs in motion, where the method in general calculates relative velocity vectors of the UAVs and if an encounter is found in the path, trajectory corrections will be made[18][19][20][21].

• Optimization techniques - Often constructed around a discrete grid- based shortest path algorithm[16][22].

• Mixed integer linear programming (MILP) - Dissembles the prob- lem into a mathematical problem containing a set of linear constraints and then uses a MILP-tool to generate a best path outcome[16][22].

In this thesis, the analysis will be made on the SLAM approach and the APFA, due to their popularity and the large contrast in construction as well as their characteristics. A desired result of the analysis would include a major performance difference between the approaches, which then can be investigated in every aspect. This investigation could then be used to optimize the imple- mentation of both approaches for achieving a more realistic result.

(13)

1.3 Objective

The main objective of this thesis is to analyze: Which of the AFAs, SLAM or APFA, have the safest navigated flight, the best time- and space-complexity, the highest time efficiency, and are most successful in reaching an arbitrary position for various simulation environments. However, the performance anal- ysis is not the only objective, but also some knowledge how to implement both approaches. A summary of the expected steps in the implementation is defined accordingly:

1. Set up a 3D robotic simulation platform.

2. Create an UAV model and apply proper dynamics.

3. Integrate mandatory sensors for the approaches onto the model.

4. Construct and apply both approaches in the simulation platform.

5. Create a simulation environment, simulate and analyze the performance difference between the two approaches.

Earlier, in the subsection advantages and disadvantages for both the AFAs were stated. The results expected are that the SLAM approach is more computational heavy, which induces implementation problems due to its high complexity, compared to a pure reaction algorithm[5][4]. It is also expected to have a safer navigated flight due to its robustness. Another thing to expect is the APFA having a lower success rate, since it is a pure reaction algorithm that has no global convergence guarantee and can easily get stuck at a local minimum[3]. However, the APFA is also expected to be most time efficient due of its low time- and space-complexity.

1.4 Outline

This thesis consists of 8 chapters. In chapter 2: dynamics, stabilization tech- niques, and control laws are explained. Chapter 3 contains details and theory about the APFA and the SLAM approach. Chapter 4 describes how the whole simulation environment was constructed from the robotic platform to model, sensors, and communication. Chapter 5 hold information about how the anal- ysis was performed. Chapter 6 presents the obtained result and chapter 7-8 contains discussion, conclusion and possibilities for future development.

(14)

Chapter 2 Theory

In this chapter, fundamental theory used in the thesis is presented. It touches areas such as quadcopter dynamics, stabilization and control strategies.

2.1 Quadcopter dynamics

In a simulations environment there are limitations of real world phenomena.

Still one should model the UAV in an as realistic way as possible to achieve credible results. For simplicity the UAV model will be a quadcopter, seen as a rigid body with the dynamic structure seen in Figure 2.1(a), where two rotors rotate counter-clockwise and the other two clockwise. The reason for this construction is to cancel out unwanted effects that occur due to Newton’s third law. The two coordinate systems are: a fixed inertial frame seen in Figure 2.1(b) and the rotational body frame fixed at the centre of mass of the quad- copter.

(a)

(b)

Figure 2.1: (a) Dynamics of a quadcopter with corresponding rotational refer- ence frame. (b) Inertial reference frame.

(15)

The dynamical structure of Figure 2.1(a) is used for the proceeding deriva- tions Eq.(2.1) → Eq.(2.10), which is an adaption of an existing model[23].

However, the only dynamical model sought is in terms of position (x, y, z) and all the moments acting on the quadcopter. Let (x, y, z) be the-translational- and the-rotational-coordinates (ϕ, θ, ψ) in the inertial reference frame, defined in IR3, where (ϕ, θ, ψ) are the Euler angles of the quadcopter, relative to the inertial frame. By neglecting rotor dynamics the generalized coordinate vector q for the quadcopter can be written, q = (x, y, z, ϕ, θ, ψ). For a rigid body the kinetic-T and potential-U -energies can be expressed,

U = mgz, (2.1a)

T = Trot+ Ttra, (2.1b)

where m is the mass of the quadcopter, g is the gravitational acceleration, Ttra and Trot is the rotational- and translational-kinetic-energies, respectively.

The quadcopter dynamics can be described by Lagrange’s equations for the external forces Ftot,

∂L

∂q + d dt

∂L

∂ ˙q = Ftot, (2.2)

where the Lagrangian is defined as the difference between the kinetic and the potential energy, L = T − U. Ftot(Fi, τ ) is created from the torque τ = ϕ, τθ, τψ) in the directions of the Euler angles and the total thrust Fi in the inertial frame. Fi can be derived from the relation,

Fi = RFr, (2.3)

where R is the rotation matrix from the body frame to the inertial frame and can be expressed,

R =

cψcθ cψsθsϕ− sψcϕ cψsθcϕ+ sψsϕ sψcθ sψsθsϕ+ cψcϕ sψsθcϕ− cψsϕ

−sθ cθsϕ cθcϕ

 , (2.4)

where ci = cos(i), si = sin(i), i ϵ (θ, ϕ, ψ) and Fr is the total thrust in the rotational frame,

Fr =

 0 0 u

 , (2.5)

that is depending on the control input u defined,

u =



xyrate xyrate

zrate ψrate



 , (2.6a)

xyrate =

4 k=1

fk, (2.6b)

(16)

where ψrate, zrate are control inputs for the quadcopter to turn in respectively ψ-direction and z-direction and fk is the thrust of rotor k, proportional to the angular speed ωkof rotor k. τ represents all moments acting on the quadcopter in the rotational frame,

τ =

L(f4− f2) L(f3− f1) L(f2+ f1+ f4+ f3)

 , (2.7)

where L is the distance from the rotors to the quadcopters centre of mass.

Neglecting aerodynamical effects the final dynamical model can be written,

m

x¨

¨ y

¨ z

 +

 0

0 mg

 = Fi, (2.8)

which can be expressed differently using the fact that the rotation matrix is orthogonal[24] R−1 =RT combined with Eq.(2.3),

x¨

¨ y

¨ z

 =

 0

0

−g

 + 1 m



cos ψ sin ψ sin θ

cos θ 0



 uT. (2.9)

2.1.1 Equilibrium conditions

The quadcopter requires four conditions to be fulfilled in order to have a state equilibrium (force balance, parallel force directions, zero moments and balance between the angular velocities), also referred to as hovering[25]:

4 k=1

fk =−mg, (2.10a)

fk||g, k ∈ [1, 4], (2.10b)

4 k=1

L× fk = 0, (2.10c)

1+ ω3)− (ω2+ ω4) = 0, (2.10d) which is the state of the quadcopter if the total control input u in Eq.(2.6a) equals zero, assuming the system is set up with a stabilization technique.

2.1.2 Damping and Constraint

Damping is often introduced into a dynamical systems, especially if the control input u is discontinuous. Without a damping term and at large transition steps in the control input, the quadcopter would be stuttering forward. An easy

(17)

way to implement a damping system is by using a ramp function, which can be constructed with the dependency of the control input in Eq.(2.6b),

Dr = 1 1

1 + δramp, (2.11a)

δramp,k+1 =

{ δramp,k+ CxyC

rate xyrate > 0

δramp,k− CxyCrate xyrate < 0 (2.11b) where C is a constant tuned with respect to extreme values of xyrate and k is the time step.

It is common that the range sensors on an UAV have higher Field Of View Horizontally (FOVH) than Field Of View Vertically (FOVV), which can lead to unwanted collisions for a xyrate ≪ zrate. This problem can be dealt with by adding a constraint on the zrate,

zrate ≤ cconxyrate, (2.12) where ccon is a constant defined by the geometry of the quadcopter.

2.2 Control Design

2.2.1 Navigation system

In order for the AFAs to properly navigate the quadcopter a position update system was created which connects the methods to the dynamical model. The position update system implemented in this thesis is shown in Figure 2.2.

Figure 2.2: Position update system implemented on the quadcopter.

The position system update was constructed such that it takes two con- trol vectors uEA containing two Euler angles and the control vector u from Eq.(2.6a), where r in the first and second step stands for rate. The control vectors are then sent to a method called inverse dynamics[23], which calculates a new xyrso that the odometry position model gives a linear output. Then the updated pose is used with the odometry data from the previous time iteration, together with Feedback Linear Controllers (FBLC)s to navigate[26] and stabi- lize the quadcopter around the new equilibrium position. Two FBLCs are used, Proportional-Integral-Derivative (PID) for the thrust Fi and Proportional- Derivative (PD) for the (ψ, θ, ϕ) angels, because the PID controller have a tendency to oscillate for highly oscillatory processes[27][28], which makes it

(18)

unfit for stabilization of the Euler angles. The data is then sent to the ro- tor function which applies the appropriate torque and thrust corresponding to Eq.(2.7) and Eq.(2.5). More details about the model, the inverse dynamics method, and the FBLCs are described in the forthcoming subsections.

2.2.2 Model

One of the key points in an ODCA system is to know the position were the UAV is located. Receiving an approximate position when the UAV is at rest is a trivial task, however not so trivial when the UAV is in motion. To obtain its new position and state a motion model for the UAV needed to be derived. The motion model selected is a odometry model, equal for both approaches. It was selected because in general its more accurate then velocity models, especially if the velocity model are using some type of PID controller[29]. This model is a bit unsuitable for a general SLAM approach because it only works after the UAV have been moving and the SLAM approach is using motion planning.

However, this does not apply for algorithms with a filter function[29], which the SLAM approach in this thesis have. The model is derived by solving Eq.(2.9), assuming the that control expression is time invariant, adding the ramp function Eq.(2.11a), which gives the recursion model for position and orientation around the z-axis for each time iteration k,



xk+1

yk+1 zk+1 ψk+1



 =



xk

yk zk ψk



 +





xk−xk−1

∆tk

yk−yk−1

∆tk

zk−zk−1

∆tk

0



+



Drcψ+∆ψ

Drsψ+∆ψsθ+∆θ cθ+∆θ

1



 uT, (2.13)

where ∆ψ, ∆θ represents change in the angles (θ, ψ) and the time step ∆t for each time iteration k, ci+∆i = cos(i + ∆i) and si+∆i = sin(i + ∆i), where i ϵ [ψ, θ].

2.2.3 Dynamic inversion

Dynamic inversion[23] is a method used to linearize the non-linear odometry model defined in Eq.(2.13), which can be derived by knowing that the velocity in the internal frame vk,i for each time iteration k,

vk,i =

˙x2k+ ˙yk2+ ˙z2k, (2.14) where the velocities are,

˙xk= xk− xk−1

∆tk , (2.15a)

˙

yk= yk− yk−1

∆tk , (2.15b)

˙zk= zk− zk−1

∆tk . (2.15c)

(19)

By knowing the linear dependency of the UAV following a straight line one can construct an expression for the velocity rate xyr from Eq.(2.6a) by using Eq.(2.14),

xyr = Bvk,i, (2.16)

where B is the linear dependency constant. By combining Eq.(2.16), Eq.(2.13) and solving for xyr in uTone gets the following inverse dynamics relation,

xywr = xyr∆tk− ˙xk− ˙yk− ˙zk− zrcθ+∆θ

Drcψ+∆ψ+ Drsψ+∆ψsθ+∆θ , (2.17) where xywr is the wanted velocity rate such that Eq.(2.13) gives a linear out- put. Some simulations platforms have discontinuous angle intervals for which Eq.(2.17) can be approximated without using direct angle orientations,

xywr = xyr∆tk− ˙xk− ˙yk− ˙zk

1 + E| ˙ψψr| , (2.18)

where E is a tuning constant.

2.2.4 Feedback Linear Controllers

For a quadcopter to navigate, maintain its position and orientation it requires a controller that can stabilize the quadcopter at its equilibrium state Eq.(2.10).

The main process of a controller is to reduce the residuals between a wanted xw and measured value xm. Two widely used FBLCs are PD and PID. PD and PID controllers main advantage is that they are easy to implement[30].

Figure 2.3 visualizes a general PID scheme.

Figure 2.3: A general control scheme for a PID controller.

The residual of a PD and PID controller is calculated by[25],

e = xw− xm, (2.19)

which then is set in the control input signal for the PD controller[25], uP D(t) = KPe + KDde

dt, (2.20)

(20)

and for the PID controller[25],

uP ID(t) = KPe + KI

t 0

e(τ )dτ + KDde

dt, (2.21)

where KP, KI and KD are controller constants in IR and τ is the time step between each measurement. KP is the proportional gain, KI is the integral gain and KD is the derivative gain. The unknown constants can either be tuned by analyzing experimental data or by using the Ziegler-Nichols method, as well as the Cohen-Coon method. It can also be tuned algorithmic and with software tools[31].

The total stabilization of the quadcopter was achieved by using both PD- and PID controllers, where the control law is designed1, modified for thrust,



f1 f2 f3 f4



 = FTi



1− α + β + γ 1− α − β − γ 1 + α− β + γ 1 + α + β− γ



 , (2.22)

where the control input α, β and γ is the θ, ϕ and ψ correction respectively. Ex- pressions for the parameters for each time iteration k are defined from Eq.(2.22) , using Eq.(2.15c), Eq.(2.19), Eq.(2.20) and Eq.(2.21),

Fk+1,z = Fk,z+KP,Fek,z+KI,F

k i=1

ek,z+KD,F(ek,z−ek−1,z)+KC,F ek,z

∆tk, (2.23a) αk+1 = KP,αek,α+ KD,α(ek,α− ek−1,α) + KP,yyk+ KD,y(ek,y− ek−1,y), (2.23b) βk+1 = KP,βek,β+ KD,β(ek,β− ek−1,β) + KP,xxk+ KD,x(ek,x− ek−1,x), (2.23c) γk+1 = KP,γek,γ+ KD,γ(ek,γ− ek−1,γ), (2.23d) where KC,F is a tuning constant, Ki,j, ek,j are the controller constants and errors, respectively for i ϵ [P, I, D], j ϵ [F, α, β, γ] at the time iteration k.

2.3 Range sensors

Range sensors are used to measure the distance between the quadcopter and some arbitrary point e.g. at an obstacles surface. The choice of range sensors depends mainly on the application. An arbitrary 3D-range sensor often get the following set sscan from a sensor scan,

sscan ={pi(r, θ, ψ), i = 1, 2, ...}, (2.24) where piis the detected point, r is the radius to the object, (θ, ψ) are the angles to the object in an egocentric reference frame. Moreover, some commonly used sensors[32] with listed properties are seen in Table 2.1.

1Design found within the code of the Quadricopter.ttm model in the 3D robotic software platform: Virtual Robotic Experimental Platform (V-REP).

(21)

Table 2.1: Range sensor properties for commonly used sensors.

Sensor Advantages Disadvantages

Laser

Precise and efficient, exists models with single beam and with large Field Of View (FOV)

Expensive, some models have the tendency of disturbing external hardware, (e.g. GPS) [33], low performance in water and on glass

Radar

Works in most environments, there exists models with long range and good accuracy[34]

Expensive, large and heavy in general

Sonar

Works well under water, generally the cheapest ones on the market

Low precision, temperature dependent, often a lot of noise in signal

Stereo-

vision Extracts a lot of information

Bad performance in highly intense illuminated areas and in darkness

(22)

Chapter 3 Methods

This chapter contains a general system process, derivation and detailed infor- mation about the two methods.

3.1 Simultaneous Localization And Mapping

Simultaneous Localization And Mapping (SLAM) is a technique used in au- tonomous flight planning and can in general be categorized in three groups:

”grid-based”, ”topological based”, and ”feature-based”[35]. The grid-based ap- proach usually divide a map into a grid of elements containing a probability of being occupied. This feature becomes memory- and computational-heavy for increasing objects and map size. A topological-based approach generally creates a graph network of nodes, which gives an approximate description of the environment. The graph network can then be used with a shortest path algorithm such as Dijkstra’s algorithm1 to find the shortest path, combined with defined actions at each node. The main disadvantage of this approach is that it is not easy to implement for large and complex environments. The concept that stands out from prior studies is the feature-based SLAM approach which identifies features in the environment to build a map which then can be used to estimate its position. This feature consists of four steps:

• Landmark extraction

• Data association

• Extended Kalman Filter

• Reactive algorithm

Figure 3.1 describes a general feature-based SLAM process, which is an adap- tion from [36].

1Dijkstra’s algorithm is an algorithm for finding the shortest path between two graph vertices in a graph.

(23)

Figure 3.1: A general overview of a feature-based SLAM process.

A SLAM process starts by receiving data from a range sensor, which is then sent to the landmark extraction (LE) algorithm. Then the LE algorithm extracts landmarks from the environment, which can be corners, lines and other features[37]. These landmarks are then sent to the data association method which associate the landmark to its closets landmark from its neigh- borhood and checks if it has been seen before[36]. The new and re-observed landmarks are then sent to the EKF which uses them together with the odom- etry data for a more accurate position estimation. The estimated position is then sent to the reactive algorithm for position update. The construction of these four steps varies a lot depending on the application, where the forthcom- ing subsections describes a possible way to construct them.

(24)

3.1.1 Landmark Extraction

The Landmark extraction algorithm selected for this thesis is a Slit-And- Merge (SAM) algorithm with the usage of a Point-Distance-Based-Method (PDBM)[38] working as an initial cluster. It was selected due to its high fre- quency updates and accuracy[39]. This setup is a modification of the SAM algorithm with an agglomerative hierarchical clustering algorithm described in[39]. However, the data received from a range sensor is often given in spher- ical coordinates (r, θ, ψ). Therefore, the data is converted to Cartesian co- ordinates before being sent to the LE algorithm, through the equations[40],

x = rsin(ψ)cos(θ), (3.1a)

y = rsin(ψ)sin(θ), (3.1b)

z = rcos(ψ), (3.1c)

where r is the radius from the range sensor to the scanned point p(x, y, z). All scanned points p are then divided into linear segments by the PDBM by the condition: d > dth[38],

d =

r2i + r2i+1− 2riri+1cos(∆α), (3.2a) dth = C0+ C1min(ri, ri+1), (3.2b) where dth is a threshold condition, d is the Euclidean distance between two scanned points, i indicates the index of each consecutively scanned point, ∆α is range sensors angular resolution, C0 is a constant and C1 is an adaptive parameter depending on Eq.(3.2a),

C1 = d

ri. (3.3)

The calculated linear segments are then used as an input to the SAM algorithm. These linear segments are then divided into smaller segments if they are not significantly linear, which is tested by a Least Mean Squares (LMS) method. For a set of points in each segment s(x, y, z) the least mean square fit problem is defined,

min f (s), (3.4)

where f (s) is a function of residuals between each point in s and the line z = a1+ a2x + a3y. Eq.(3.4) can be solved using the normal equations,

ATAxsol = ATb, (3.5a)

A =





1 x1 y1 1 x2 y2 ... ... ...

1 xi yi



, b =



 z1 z2 ...

zi



, (3.5b)

where xsol is the solution vector containing the calculated constants (a1, a2, a3) and i is the number of points in the segment siϵ s. A general implementation

(25)

of the EKF uses landmarks N defined as points[36]. Therefore, the linear segments si can be converted to a point landmark by selecting a fixed point Fp on the map and selecting the point p in si that is orthogonal to the the fixed point by,

Ni = pϵ si ⊥ Fp. (3.6)

Next step in the the SAM algorithm is to check if two or more landmarks can be merged into one landmark. This is done by checking the collinear- ity between two abreast landmarks by using the Cayley–Menger determi- nant, where the Cayley–Menger matrix[41] is defined for a finite metric space (X = M, d), M ϵ (x, y, z),

CM(X, d) =

[ 0 e

eT D ]

, (3.7)

where e is an vector of ones and D = d(Mi, Mj)2. The determinant of the CM-matrix Eq.(3.7) can be used to determine the collinearity of at least three distinct points with the following expression[42],

det(CM ) =



0 d(AB)2 d(AC)2 1 d(AB)2 0 d(BC)2 1 d(AC)2 d(BC)2 0 1

1 1 1 0



 = 0. (3.8)

The pseudo code for the complete SAM algorithm is described in Algo- rithm 1.

(26)

Algorithm 1: Split-And-Merge

Input : A vector of linear segments s

Output: A vector L ϵ IRN containing N landmarks Create an empty sub-list Slist;

Initialize an empty list of landmarks L;

for i← 1 to number of segments in s do

if (number of points in segment si ≥ 5) then Slist← s;

while (Slist is not empty) do a1, a2, a3 ← LMS(si);

for j ← 1 to number of points in si do res← calculateResiduals(si, a, b, c);

end

resmax ← max(res);

if (resthreshold< resmax) then Slist← si(resmax);

sort Slist in ascending order;

if (number of points in segment si ≤ 2) then remove si from Slist;

end else

N ← extractP ointF romLine(si);

L← N;

remove si from Slist; end

end end end

for k ← to number of landmarks N in L do

CMdet ← calculateCMDeterminant(Nk, Nk+1);

if (CMdet < Ctolerance) then

Nk← mergeLandmarks(Nk, Nk+1);

remove Nk+1 from L;

L← Nk; end

end

(27)

3.1.2 Data Association

The Data Association (DA) algorithm can be thought of as a protocol that neglect bad landmarks, with characteristic properties such as[36],

• Not re-observable each time step

• Does not stand out and might not be observed again

• Getting associated with different landmark

Using bad landmarks might lead to an even worse estimated position update in the EKF than the odometry data alone and can induce devastating results.

The following concept about data association is an approximation based on[36].

The first step in the DA algorithm is to initialize an empty landmark database which stores new and re-observed landmarks. In order to remove landmarks that does not stand out, only landmarks re-observed n times are used for a position update. These landmarks are paired to their nearest neighbour by a nearest neighbour approach. Thus, for these pairs to be accepted as the same landmark the following condition must hold,

v ≤ λ∆α, (3.9)

where ∆α is the range sensor angular resolution, λ is a constant defined as half the amount of the minimum points required in a linear segment siϵ S and v is a parameter expressed,

v = zL− hL, (3.10a)

hL=

(Nxp− x)2+ (Nyp− y)2+ (Nzp− z)2, (3.10b) zL=

(Nxd− x)2+ (Nyd− y)2+ (Nzd− z)2, (3.10c) where hL is the expected range between the landmark Np(Nxp, Nyp, Nzp) and the quadcopter using the odometry data and zL is the expected range be- tween the landmark Nd(Nxd, Nyd, Nzd) and the quadcopter using the updated landmark position from the landmark database.

3.1.3 Extended Kalman Filter

The usage of filtering functions is crucial to the feature-based SLAM approach.

Popular filters for estimating a state with a non-linear transition function is the Extended Kalman Filter (EKF)[43], Unscented Kalman Filter (UKF)[44] and Iterative Kalman Filter (IEKF)[45]. The reason that the transition function is still being treated as non-linear is because the inverse dynamics method is only successful as long as the inner dynamics is stable[23], which is not guaranteed in this case. However, it will reduce strong non-linearities which makes it redundant to use a IEKF that increase performance in significantly non-linear systems, compared to the EKF[45]. In [44] a head and hand experiment was

(28)

made for orientation, which they represented by quaternions2[40]. Here they analyzed the differences between a EKF and UKF and the result gave roughly the same accuracy, implying that the EKF is the better choice when working in a virtual environment, due to e.g. simplicity and speed. Therefore, the EKF was selected to be the filter for the SLAM approach. The proceeding derivations Eq.(3.11) → Eq.(3.16) and reasoning are from[43].

The extended Kalman filter estimates a time-discrete state vector x(x, y, z) ϵ IRn by a stochastic non-linear function,

xk= f (xk−1, uk−1, wk−1), (3.11a) together with a measurement z ϵ IRm,

zk= h(xk, vk), (3.11b)

where f and h are non-linear functions, wk and vk represent Gaussian white noise, uk is the control function and k is the discrete time index. The noise terms in Eq.(3.11a) and Eq.(3.11b) are in general unknown so one can approx- imate Eq.(3.11a) and Eq.(3.11b) by neglecting the noise,

x˜k = f (ˆxk−1, uk−1, 0), (3.12a)

˜zk = h(˜xk, 0), (3.12b) where ˆxk is the a posteriori state estimate. Eq.(3.12a) and Eq.(3.12b) still represents a non-linear process and one can linearize the estimates by the approximations,

xk ≈ ˜xk+ Ak(xk−1− ˆxk−1) + Wkwk−1, (3.13a) zk ≈ ˜zk+ Hk(xk− ˜xk) + Vkvk, (3.13b) where A(f (x))k, W(f (w))k, H(h(x))k and V(h(v))k are Jacobian matrices consisting of partial derivatives. Together with Eq.(3.12a), Eq.(3.12b), the Kalman gain Kk and another a posteriori state estimation relation[43],

xˆk= ˜xk+ Kk(zk− ˜zk), (3.14) the prediction update can be formulated,

xˆk = f (ˆxk−1, uk−1, 0), (3.15a) Pk = AkPk−1AkT + WkQk−1WTk, (3.15b) where ˆxk is the a priori state estimate, Qk is the process noise covariance matrix, Pk is the error covariance and Pk is the a priori error covariance.

2A quaternion can be written q = q0+ q1i + q2j + q3k, where q[0,3]ϵ IR and i, j, k fulfills the Hamilton’s rules, {i2= j2= k2=−1, ij = k, ji = −k, jk = i, kj = −i, ki = j, ik = −j}.

(29)

The corresponding measurement update are,

Kk = PkHTk(HkPkHTk + VkRkVTk)−1, (3.16a) xˆk= ˆxk + Kk(zk− h(ˆxk, 0)), (3.16b) Pk = (I− KkHk)Pk, (3.16c) where Rk is the measurement noise covariance matrix. After the estimated state update ˆxk have been calculated from odometry data all landmarks N are then corrected even further by the data achieved from the data association step. This is done by a simplification taken from [36], by not taking into account the covariance update for the landmarks that are corresponding to the quadcopter. By using Eq.(3.16b) and Eq.(3.10a) the state is updated for each landmark N ϵ L as,

xˆk,L+1 = ˆxk,L+ cn(zL− hL), (3.17) where cn = 1 − 1/n, and n is the number of times the landmark has been observed.

3.1.4 TangentBug

When it comes to reaction algorithms there are a whole sea to choose from. In [12] some commonly used algorithms are mentioned such as Bug 1, vector field histogram approach, Bubble and band technique, Bug 2, and TangentBug.

Preferable properties of the reaction algorithm are low computational power and the possibility to find a global minimum solution. From the algorithms mentioned above, Bug 1 and Bug 2 are simple to implement, but might be a bit too simple when it comes to optimization properties. The vector field his- togram approach, which models the quadcopter to move in arcs or straight-line does not fit our model. The Bubble and band technique acquire a lot of global information for a fully developed path plan which also makes it unsuitable.

Therefore, the TangentBug (TB) was selected, which is an improvement of the Bug 2 algorithm with the property to possibly find a global minimum solution by using small amounts of global information [5].

The TB algorithm are using different functions such as, atan2[46] defined,

atan2(y, x)≡















arctan(yx) , x > 0

arctan(yx) + π , x < 0, y ≥ 0 arctan(yx)− π , x < 0, y < 0 +π2 , x = 0, y > 0

π2 , x = 0, y < 0 undefined , x = 0, y = 0

(3.18)

and the Euclidean distance d ϵ IR3[47], d =

(x2− x1)2 + (y2− y1)2+ (z2− z1)2. (3.19)

(30)

The TB algorithm is a 2D algorithm and it is applied as a 2D algo- rithm due to the thrust rate constraint, which is discussed in subsection 2.1.2, Eq.(2.12). Instead the SLAM method is 3D reactive, in such a way that it is constantly moving towards the goal height, with a thrust rate depending on the Euler angle ψ. The main feature of the TB algorithm is an algorithm known as Local Tangent Graph (LTG)[5] that locally scans its surroundings at every time step k to determine if there is a obstacle free path to the goal.

If no obstacle is found it goes straight to the goal, otherwise it uses a normal Bug2 algorithm[12] to surpass the obstacle. This feature is one of many mod- ifications of the original TB algorithm. The pseudo code for the modified TB algorithm can be found in Algorithm 2.

Algorithm 2: Modified TangentBug

Input : Goal position and current position

Output: A Boolean variable for success in reaching the goal if (not at goal) then

S(θ, ψ, d) ← LaserSensor3D;

θg ← atan2(goalPosition,currentPosition);

dmin ← min(d);

if (obstacle detected) and (dmin<threshold) then pathToGoal ← LTG(S, θg);

if (no pathToGoal) then Bug2(S);

else

quadcopter ← u(θg, ψg, θr, ψr) ; end

else

quadcopter ← u(θ, ψ, θr, ψr) ; end

else

quadcopter ← u(0, 0, 0, 0) ; at goal ←true ;

end

There are a few major differences between the modified TB algorithm described in Algorithm 2 compared to the one defined in [5]. A List of modi- fications done to the original TB algorithm can be found in Table 3.1.

(31)

Table 3.1: A point-list of modifications done to the original TangentBug algo- rithm.

Original TB:

• 1) Detection state false:

Moves towards the goal position along the locally optimal direction on the current LTGs sub-graph

• 2) Obstacle found: If local minimum found

• 3) Turn direction: Not specified

• 4) Obstacle follow: Move along the boundary using the LTG, while continuously recording dmin

• 5) Stop condition: If goal position reached or a loop around the obstacle is completed

Modified TB:

• 1) Detection state false:

Moves towards the globally optimal direction using the atan2 function

• 2) Obstacle found: If the obstacle is within a threshold

• 3) Turn direction:

Depending on angle to goal and the angle to the obstacle relative the quadcopter

• 4) Obstacle follow: Move along boundary using Bug2 with TB conditions from the LTG, while continuously recording dmin

• 5) Stop condition: If goal position reached

Point five for the modified TB algorithm in Table 3.1 does not contain any stop condition for unreachable goal positions. The reason for this is that both methods will be using a type of memoization3[48] algorithm that will keep track of the quadcopter so that it will stop if it encounters a local minimum.

In order for the memoization algorithm to find a local minimum it requires some conditions on what should count as a local minimum. In our case a local minimum is found if,

• The quadcopter is located in an earlier encountered grid cell having ap- proximately the same direction and that it is not the last new cell it was located in

• The quadcopter is stationary in a cell grid for an arbitrary defined amount of time

3Memoization is an optimization technique that is often used to speed up computer programs by e.g. storing complex data to avoid unnecessary re-calculations.

(32)

These conditions are inserted in the memoization algorithm, see Algorithm 3.

Algorithm 3: Memoization

Input : Current position Pc and current yaw angle Ac Output: Boolean variable defining minimum state Initializing positionMap;

Initializing directionMap;

Initializing time variable t;

positionMap← index corresponding to Pc; minFound←false;

if (positionMap(Pc) ̸=empty and Pc ̸= Plast) then if (t≥ tth) then

minFound←true;

else

t← newT ime();

if (directionMap(Ac)≈directionMap(Alast)) then minFound←true;

end end else

positionMap← index(Pc);

directionMap← index(Ac);

t ← 0;

end

3.2 Artificial Potential Field Approach

Pure reactive algorithms are very useful in applications that does not handle complex computations and heavy memory usage. For this thesis, an Artificial Potential Field Approach (APFA) was selected as the second approach, due to similarities to the SLAM approach, mainly the property that it strives to find a global minimum from the usage of mostly local information. The APFA was built from two functions, an attractive potential function that pulls the quadcopter towards the goal position and a repulsive potential function that pushes the quadcopter away from all detected obstacles, within its local sur- roundings.

As mentioned earlier, the APFA originates from[17]. It was constructed by[13], where the main difference between the two approaches is that the steer- ing does not come from translational movements but from angular accelera- tion, which makes it more smooth. This characteristic can be very practical for simpler stabilization systems, because it puts less load on the control-model algorithm. The progression of this subsection will go more into detail how this approach is constructed. A picture of an APFA-process can be seen in

Figure 3.2.

(33)

Figure 3.2: An overview of the constructed APFA-Process.

The constructed APFA is a hybrid between [13] and [14], where the foun- dation is taken from [13] with properties such as a second order turn rate and [14], that took [13]s concept from 2D→3D. Therefore, the attractive potential function is expressed,

A3D(θ, ψ) = kg

[ θg

ψg ]

(e−c1dg + c2), (3.20) and the repulsive potential function,

R3D(O(θ, ψ)) = ko [

s1o)s2(t1(1t2o|)) s1o)s2(t1(1 t2o|))

]

(e−c3do)

[ e−c4o| e−c4o|

]

, (3.21)

where (kg, ko) are constants set as the magnitude of attraction and repulsion, respectively, (θg, ψg, θo, ψo ) are angles to goal position and angles to obsta- cles, respectively, (dg, do) are distance to goal and obstacle, respectively and

References

Related documents

Our approach is based on earlier results by the authors on the main characteristics (dimensions of corresponding stable, unstable and center manifolds) for singular points to

To motivate the employees is the second aim of incentive systems according to Arvidsson (2004) and that is partly achieved when employees value the reward that

The proposed model has been created to provide a sound response to the following enquiry: “What concepts and principles should define a secure collaborative

The expression syntax tree has several diferent types of node objects but some of the most important are arrow expressions, non-arrow expression and arrowable expressions.. The

Every tethering mode has a reference position where the UAV is assumed to follow and stay at and the main idea with the fictitious position and the automatic control system is

The total gearbox loss differs depending on what oil and calculation method that is used to calculate the friction coefficient, Figure 35. With this plot it is also obvious which

För det tredje har det påståtts, att den syftar till att göra kritik till »vetenskap», ett angrepp som förefaller helt motsägas av den fjärde invändningen,

NORIA can be strengthened at little cost by selective mutual opening of national R&amp;D programmes to allow research and innovation funders and performers to build