This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Distributed Estimation, Control and Coordination of Quadcopter Swarm Robots

(March 29, 2017)

Introduction

In this thesis we are interested in applying distributed estimation, control and optimization techniques to enable a group of quadcopters to fly through openings. The quadcopters are assumed to be equipped with a simulated bearing and distance sensor for localization. Some quadcopters are designated as leaders who carry global position sensors. We assume quadcopters can communicate information with each other. Under these assumptions, the goal of project was achieved by completing the following tasks:

  1. 1.

    Estimate global positions from distance and bearing measurements.

  2. 2.

    Form and maintain desired shapes.

  3. 3.

    Change the scale of the formation.

  4. 4.

    Plan collision free trajectories to pass through openings.

The thesis is organized in the following way to address above challenges: Chapter 1 presented preliminary graph theory that is frequently referenced throughout the thesis. Chapter 2 gave an overview of the system set-up and explains the principle of bearing and distance sensor. Chapter 3 introduced the distributed observer for swarm localization from the bearing and distance sensor measurements. Chapter 4 discussed the distributed control for formation maintaining and chapter 5 proposed a formation scale estimation method for time varying formation scale. Finally Chapter 6 proposed two scalable trajectory optimization algorithms to plan collision-free trajectories through the openings and gave an overview of the constraints.

Chapter 1 Graph Theory

The concepts presented in this chapter are mainly summarized from the book [2].

1.1 Graphs

Undirected graph

An undirected graph is a tuple G=(V,E)G=(V,E), where VV is a node list and EE is a set of edges of unordered pairs of nodes. An unordered edge is a set of two nodes {i,j}\{i,j\}, i,jV\forall i,j\in V and iji\neq j. If {i,j}E\{i,j\}\in E, then i,ji,j are called neighbors. Let NiN_{i} denote the set of neighbors of ii.

Directed graph

A directed graph (diagraph) is a tuple G=(V,E)G=(V,E), where VV is a node list and EE is a set of edges of ordered pairs of nodes. An ordered pair (i,j)(i,j) denotes an edge from ii to jj. ii is called in-neighbor of jj and jj is called out-neighbor of ii. Let NioutN^{out}_{i} denote the set of out-neighbor of ii.

Path

A path of undirected graph is an ordered sequence of nodes such that any pair of consecutive nodes is an edge of the graph.

Directed path

A directed path of a diagraph is an ordered sequence of nodes such that any pair of consecutive nodes is an edge of the diagraph.

Connectivity

An undirected graph is connected if between any pair of nodes there exist a path. A diagraph is strongly connected if there exists a directed path between any pair of nodes.

Weighted diagraph

A weighted diagraph is a triplet G=(V,E,{ae}eE)G=(V,E,\{a_{e}\}_{e\in E}), where (V,E)(V,E) is a diagraph and aea_{e} is a strictly positive scalar of an edge eEe\in E. A weighted diagraph is undirected if for any edge (i,j)E(i,j)\in E, there exist an edge (j,i)E(j,i)\in E and a(i,j)=a(j,i)a_{(i,j)}=a_{(j,i)}.

1.2 Adjacency Matrix

Given a weighted diagraph G=(V,E,{ae}eE)G=(V,E,\{a_{e}\}_{e\in E}), the adjacency matrix AA is defined as follows:

aij={a(i,j),if (i,j)E0,otherwisea_{ij}=\left\{\begin{array}[]{ll}a_{(i,j)},&\text{if $(i,j)\in E$}\\ 0,&\text{otherwise}\end{array}\right. (1.1)

The weighted out-degree matrix DoutD_{out} are defined by:

Dout=diag(A𝟏)D_{out}=\text{diag}(A\mathbf{1}) (1.2)

1.3 Laplacian Matrix

The Laplacian matrix of the weighted diagraph G=(V,E,{ae}eE)G=(V,E,\{a_{e}\}_{e\in E}) is defined as:

L\displaystyle L =DoutA\displaystyle=D_{out}-A (1.3)

and

(Lx)i\displaystyle(Lx)_{i} =jNioutaij(xixj)\displaystyle=\sum_{j\in N^{out}_{i}}a_{ij}(x_{i}-x_{j}) (1.4)

If GG is undirected,

(Lx)i=jNiaij(xixj)(Lx)_{i}=\sum_{j\in N_{i}}a_{ij}(x_{i}-x_{j}) (1.5)

and

L𝟏=𝟎\displaystyle L\mathbf{1}=\mathbf{0} (1.6)

For an undirected graph GG, LL is symmetric. λ1=0\lambda_{1}=0 is a simple eigenvalue of LL and all other eigenvalues of LL are real and positive:

0=λ1λ2λN\displaystyle 0=\lambda_{1}\leq\lambda_{2}\leq\cdots\leq\lambda_{N} (1.7)

1.4 Incidence Matrix

Given an undirected weighted graph G=(V,E,{ae}eE)G=(V,E,\{a_{e}\}_{e\in E}), number the edges of GG with a unique e{1,,m}e\in\{1,...,m\} and assign an arbitrary direction to each edge. The direction of an edge (i,j)(i,j) is from ii to jj. ii is called the source node of (i,j)(i,j) and jj is the sink node. Then the incidence matrix B is defined element-wise as

Bie={+1,if node i is the source node of edge e1,if node i is the sink node of edge e0,otherwiseB_{ie}=\left\{\begin{array}[]{ll}+1,&\text{if node $i$ is the source node of edge $e$}\\ -1,&\text{if node $i$ is the sink node of edge $e$}\\ 0,&\text{otherwise}\end{array}\right. (1.8)

The incidence matrix BB is used to compute the difference between the values of two nodes connected by an edge ee oriented from ii to jj

(BTx)e=xixj(B^{T}x)_{e}=x_{i}-x_{j} (1.9)

Thus BT𝟏=0B^{T}\mathbf{1}=0, where 𝟏=[1,,1]T\mathbf{1}=[1,...,1]^{T}. Recall that

(Lx)i=jNiaij(xixj)(Lx)_{i}=\sum_{j\in N_{i}}a_{ij}(x_{i}-x_{j}) (1.10)

Then the Laplacian matrix LL is closely related to the incidence matrix BB through:

L=Bdiag({ae}e{1,,m})BTL=B\text{diag}(\{a_{e}\}_{e\in\{1,...,m\}})B^{T} (1.11)

The incidence matrix BTB^{T} operates on xx to compute the difference between xix_{i} and xjx_{j} of an edge (i,j)(i,j). The difference (xixj)(x_{i}-x_{j}) is then weighted by a diagonal element a(ij)a_{(ij)} of the diagonal matrix diag({ae}e{1,,m})\text{diag}(\{a_{e}\}_{e\in\{1,...,m\}}). Finally BB picks and sums the weighted differences of all edges connecting the node ii. The picking and summation properties of BB helps us to find an appropriate observer gain matrix in a later discuss about distributed observer design. Note that LL is symmetric because the weighted graph GG is undirected, i.e., a(i,j)=a(j,i)a_{(i,j)}=a_{(j,i)}.

Chapter 2 System Setup

2.1 Overview

An overview of the system is shown in Fig. 2.1. The testbed for this project is a nano quadcopter called Crazyflie 2.0. There are five main modules developed on PC in this project. A tracking module tracks the global position pig(x,y,z){}_{g}p_{i}(x,y,z) of Crazyflie ii. Then the tracked positions are used for simulating the local distance and bearing sensor measurement of Crazyflie jj measured by Crazyflie ii. A preprocessing step follows to transform the simulated local measurement to global measurement from which the distributed localization module can estimate the global position of the Crazyflie. Based on the estimated positions, Crazyflies can apply distributed control to maintain a formation [10] or plan trajectories to accomplish certain tasks [1]. In this chapter we discuss the hardware of the system and three modules: (a) Crazyflies tracking, (b) bearing and distance sensor simulation and (c) the preprocessing of the sensor measurements.

Refer to caption
Figure 2.1: Block diagram of the system

2.2 Hardware

We have in total 4 Crazyflies and 1 Crazyradio for the communication between PC and Crazyflies. Since Crazyflies cannot directly communicate with each other, all communications were completed through PC. We used vicon system to track Crazyflies. On top of each Crazyflie, a infra-red led board is attached to strengthen the signal being observed by the vicon system. We used a hula loop to resemble a ring or opening. Three vicon markers were attached to the ring for tracking its position and orientation. The hardware used in this project are shown in Fig. 2.2.

Refer to caption
(a) Crazyflie 2.0
Refer to caption
(b) Crazyradio
Refer to caption
(c) Infra-red led board
Refer to caption
(d) A ring with vicon markers attached
Figure 2.2: Available hardware

2.3 Crazyflies Tracking

The vicon system outputs a set of unordered position measurements set ZZ of which each element zz is the position measurement of a Crazyflie. Since the set is unordered, the correspondences of these measurements to the Crazyflies are unknown. In order to select the correct position measurement from the unordered measurements and be more robust to the missing measurements, we applied a kalman filter to track each Crazyflie. The Crazyflie is modelled as a random walk with unknown normally distributed acceleration aia_{i}. Assume the state vector of the Crazyflie ii is:

xi=[pivi]\displaystyle x_{i}=\begin{bmatrix}p_{i}\\ v_{i}\end{bmatrix} (2.1)

Then the random walk model of the Crazyflie is:

pi[k+1]\displaystyle p_{i}[k+1] =pi[k]+vi[k]δt\displaystyle=p_{i}[k]+v_{i}[k]\delta t (2.2)
vi[k+1]\displaystyle v_{i}[k+1] =vi[k]+ai[k]\displaystyle=v_{i}[k]+a_{i}[k] (2.3)

where δt=5\delta t=5ms is the time interval between two consecutive measurements of vicon system. We applied the standard kalman filter to estimate the state xx. Let p^p,i[k]\hat{p}_{p,i}[k] and v^p,i[k]\hat{v}_{p,i}[k] denote the prior updates of position and velocity of Crazyflie ii and p^m,i[k]\hat{p}_{m,i}[k] and v^m,i[k]\hat{v}_{m,i}[k] denote the measurement updates of Crazyflie ii. Then the prediction step at time kk for Crazyflie ii is:

p^p,i[k+1]\displaystyle\hat{p}_{p,i}[k+1] =p^m,i[k]+v^m,i[k]δt\displaystyle=\hat{p}_{m,i}[k]+\hat{v}_{m,i}[k]\delta t (2.4)
v^p,i[k+1]\displaystyle\hat{v}_{p,i}[k+1] =v^m,i[k]\displaystyle=\hat{v}_{m,i}[k] (2.5)

Since only the positions are measured, the measurement model is:

zi\displaystyle z_{i} =Hixi+wi\displaystyle=H_{i}x_{i}+w_{i} (2.6)
=[I0][pivi]+wi\displaystyle=\begin{bmatrix}I&0\end{bmatrix}\begin{bmatrix}p_{i}\\ v_{i}\end{bmatrix}+w_{i} (2.7)
=pi+wi\displaystyle=p_{i}+w_{i} (2.8)

Before performing the measurement update step, the position measurement zi[k+1]z_{i}[k+1] of Crazyflie ii should be correctly picked from the unordered measurement set ZZ. It is selected by searching a measurement zz that has the smallest euclidean distance to the predicted position z^i[k+1]=p^p,i[k+1]\hat{z}_{i}[k+1]=\hat{p}_{p,i}[k+1]:

zi[k+1]=argminzZzz^i[k+1]22\displaystyle z_{i}[k+1]=\underset{z\in Z}{\text{argmin}}\|z-\hat{z}_{i}[k+1]\|^{2}_{2} (2.9)

and the measurement update step at time kk is:

p^m,i[k+1]\displaystyle\hat{p}_{m,i}[k+1] =p^p,i[k+1]+kp,i(zi[k+1]z^i[k+1])\displaystyle=\hat{p}_{p,i}[k+1]+k_{p,i}(z_{i}[k+1]-\hat{z}_{i}[k+1]) (2.10)
v^m,i[k+1]\displaystyle\hat{v}_{m,i}[k+1] =v^p,i[k+1]+kv,i(zi[k+1]z^i[k+1])\displaystyle=\hat{v}_{p,i}[k+1]+k_{v,i}(z_{i}[k+1]-\hat{z}_{i}[k+1]) (2.11)

where kp,ik_{p,i} and kv,ik_{v,i} are estimator gains. Thus we are able to track each Crazyflie from the unordered set of positions measurements. The tracked positions will be used for simulating the global position sensors and the bearing and distance sensor on Crazyflies.

2.4 Bearing and Distance Sensor

2.4.1 Sensor Simulation

As shown in Fig. 2.3 the bearing and distance sensor attached on the Crazyflie ii measures the distance and angle zjii(r,θ,ϕ){}_{i}z_{ji}(r,\theta,\phi) of Crazyflie jj in its local coordinate Σi\Sigma^{i}.

Refer to caption
Figure 2.3: Bearing and distance sensor

The local bearing and distance measurement zjii(r,θ,ϕ){}_{i}z_{ji}(r,\theta,\phi) is basically a Spherical coordinate representation. To simulate the bearing and distance sensor from vicon measurements, we first compute the global relative position measurement zjig{}_{g}z_{ji} from the tracked positions zig{}_{g}z_{i} and zjg{}_{g}z_{j}.

zjig=zjgzig{}_{g}z_{ji}=\text{${{}_{g}z_{j}}-{{}_{g}z_{i}}$} (2.12)

and we can obtain the local representation of zjig{}_{g}z_{ji} in the local coordinate frame Σi\Sigma^{i} through the attitude matrix R^ig{}_{ig}\hat{R} that is estimated by Crazyflie on-board attitude estimator:

zjii=R^1gigzji{}_{i}z_{ji}={{}_{ig}\hat{R}^{-1}}_{g}z_{ji} (2.13)

Let zjii=(x,y,z){}_{i}z_{ji}=(x,y,z), then the local bearing and distance measurement (r,θ,ϕ)(r,\theta,\phi) can be found as:

r\displaystyle r =x2+y2+z2\displaystyle=\sqrt{x^{2}+y^{2}+z^{2}} (2.14)
θ\displaystyle\theta =arccoszx2+y2+z2\displaystyle=\arccos\frac{z}{\sqrt{x^{2}+y^{2}+z^{2}}} (2.15)
ϕ\displaystyle\phi =arctanyx\displaystyle=\arctan\frac{y}{x} (2.16)

2.4.2 Preprocessing of Sensor Measurements

To estimate the global position pig{}_{g}p_{i} from the local bearing and distance zjii(r,θ,ϕ){}_{i}z_{ji}(r,\theta,\phi) of neighbor jj, a preprocessing step of transforming the Spherical representation to the global Cartesian representations is necessary. This transformation is illustrated in Fig. 2.4. For a distance and bearing measurement zjii(r,θ,ϕ){}_{i}z_{ji}(r,\theta,\phi) measured in Crazyflie ii’s coordinate Σi\Sigma^{i}, we first transform it to the local Cartesian representation zjii(x,y,z){}_{i}z_{ji}(x,y,z).

zjii(x,y,z)=[xyz]i=[rsinθcosϕrsinθsinϕrcosθ]{}_{i}z_{ji}(x,y,z)=\prescript{}{i}{\begin{bmatrix}x\\ y\\ z\end{bmatrix}}=\begin{bmatrix}r\sin\theta\cos\phi\\ r\sin\theta\sin\phi\\ r\cos\theta\end{bmatrix} (2.17)

Furthermore, the local Cartesian representation can also be transformed to the global Cartesian representation through the attitude matrix R^gi\prescript{}{gi}{\hat{R}}.

zjig(x,y,z)=[xyz]g=R^gi[xyz]i{}_{g}z_{ji}(x,y,z)=\prescript{}{g}{\begin{bmatrix}x\\ y\\ z\end{bmatrix}}=\prescript{}{gi}{\hat{R}}\prescript{}{i}{\begin{bmatrix}x\\ y\\ z\end{bmatrix}} (2.18)
Refer to caption
(a) Local Spherical representation in Σi\Sigma^{i}
Refer to caption
Refer to caption
(b) Local Cartesian representation in Σi\Sigma^{i}
Refer to caption
Refer to caption
(c) Global Cartesian representation in Σg\Sigma^{g}
Figure 2.4: Transformation of local bearing and distance measurement in Spherical representation to global Cartesian representation

With the global representation of relative position zjig(x,y,z){}_{g}z_{ji}(x,y,z), the distributed observer is able to estimate the global positions of Crazyflies. Note that the attitude matrix R^gi\prescript{}{gi}{\hat{R}} plays a crucial role here for the simulation and the preprocessing of the distance and bearing measurements.

2.5 Parameters

The parameters we used for tracking Crazyflie ii, i1,,Ni\in 1,...,N when the discretization time step δt=5\delta t=5ms are:

kp,i=0.8\displaystyle k_{p,i}=0.8 (2.19)
kv,i=0.0005\displaystyle k_{v,i}=0.0005 (2.20)

Chapter 3 Distributed Observer

3.1 Observer Design

Refer to caption
(a) Global and relative position measurements
Refer to caption
(b) Reverse the direction of relative measurements
Refer to caption
(c) Fuse measurements with predictions
Figure 3.1: Measurement update step

We assume that the underlying graph G=(V,E)G=(V,E) of the measurements is undirected and connected, that is, both Crazyflie ii and jj have the relative position measurement zijg{}_{g}z_{ij}, after the preprocessing step. Let the edge (i,j)(i,j) of GG be numbered with a unique e{1,,m}e\in\{1,...,m\} and consider all NN Crazyflies are modeled as double-integrators in nn-dimensional space (n=3):

{p˙i=vi,v˙i=ui,,i={1,,N}\left\{\begin{array}[]{l}\dot{p}_{i}=v_{i},\\ \dot{v}_{i}=u_{i},\end{array}\right.,i=\{1,\ldots,N\} (3.1)

The system dynamics in state space is:

[p˙v˙]=[0InN00]:=A[pv]+[0InN]:=Bu\begin{bmatrix}\dot{p}\\ \dot{v}\end{bmatrix}=\underbrace{\begin{bmatrix}0&I_{nN}\\ 0&0\end{bmatrix}}_{\text{:=$A$}}\begin{bmatrix}p\\ v\end{bmatrix}+\underbrace{\begin{bmatrix}0\\ I_{nN}\end{bmatrix}}_{\text{:=$B$}}u (3.2)

As discussed in the previous chapter, the relative measurements are represented in global Cartesian coordinate zjig(x,y,z){}_{g}z_{ji}(x,y,z). From now on, the prescript "g""g" and (x,y,z)(x,y,z) are dropped from zjig(x,y,z){}_{g}z_{ji}(x,y,z) for more concise notation.

We are able to express the relative measurements zijz_{ij} and the global measurements ziz_{i} through the incidence matrix BB and the selection matrix EE, where the selection matrix is defined as

E\displaystyle E =[ei||],iVg\displaystyle=\begin{bmatrix}\cdots\underset{|}{\overset{|}{e_{i}}}\cdots\end{bmatrix},\quad i\in V_{g} (3.3)

and ETzE^{T}z is a vector of all global measurements:

(ETz)k\displaystyle(E^{T}z)_{k} =zi,iVg\displaystyle=z_{i},\quad i\in V_{g} (3.4)

where VgV_{g} is the node list of Crazyflies that carry global position sensors. eie_{i} is the iith column of the identity matrix INI_{N}. Let x=[pT,vT]Tx=[p^{T},v^{T}]^{T} and x^=[p^T,v^T]T\hat{x}=[\hat{p}^{T},\hat{v}^{T}]^{T}. Then we decompose all measurements into relative and absolute measurements as follows:

z\displaystyle z =Hx+w\displaystyle=Hx+w (3.5)
=[BTIn0ETIn0][pv]+w\displaystyle=\begin{bmatrix}B^{T}\otimes I_{n}&0\\ E^{T}\otimes I_{n}&0\end{bmatrix}\begin{bmatrix}p\\ v\end{bmatrix}+w (3.6)

The kronecker product \otimes generalizes system to n-dimentional space and ww is the vector of measurement noise. A typical state observer can be designed as:

x^˙\displaystyle\dot{\hat{x}} =Ax^+Bu+L(zz^)\displaystyle=A\hat{x}+Bu+L(z-\hat{z}) (3.7)
z^\displaystyle\hat{z} =Hx^\displaystyle=H\hat{x} (3.8)
z\displaystyle z =Hx+w\displaystyle=Hx+w (3.9)

Usually a steady state optimal kalman filter KK_{\infty} will be used to design the gain LL:

x^˙=Ax^+Bu+K(zz^)\dot{\hat{x}}=A\hat{x}+Bu+K_{\infty}(z-\hat{z}) (3.10)

However the optimal kalman gain KK_{\infty} is a dense matrix that will fuse all measurements zz available in the network to update each Crazyflie ii’s state x^i\hat{x}_{i} [7]. This is not possible since the measurements and communications are only local and the local state observer of agent ii updates states only from the neighbors’ relative measurements and from its own global position measurements:

[p^˙iv^˙i]\displaystyle\begin{bmatrix}\dot{\hat{p}}_{i}\\ \dot{\hat{v}}_{i}\end{bmatrix} =[0In00][p^iv^i]+[0In]ui+([kpkpkvkv]In)[jNikrp,ij(zijz^ij)kgp,i(ziz^i)]\displaystyle=\begin{bmatrix}0&I_{n}\\ 0&0\end{bmatrix}\begin{bmatrix}\hat{p}_{i}\\ \hat{v}_{i}\end{bmatrix}+\begin{bmatrix}0\\ I_{n}\end{bmatrix}u_{i}+\left(\begin{bmatrix}k_{p}&k_{p}\\ k_{v}&k_{v}\end{bmatrix}\otimes I_{n}\right)\begin{bmatrix}\sum_{j\in N_{i}}k_{rp,ij}(z_{ij}-\hat{z}_{ij})\\ k_{gp,i}(z_{i}-\hat{z}_{i})\end{bmatrix} (3.11)

where krp,i>0k_{rp,i}>0 and kgp,i0k_{gp,i}\geq 0 control the weights of the measurements available to ii and kgp,i=0k_{gp,i}=0 if Crazyflie ii does not have global position measurement. kpk_{p} and kvk_{v} were used to fine-tune the gains for updating positions and velocities. Note that jNi\sum_{j\in N_{i}} only sums local weighted relative measurements error krp,i(zijz^ij)k_{rp,i}(z_{ij}-\hat{z}_{ij}). As shown in Fig. 3.1(c), (zij+z^j)(z_{ij}+\hat{z}_{j}) can be viewed as a global position measurement of ii and its difference with the prediction of global position z^i\hat{z}_{i} is the measurement error:

zij+z^jz^i=zijz^ij\displaystyle z_{ij}+\hat{z}_{j}-\hat{z}_{i}=z_{ij}-\hat{z}_{ij} (3.12)

Let Drp=diag({krp,e})e1,,mD_{rp}=\text{diag}(\{k_{rp,e}\})_{e\in{1,...,m}}, then BDrpBTBD_{rp}B^{T} is a Laplacian matrix and

(BDrpBT(zz^))i=jNikrp,ij(zijz^ij)\displaystyle(BD_{rp}B^{T}(z-\hat{z}))_{i}=\sum_{j\in N_{i}}k_{rp,ij}(z_{ij}-\hat{z}_{ij}) (3.13)

Let Dgp=diag({kgp,i})iVgD_{gp}=\text{diag}(\{k_{gp,i}\})_{i\in V_{g}}, then

(EDgpET(zz^))i=kgp,i(ziz^i)\displaystyle(ED_{gp}E^{T}(z-\hat{z}))_{i}=k_{gp,i}(z_{i}-\hat{z}_{i}) (3.14)

Therefore the distributed observer can be written in a compact form as:

[p^˙v^˙]\displaystyle\begin{bmatrix}\dot{\hat{p}}\\ \dot{\hat{v}}\end{bmatrix} =[0InN00][p^v^]+[0InN]u+L1H[zz^]\displaystyle=\begin{bmatrix}0&I_{nN}\\ 0&0\end{bmatrix}\begin{bmatrix}\hat{p}\\ \hat{v}\end{bmatrix}+\begin{bmatrix}0\\ I_{nN}\end{bmatrix}u+L_{1}H\begin{bmatrix}z-\hat{z}\end{bmatrix} (3.15)

and the observer gain L1L_{1} is:

L1\displaystyle L_{1} =[kpBDrpkpEDgpkvBDrpkvEDgp]In\displaystyle=\begin{bmatrix}k_{p}BD_{rp}&k_{p}ED_{gp}\\ k_{v}BD_{rp}&k_{v}ED_{gp}\end{bmatrix}\otimes I_{n} (3.16)

3.2 Stability

To study the stability of above observer, let e=[pT,vT]T[p^T,v^T]Te=[p^{T},v^{T}]^{T}-[\hat{p}^{T},\hat{v}^{T}]^{T}. Then

e˙=(AL1H):=𝒪e\dot{e}=\underbrace{(A-L_{1}H)}_{\text{:=$\mathcal{O}$}}e (3.17)

and

𝒪=AL1H\displaystyle\mathcal{O}=A-L_{1}H =[0InN00][kpBDrpkpEDapkvBDrpkvEDap]In[BT0ET0]In\displaystyle=\begin{bmatrix}0&I_{nN}\\ 0&0\end{bmatrix}-\begin{bmatrix}k_{p}BD_{rp}&k_{p}ED_{ap}\\ k_{v}BD_{rp}&k_{v}ED_{ap}\end{bmatrix}\otimes I_{n}\begin{bmatrix}B^{T}&0\\ E^{T}&0\end{bmatrix}\otimes I_{n} (3.18)
=[0InN00][kpBDrpBT+kpEDapET0kvBDrpBT+kvEDapET0]In\displaystyle=\begin{bmatrix}0&I_{nN}\\ 0&0\end{bmatrix}-\begin{bmatrix}k_{p}BD_{rp}B^{T}+k_{p}ED_{ap}E^{T}&0\\ k_{v}BD_{rp}B^{T}+k_{v}ED_{ap}E^{T}&0\end{bmatrix}\otimes I_{n} (3.19)
=[kpBDrpBTkpEDapETINkvBDrpBTkvEDapET0]:=𝒪In\displaystyle=\underbrace{\begin{bmatrix}-k_{p}BD_{rp}B^{T}-k_{p}ED_{ap}E^{T}&I_{N}\\ -k_{v}BD_{rp}B^{T}-k_{v}ED_{ap}E^{T}&0\end{bmatrix}}_{:=\mathcal{O^{\prime}}}\otimes I_{n} (3.20)

To ensure the observer estimates states properly, the error dynamics matrix 𝒪\mathcal{O} needs to be asymptotically stable. The kronecker product only add multiplicities of each eigenvalues and do not affect stability. We then find eigenvalues of 𝒪\mathcal{O^{\prime}} to study the stability of 𝒪\mathcal{O} by solving det(λI2N𝒪)=0det(\lambda I_{2N}-\mathcal{O^{\prime}})=0.

det(λI2N𝒪)\displaystyle det(\lambda I_{2N}-\mathcal{O^{\prime}}) =det([λIN00λIN][kpBDrpBTkpEDapETINkvBDrpBTkvEDapET0])\displaystyle=det(\begin{bmatrix}\lambda I_{N}&0\\ 0&\lambda I_{N}\end{bmatrix}-\begin{bmatrix}-k_{p}BD_{rp}B^{T}-k_{p}ED_{ap}E^{T}&I_{N}\\ -k_{v}BD_{rp}B^{T}-k_{v}ED_{ap}E^{T}&0\end{bmatrix}) (3.21)
=det([λIN+kpBDrpBT+kpEDapETINkvBDrpBT+kvEDapETλIN])\displaystyle=det(\begin{bmatrix}\lambda I_{N}+k_{p}BD_{rp}B^{T}+k_{p}ED_{ap}E^{T}&-I_{N}\\ k_{v}BD_{rp}B^{T}+k_{v}ED_{ap}E^{T}&\lambda I_{N}\end{bmatrix}) (3.22)
=det(λ2IN+λkpBDrpBT+λkpEDapET+kvBDrpBT+kvEDapET)\displaystyle=det(\lambda^{2}I_{N}+\lambda k_{p}BD_{rp}B^{T}+\lambda k_{p}ED_{ap}E^{T}+k_{v}BD_{rp}B^{T}+k_{v}ED_{ap}E^{T}) (3.23)
=det(λ2IN+(λkp+kv)(BDrpBT+EDapET:=𝒯))\displaystyle=det(\lambda^{2}I_{N}+(\lambda k_{p}+k_{v})(\underbrace{BD_{rp}B^{T}+ED_{ap}E^{T}}_{\text{$:=\mathcal{T}$}})) (3.24)

Let μi\mu_{i} be iith eigenvalue of 𝒯\mathcal{T}, then

det(λ2IN+(λkp+kv)𝒯)=iN(λ2+(λkp+kv)μi)=0\displaystyle det(\lambda^{2}I_{N}+(\lambda k_{p}+k_{v})\mathcal{T})=\prod_{i}^{N}(\lambda^{2}+(\lambda k_{p}+k_{v})\mu_{i})=0 (3.25)

Then we can solve above equation to find λ\lambda

λ2+(λkp+kv)μi=0\displaystyle\lambda^{2}+(\lambda k_{p}+k_{v})\mu_{i}=0 (3.26)

The Routh-Hurwitz stability criterion tells us that if the coefficients of second order polynomial are all positive then the roots are in the left half plane. Therefore if μi>0\mu_{i}>0, then 𝒪\mathcal{O^{\prime}} is Hurwitz. It is easy to verify that 𝒯\mathcal{T} is positive definite and thus μi>0\mu_{i}>0:

xT𝒯x\displaystyle x^{T}\mathcal{T}x =xT(BDrpBT+EDapET)x\displaystyle=x^{T}(BD_{rp}B^{T}+ED_{ap}E^{T})x (3.27)
=DrpBTx22+DapETx22\displaystyle=\|\sqrt{D_{rp}}B^{T}x\|^{2}_{2}+\|\sqrt{D_{ap}}E^{T}x\|^{2}_{2} (3.28)
0,xR3N\displaystyle\geq 0,\quad\forall x\in R^{3N} (3.29)

Since DrpBTx=0\|\sqrt{D_{rp}}B^{T}x\|=0 if and only if x=β𝟏3N=β(1,,,1)x=\beta\mathbf{1}_{3N}=\beta(1,,,1), β\beta\in\Re and ET(β𝟏3N)>0\|E^{T}(\beta\mathbf{1}_{3N})\|>0,

xT𝒯x\displaystyle x^{T}\mathcal{T}x =DrpBTx22+DapETx22>0,xR3N\displaystyle=\|\sqrt{D_{rp}}B^{T}x\|^{2}_{2}+\|\sqrt{D_{ap}}E^{T}x\|^{2}_{2}>0,\quad\forall x\in R^{3N} (3.30)

Thus μi>0\mu_{i}>0 and 𝒪\mathcal{O^{\prime}} is Hurwitz. The estimation error e~=[pT,vT]T[p^T,v^T]T\tilde{e}=[p^{T},v^{T}]^{T}-[\hat{p}^{T},\hat{v}^{T}]^{T} will asymptotically converge to zero. Thus all the agents are able to estimate positions and velocities, and we are ready to apply distributed control law to control the swarm.

3.3 Parameters

The observer gains to update position and velocity are:

kp=0.8\displaystyle k_{p}=0.8 (3.31)
kv=20.0\displaystyle k_{v}=20.0 (3.32)

(a) If i measures global position, the observer gains used in this project are:

krp,ij=kgp,i=kpNi+1,iVg\displaystyle k_{rp,ij}=k_{gp,i}=\frac{k_{p}}{N_{i}+1},\quad\forall i\in V_{g} (3.33)
krv,ij=kgv,i=kvNi+1,iVg\displaystyle k_{rv,ij}=k_{gv,i}=\frac{k_{v}}{N_{i}+1},\quad\forall i\in V_{g} (3.34)

(b) If i has no global position sensor iVVgi\in V\setminus V_{g}, then:

krp,ij=kpNi\displaystyle k_{rp,ij}=\frac{k_{p}}{N_{i}} (3.35)
kgp,i=0\displaystyle k_{gp,i}=0 (3.36)
krv,ij=kvNi\displaystyle k_{rv,ij}=\frac{k_{v}}{N_{i}} (3.37)
kgv,i=0\displaystyle k_{gv,i}=0 (3.38)

The parameters selected may not be optimal and need to be further tuned by trial and error in practice.

Chapter 4 Distributed Control

4.1 Controller Design

Let p=[,piT,]Tp^{*}=[...,p^{*T}_{i},...]^{T} and v=[,viT,]Tv^{*}=[...,v^{*T}_{i},...]^{T} be the desired global positions and velocities of all Crazyflies. Then the desired relative positions and velocities between ii and jj are pij=pipjp^{*}_{ij}=p^{*}_{i}-p^{*}_{j} and vij=vivjv^{*}_{ij}=v^{*}_{i}-v^{*}_{j}. Among the Crazyflies, leaders are able to control the global positions pip^{*}_{i} and velocities viv^{*}_{i}, whereas followers can only control the relative positions pijp^{*}_{ij} and velocities vijv^{*}_{ij}. To maintain the formation, we propose implementing following formation control law on each Crazyflie ii [10]:

ui=\displaystyle u_{i}= urp,i+urv,i+ugp,i+ugv,i\displaystyle\quad u_{rp,i}+u_{rv,i}+u_{gp,i}+u_{gv,i} (4.1)
ui=\displaystyle u_{i}= jNikrp,ij(pipjpij)\displaystyle-\sum_{j\in N_{i}}k_{rp,ij}(p_{i}-p_{j}-p^{*}_{ij}) (4.2)
jNikrv,ij(vivjvij)\displaystyle-\sum_{j\in N_{i}}k_{rv,ij}(v_{i}-v_{j}-v^{*}_{ij}) (4.3)
kgp,i(pipi)\displaystyle-k_{gp,i}(p_{i}-p_{i}^{*}) (4.4)
kgv,i(vivi)\displaystyle-k_{gv,i}(v_{i}-v_{i}^{*}) (4.5)

where urp,iu_{rp,i} controls relative positions to achieve the desired formations, urv,iu_{rv,i} controls relative velocities for the flocking behavior of the swarm, ugp,iu_{gp,i} controls the global position of the swarm, and ugv,iu_{gv,i} controls global velocity of the swarm. In addition, krp,ij>0k_{rp,ij}>0, krv,ij>0k_{rv,ij}>0 are the control gains for relative positions and velocities to neighbors. kgp,i0k_{gp,i}\geq 0, kgv,i0k_{gv,i}\geq 0 are control gains for the global positions and velocities. Only when Crazyflie ii is a leader, kgp,i>0k_{gp,i}>0, kgv,i>0k_{gv,i}>0.

We assume the underlying graph to control positions and velocities be Grp=(V,E,{krp,e}eE)G_{rp}=(V,E,\{k_{rp,e}\}_{e\in E}) and Grv=(V,E,{krv,e}eE)G_{rv}=(V,E,\{k_{rv,e}\}_{e\in E}) respectively, which are both undirected and connected. Let LpL_{p} and LvL_{v} denote the Laplacian matrices for these two graphs. Let GpG_{p} and GvG_{v} be defined element-wise as:

(Gpx)i=kgp,ixi\displaystyle(G_{p}x)_{i}=k_{gp,i}x_{i} (4.6)
(Gvx)i=kgv,ixi\displaystyle(G_{v}x)_{i}=k_{gv,i}x_{i} (4.7)

and assume the ratio of control gains of position to velocity is constant α\alpha, α\alpha\in\Re:

kgp,i\displaystyle k_{gp,i} =αkgv,i\displaystyle=\alpha k_{gv,i} (4.8)
krp,ij\displaystyle k_{rp,ij} =αkrv,ij\displaystyle=\alpha k_{rv,ij} (4.9)

Then the distributed control law in a compact form is:

u\displaystyle u =K(xx)\displaystyle=K(x-x^{*}) (4.10)
=[(LpIn)(GpIn)(LvIn)(GvIn)][ppvv]\displaystyle=\begin{bmatrix}-(L_{p}\otimes I_{n})-(G_{p}\otimes I_{n})&-(L_{v}\otimes I_{n})-(G_{v}\otimes I_{n})\end{bmatrix}\begin{bmatrix}p-p^{*}\\ v-v^{*}\end{bmatrix} (4.11)
=[(αLvIn)(αGvIn)(LvIn)(GvIn)][ppvv]\displaystyle=\begin{bmatrix}-(\alpha L_{v}\otimes I_{n})-(\alpha G_{v}\otimes I_{n})&-(L_{v}\otimes I_{n})-(G_{v}\otimes I_{n})\end{bmatrix}\begin{bmatrix}p-p^{*}\\ v-v^{*}\end{bmatrix} (4.12)

and we obtain the closed loop dynamics:

x˙\displaystyle\dot{x} =Ax+Bu\displaystyle=Ax+Bu (4.13)
x˙\displaystyle\dot{x} =Ax+BK(xx)\displaystyle=Ax+BK(x-x^{*}) (4.14)
x˙x˙\displaystyle\dot{x}^{*}-\dot{x} =x˙AxBK(xx)\displaystyle=\dot{x}^{*}-Ax-BK(x-x^{*}) (4.15)
x˙x˙\displaystyle\dot{x}^{*}-\dot{x} =x˙A(xx+x)BK(xx)\displaystyle=\dot{x}^{*}-A(x-x^{*}+x^{*})-BK(x-x^{*}) (4.16)
x˙x˙\displaystyle\dot{x}^{*}-\dot{x} =x˙AxA(xx)BK(xx)\displaystyle=\dot{x}^{*}-Ax^{*}-A(x-x^{*})-BK(x-x^{*}) (4.17)
x˙x˙\displaystyle\dot{x}^{*}-\dot{x} =Bu(A+BK)(xx)\displaystyle=Bu^{*}-(A+BK)(x-x^{*}) (4.18)

Let e=xxe=x^{*}-x, ep=ppe_{p}=p^{*}-p and ev=vve_{v}=v^{*}-v, we then obtain the following error dynamics

e˙\displaystyle\dot{e} =(A+BK)e+Bu\displaystyle=(A+BK)e+Bu^{*} (4.19)
[e˙pe˙v]\displaystyle\begin{bmatrix}\dot{e}_{p}\\ \dot{e}_{v}\end{bmatrix} =[0InN(αLvIn)(αGvIn)(LvIn)(GvIn)]:=[epev]+Bu\displaystyle=\underbrace{\begin{bmatrix}0&I_{nN}\\ -(\alpha L_{v}\otimes I_{n})-(\alpha G_{v}\otimes I_{n})&-(L_{v}\otimes I_{n})-(G_{v}\otimes I_{n})\end{bmatrix}}_{\text{$:=\mathcal{M}$}}\begin{bmatrix}e_{p}\\ e_{v}\end{bmatrix}+Bu^{*} (4.20)
=([0IN(αLv+αGv)(Lv+Gv)]:=In)[epev]+Bu\displaystyle=\left(\underbrace{\begin{bmatrix}0&I_{N}\\ -(\alpha L_{v}+\alpha G_{v})&-(L_{v}+G_{v})\end{bmatrix}}_{:=\mathcal{M}^{\prime}}\otimes I_{n}\right)\begin{bmatrix}e_{p}\\ e_{v}\end{bmatrix}+Bu^{*} (4.21)

One must make sure \mathcal{M}^{\prime} is Hurwitz such that epe_{p} and eve_{v} are bounded given uu^{*} is bounded. uu^{*} is the desired feed-forward input which is unknown.

4.2 Stability

Similar to the observer, we compute the eigenvalues of \mathcal{M}^{\prime} to test its stability:

det(λI2N)\displaystyle det(\lambda I_{2N}-\mathcal{M}^{\prime}) =det([λIN00λIN][0IN(αLv+αGv)(Lv+Gv)])\displaystyle=det(\begin{bmatrix}\lambda I_{N}&0\\ 0&\lambda I_{N}\end{bmatrix}-\begin{bmatrix}0&I_{N}\\ -(\alpha L_{v}+\alpha G_{v})&-(L_{v}+G_{v})\end{bmatrix}) (4.22)
=det([λININαLv+αGvλIN+Lv+Gv])\displaystyle=det(\begin{bmatrix}\lambda I_{N}&-I_{N}\\ \alpha L_{v}+\alpha G_{v}&\lambda I_{N}+L_{v}+G_{v}\end{bmatrix}) (4.23)
=det(λ2IN+λLv+λGv+αLv+αGv)\displaystyle=det(\lambda^{2}I_{N}+\lambda L_{v}+\lambda G_{v}+\alpha L_{v}+\alpha G_{v}) (4.24)
=det(λ2IN+(λ+α)Lv+(λ+α)Gv)\displaystyle=det(\lambda^{2}I_{N}+(\lambda+\alpha)L_{v}+(\lambda+\alpha)G_{v}) (4.25)
=det(λ2IN+(λ+α)(Lv+Gv:=Γ))\displaystyle=det(\lambda^{2}I_{N}+(\lambda+\alpha)(\underbrace{L_{v}+G_{v}}_{:=\Gamma})) (4.26)

Let γi\gamma_{i} be the iith eigenvalue of Γ\Gamma, then

det(λ2IN+(λ+α)Γ)\displaystyle det(\lambda^{2}I_{N}+(\lambda+\alpha)\Gamma) =iN(λ2+(λ+α)γi)=0\displaystyle=\prod^{N}_{i}(\lambda^{2}+(\lambda+\alpha)\gamma_{i})=0 (4.27)

Again if γi>0\gamma_{i}>0 then Re{λ}<0Re\{\lambda\}<0.

xT(Lv+Gv)x\displaystyle x^{T}(L_{v}+G_{v})x =xT(Lv+Gv)x\displaystyle=x^{T}(L_{v}+G_{v})x (4.28)
=xTLvx+xTGvx\displaystyle=x^{T}L_{v}x+x^{T}G_{v}x (4.29)
0\displaystyle\geq 0 (4.30)

where xTLvx0x^{T}L_{v}x\geq 0 since LvL_{v} is a Laplacian matrix which has non-negative eigenvalues and Lvx=0L_{v}x=0 if and only if x=β𝟏Nx=\beta\mathbf{1}_{N}, β\beta\in\Re. xTGvx0x^{T}G_{v}x\geq 0 because GvG_{v} is a diagonal matrix with non-negative diagonal. Since xTGvx>0x^{T}G_{v}x>0 when x=β𝟏Nx=\beta\mathbf{1}_{N},

xT(Lv+Gv)x=xTLvx+xTGvx>0\displaystyle x^{T}(L_{v}+G_{v})x=x^{T}L_{v}x+x^{T}G_{v}x>0 (4.31)

Thus γi>0\gamma_{i}>0 and the eigenvalue λ\lambda of \mathcal{M} has negative real part. The error dynamics matrix \mathcal{M} is asymptotically stable.

4.3 Parameters

If ii is a leader iVgi\in V_{g}, the control gains for position and velocity are:

kgp,i=9.0Ni+1\displaystyle k_{gp,i}=\frac{9.0}{N_{i}+1} (4.32)
kgv,i=4.0Ni+1\displaystyle k_{gv,i}=\frac{4.0}{N_{i}+1} (4.33)
krp,ij=9.0Ni+1\displaystyle k_{rp,ij}=\frac{9.0}{N_{i}+1} (4.34)
krv,ij=4.0Ni+1\displaystyle k_{rv,ij}=\frac{4.0}{N_{i}+1} (4.35)

If ii is a follower iVVgi\in V\setminus V_{g},

kgp,i=0\displaystyle k_{gp,i}=0 (4.36)
kgv,i=0\displaystyle k_{gv,i}=0 (4.37)
krp,ij=9.0Ni\displaystyle k_{rp,ij}=\frac{9.0}{N_{i}} (4.38)
krv,ij=4.0Ni\displaystyle k_{rv,ij}=\frac{4.0}{N_{i}} (4.39)

Basically the above parameters mean that the relative position and velocity error to the neighbors are averaged to generate the final control output. This is simple and but may not be optimal. In practice they should be fine-tuned by trial and error.

4.4 Discussion

The distributed control in this project is only suitable for maintaining formations in free space. The collision avoidance was not considered in designing the control law. In literature, Lyapunov functions with infinite potential energy were often proposed to achieve collision avoidance [11]. This is not realistic as physical systems have limited amount of actuation. This motivates us to apply optimization based trajectory generation to deal with complex environments and constraints as will be discussed in chapter 6.

Chapter 5 Formation Scale Estimation

5.1 Estimator Design

The distributed control maintains a constant shape of the formation by controlling the relative positions and velocities. Crazyflies need to know the scale factor of the relative positions and velocities to change the formation scale. In this chapter we discuss how to estimate the scale of the formation.

Assume the center of the formation is (pc,vc)(p^{c},v^{c}) and the desired relative position and velocities are (pr,vr)(p^{r},v^{r}) with zero mean, i.e., e1,,mper=0\sum_{e\in{1,...,m}}p^{r}_{e}=0 and e1,,mver=0\sum_{e\in{1,...,m}}v^{r}_{e}=0. Then we are able to write the desired trajectories of the system as:

[pv]=[pcvc]+[prvr]\displaystyle\begin{bmatrix}p^{*}\\ v^{*}\end{bmatrix}=\begin{bmatrix}p^{c}\\ v^{c}\end{bmatrix}+\begin{bmatrix}p^{r}\\ v^{r}\end{bmatrix} (5.1)

and

vr=p˙r\displaystyle v^{r}=\dot{p}^{r} (5.2)

Sometimes the desired scale of the formation change over time, for example, to avoid collisions. Then the desired relative positions and velocities are not constant anymore and the desired trajectories can be rewritten as:

[pv]\displaystyle\begin{bmatrix}p^{*}\\ v^{*}\end{bmatrix} =[pcvc]+[prp˙r]\displaystyle=\begin{bmatrix}p^{c}\\ v^{c}\end{bmatrix}+\begin{bmatrix}p^{r}\\ \dot{p}^{r}\end{bmatrix} (5.3)
=[pcvc]+[s(t)p¯rs˙(t)p¯r]\displaystyle=\begin{bmatrix}p^{c}\\ v^{c}\end{bmatrix}+\begin{bmatrix}s(t)\bar{p}^{r}\\ \dot{s}(t)\bar{p}^{r}\end{bmatrix} (5.4)

where s(t)>0s(t)>0 is the time varying scale and p¯r\bar{p}^{r} is the relative positions when s(t)=1s(t)=1. Since we only allow leaders to have the information of the desired scale s(t)s(t), the followers must communicate with neighbors to obtain this scale. One approach is that the scale s(t)s(t) can be transmitted by leaders to their neighbors who in turn transmit s(t)s(t) to their neighbors [4]. However each follower needs to know among which of its neighbors there is a path to the leaders. This may not be robust in case the roles of leaders and followers may change and the communication may be lost. A better solution is again using distributed law to fuse all neighbors’ information to estimate the scale regardless of the path to leaders [4]. Assume the underlying communication graph GG is undirected and connected with weights aija_{ij} and LsL_{s} is its Laplacian matrix. Let VgV_{g} be the list of leaders who know the desired scale s(t)s(t) and sest,i=[,sest,i,]Ts_{est,i}=[...,s_{est,i},...]^{T} be the scale estimate vector of all Crazyflies. The Crazyflie ii updates sest,is_{est,i} through:

s˙est,i=jNiaij(sest,isest,j)gi(sest,is(t))\displaystyle\dot{s}_{est,i}=-\sum_{j\in N_{i}}a_{ij}(s_{est,i}-s_{est,j})-g_{i}(s_{est,i}-s(t)) (5.5)

and

{gi=g>0,ifiVggi=0,otherwise\displaystyle\left\{\begin{aligned} g_{i}&=g>0,\quad\text{if}\ i\in V_{g}\\ g_{i}&=0,\quad\text{otherwise}\end{aligned}\right. (5.6)

Let GsG_{s} be a diagonal matrix and

(Gs)i=g,iVg\displaystyle(G_{s})_{i}=g,\quad i\in V_{g} (5.7)

Then we can write the estimation dynamics in compact form:

s˙est=LssestGs(sests𝟏N)\displaystyle\dot{s}_{est}=-L_{s}s_{est}-G_{s}(s_{est}-s\mathbf{1}_{N}) (5.8)

5.2 Stability

Let e:=sests𝟏Ne:=s_{est}-s\mathbf{1}_{N}. If s(t)s(t) is varying slowly and s˙(t)\dot{s}(t) is bounded the estimation error e(t)e(t) is bounded from the bounded input bounded state theory:

s˙ests˙𝟏N\displaystyle\dot{s}_{est}-\dot{s}\mathbf{1}_{N} =LssestGs(sests𝟏N)s˙𝟏N\displaystyle=-L_{s}s_{est}-G_{s}(s_{est}-s\mathbf{1}_{N})-\dot{s}\mathbf{1}_{N} (5.9)
e˙\displaystyle\dot{e} =(Ls+Gs)(sests𝟏N)s˙𝟏N,since Ls𝟏N=0N\displaystyle=-(L_{s}+G_{s})(s_{est}-s\mathbf{1}_{N})-\dot{s}\mathbf{1}_{N},\quad\textrm{since }L_{s}\mathbf{1}_{N}=0_{N} (5.10)
e˙\displaystyle\dot{e} =(Ls+Gs)es˙𝟏N\displaystyle=-(L_{s}+G_{s})e-\dot{s}\mathbf{1}_{N} (5.11)

As before, xTLsx0x^{T}L_{s}x\geq 0 and xTLsx=0x^{T}L_{s}x=0 if and only if x=β𝟏Nx=\beta\mathbf{1}_{N}, β\beta\in\Re and 𝟏NTGs𝟏N>0\mathbf{1}_{N}^{T}G_{s}\mathbf{1}_{N}>0. Therefore Ls+GsL_{s}+G_{s} is exponentially stable.

Note that p˙=v\dot{p}^{*}=v^{*} and p˙c=vc\dot{p}^{c}=v^{c}. Then

p\displaystyle p^{*} =pc+s(t)p¯r\displaystyle=p^{c}+s(t)\bar{p}^{r} (5.12)
v\displaystyle v^{*} =p˙c+s˙(t)p¯r\displaystyle=\dot{p}^{c}+\dot{s}(t)\bar{p}^{r} (5.13)

Substitute s(t)s(t) and s˙(t)\dot{s}(t) with the estimated scale sests_{est} and s˙est\dot{s}_{est}, we obtain

pest\displaystyle p^{*}_{est} pc+(diag(sest)In)p¯r\displaystyle\approx p^{c}+(\textrm{diag}(s_{est})\otimes I_{n})\bar{p}^{r} (5.14)
vest\displaystyle v^{*}_{est} p˙c+(diag(s˙est)In)p¯r\displaystyle\approx\dot{p}^{c}+(\textrm{diag}(\dot{s}_{est})\otimes I_{n})\bar{p}^{r} (5.15)

Then we are able to write the approximated desired trajectories as:

[pestvest][pcvc]+[diag(sest)Indiag((Ls+Gs)sest+sGs1N)In]p¯r\displaystyle\begin{bmatrix}p^{*}_{est}\\ v^{*}_{est}\end{bmatrix}\approx\begin{bmatrix}p^{c}\\ v^{c}\end{bmatrix}+\begin{bmatrix}\textrm{diag}(s_{est})\otimes I_{n}\\ \textrm{diag}(-(L_{s}+G_{s})s_{est}+sG_{s}\textbf{1}_{N})\otimes I_{n}\end{bmatrix}\bar{p}^{r} (5.16)

Thus the approximated desired relative positions and velocities are obtained from the estimated scale factor sests_{est}. Crazyflies then can apply the formation control law to maintain the estimated time varying desired relative positions and velocities.

5.3 Parameters

We again average neighbors’ estimates sest,js_{est,j}, jNij\in N_{i} to update sest,is_{est,i}:

(a) If ii is a leader, iVgi\in V_{g}, then

aij=gi=1Ni+1\displaystyle a_{ij}=g_{i}=\frac{1}{N_{i}+1} (5.17)

(b) If ii is a follower, iVVgi\in V\setminus V_{g}, then

aij=1Ni\displaystyle a_{ij}=\frac{1}{N_{i}} (5.18)
gij=0\displaystyle g_{ij}=0 (5.19)

Chapter 6 Distributed Trajectory Optimization

6.1 Centralized Trajectory Optimization

Federico proposed a discrete time trajectory optimization method to compute collision-free trajectories in a centralized manner [1]. The optimization problem is:

(6.3)

where x3NKx\in\Re^{3NK} is the stacked acceleration vectors of all quadcopters. Let TT and kk denote the trajectory duration and discretization time step, then K=ThK=\frac{T}{h}. The equality constraint Aeq=beqA_{eq}=b_{eq} represents initial and final positions and velocities of the quadcopters and the inequality constraint AinxbinA_{in}x\preceq b_{in} contains the convexified collision avoidance constraints and other physical constraints, e.g., actuator constraints. Since the jerks of quadcopter is related to the magnitude of body rates, we seek for a minimum jerk solution to reduce the aggressiveness of attitude changing during the flight [9]:

(6.6)

where DD is to compute forward difference of xx to approximate the derivative of acceleration xx. The above centralized approach scales poorly with number of Crazyflies. There are O(N2)O(N^{2}) collision avoidance constraints and O(N)O(N) optimization variables. In the following sections we discuss how to make the optimization more scalable.

6.2 Initial Solution

To obtain the convexified collision avoidance constraints and the ring constraint AinxbinA_{in}x\preceq b_{in}, we need either an initial guess or a previous solution. Here we discuss one possible solution as the initial guess.

We first solve the optimization problem 6.6 without AinbinA_{in}\preceq b_{in} to find a straight line solution for each Crazyflie without considering the collision avoidance and ring constraints, which is shown in figure 6.1

Refer to caption
Figure 6.1: Straight line solution

The straight line solution is used for finding a proper crossing time kck_{c} to impose the ring constraint. Then a velocity constraint at the position of the crossing time is imposed and the initial solution is refined such that it passes through the center of ring perpendicularly with a reasonable speed.

Refer to caption
Figure 6.2: Re-optimized solution passing through the center of ring
Refer to caption
Figure 6.3: A coordinate rorxryrzr_{o}-r_{x}r_{y}r_{z} is attached to the ring to represent the location and attitude of ring

6.3 Collision Avoidance Constraints

There are two types of collisions considered to solve the optimization problem 6.6:

6.3.1 Collisions between Crazyflie and ring

The ring resembles an opening that only its interior is allowed to pass through as illustrated in Fig. 6.3. Therefore, Crazyflie should avoid hitting on or bypassing the ring. The ring object can be modelled as a convex circle constraint if we know the time to impose it when the Crazyflie crosses the ring. However it is unknown before solving the optimization problem. The following steps estimate a crossing time and convexify the ring constraint using an initial or previous qqth solution piq[k]p^{q}_{i}[k]:

  1. 1.

    find kci=argmink1,,Kpiq[k]ro22k^{i}_{c}=\underset{k\in 1,...,K}{\text{argmin}}\|p^{q}_{i}[k]-r_{o}\|^{2}_{2}

  2. 2.

    let piq+1[kci]tubep^{q+1}_{i}[k^{i}_{c}]\in tube

  3. 3.

    let piq+1[kci1]leftConep^{q+1}_{i}[k^{i}_{c}-1]\in leftCone

  4. 4.

    let piq+1[kci+1]rightConep^{q+1}_{i}[k^{i}_{c}+1]\in rightCone

We used a tube and two cones to approximate the ring constraint such that Crazyflie will avoid collisions before and after passing through it. The reason for imposing only two cone constraints is that it makes the constraints only be local near the ring and will not affect the optimization of trajectory far from the ring. This on one hand limits the number of constraints and on the other hand it also reduces the chances of infeasibility when the initial or final position that cannot be optimized are not within the cone, which results in an infeasible problem.

tube
|ryT(piq+1[kci]ro)|Rtube\displaystyle\left|{r}_{y}^{T}(p^{q+1}_{i}[k^{i}_{c}]-r_{o})\right|\leq R_{tube} (6.7)
|rzT(piq+1[kci]ro)|Rtube\displaystyle\left|{r}_{z}^{T}(p^{q+1}_{i}[k^{i}_{c}]-r_{o})\right|\leq R_{tube} (6.8)
leftCone
|ryT(piq+1[kci1]ro)|rxT(piq+1[kci1]ro)\displaystyle\left|{r}_{y}^{T}(p^{q+1}_{i}[k^{i}_{c}-1]-r_{o})\right|\leq{r}_{x}^{T}(p^{q+1}_{i}[k^{i}_{c}-1]-r_{o}) (6.9)
|rzT(piq+1[kc1]ro)|rxT(piq+1[kci1]ro)\displaystyle\left|{r}_{z}^{T}(p^{q+1}_{i}[k_{c}-1]-r_{o})\right|\leq{r}_{x}^{T}(p^{q+1}_{i}[k^{i}_{c}-1]-r_{o}) (6.10)
rightCone
|ryT(piq+1[kci+1]ro)|rxT(piq+1[kci+1]ro)\displaystyle\left|{r}_{y}^{T}(p^{q+1}_{i}[k^{i}_{c}+1]-r_{o})\right|\leq-{r}_{x}^{T}(p^{q+1}_{i}[k^{i}_{c}+1]-r_{o}) (6.11)
|rzT(piq+1[kci+1]+ro)|rxT(piq+1[kci+1]ro)\displaystyle\left|{r}_{z}^{T}(p^{q+1}_{i}[k^{i}_{c}+1]+r_{o})\right|\leq-{r}_{x}^{T}(p^{q+1}_{i}[k^{i}_{c}+1]-r_{o}) (6.12)
Refer to caption
(a) Impose tube (green), leftCone (red) and rightCone (blue) constraints to approximate the ring constraint
Refer to caption
(b) The resulting new trajectory after imposing the approximated ring constraint
Figure 6.4: Cross section diagram of ring constraint.

6.3.2 Collisions between Crazyflies

To avoid collisions between Crazyflies themselves at each kk, a safe distance margin Rcollision=0.3R_{collision}=0.3m between Crazyflies’ centers is enforced. This margin is large enough to tolerate certain control error when Crazyflies are tracking the trajectories. The collision avoidance constraint between Crazyflies ii and jj at time kk is a non-convex constraint:

pi[k]pj[k]2Rcollisioni,j1,,N,ij\displaystyle\|p_{i}[k]-p_{j}[k]\|_{2}\geq R_{collision}\quad\forall i,j\in 1,...,N,\ i\neq j (6.13)

To convexify this constraint, again we need an initial guess or previous solution piq[k],pjq[k]p^{q}_{i}[k],p^{q}_{j}[k]. Assume the new solutions are piq+1p^{q+1}_{i} and pjq+1p^{q+1}_{j}, then the convexified constraint is [1]:

ηT(piq+1[k]pjq+1[k])Rcollision,η=piq[k]pjq[k]piq[k]pjq[k]2\displaystyle\eta^{T}(p^{q+1}_{i}[k]-p^{q+1}_{j}[k])\geq R_{collision},\quad\eta=\frac{p^{q}_{i}[k]-p^{q}_{j}[k]}{\|p^{q}_{i}[k]-p^{q}_{j}[k]\|_{2}} (6.14)

Note that this convexified constraint assumes the optimization variables are piq+1[k],pjq+1[k]p^{q+1}_{i}[k],p^{q+1}_{j}[k]. We can also optimize only piq+1[k]p^{q+1}_{i}[k] for Crazyflie ii and pjq+1[k]p^{q+1}_{j}[k] for Crazyflie jj independently [3].

ηT(piq+1[k]pjq[k])Rcollision,η=piq[k]pjq[k]piq[k]pjq[k]2\displaystyle\eta^{T}(p^{q+1}_{i}[k]-p^{q}_{j}[k])\geq R_{collision},\quad\eta=\frac{p^{q}_{i}[k]-p^{q}_{j}[k]}{\|p^{q}_{i}[k]-p^{q}_{j}[k]\|_{2}} (6.15)
ηT(piq[k]pjq+1[k])Rcollision,η=piq[k]pjq[k]piq[k]pjq[k]2\displaystyle\eta^{T}(p^{q}_{i}[k]-p^{q+1}_{j}[k])\geq R_{collision},\quad\eta=\frac{p^{q}_{i}[k]-p^{q}_{j}[k]}{\|p^{q}_{i}[k]-p^{q}_{j}[k]\|_{2}} (6.16)

As shown in Fig. 6.5, the convexified constraints Eqn. 6.14 and Eqn. 6.15 are different. Eqn. 6.14 is a relative constraint that the infeasible region can move along the direction of η\eta, whereas Eqn. 6.14 is an absolute constraint that the infeasible region is static. Clearly the collision constraints convexified with Eqn. 6.14 have larger feasible regions.

Refer to caption
(a)
Refer to caption
(b)
Refer to caption
(c)
Figure 6.5: Collision avoidance constraints. Fig.(a) illustrates the original non-convex collision avoidance constraint Eqn. 6.13. Fig.(b) illustrates the convexified constraint Eqn. 6.14. Fig.(c) illustrates the convexified constraint Eqn. 6.15.

6.4 Distributed Constrained Convex Optimization

After discussing constructing initial solution and convexfication of collision constraints, we begin discussing the method to make the optimization problem more scalable. Recently there is an increasing interest in enabling agents to cooperatively solve the following distributed constrained convex optimization:

(6.19)

where each fif_{i} is a local objective function and XiX_{i} is a local feasible set. The important observation here is that both the objective function f0f_{0} and constraint set XX are decomposed as individual local objective functions and feasible sets. The distributed projected subgradient algorithm to solve the above problem is [6]:

xi(m+1)=PXi[jNiiaijxj(m)αmdi(m)]\displaystyle x_{i}(m+1)=P_{X_{i}}\left[\sum_{j\in N_{i}\cup i}a_{ij}x_{j}(m)-\alpha_{m}d_{i}(m)\right] (6.20)

where xi(m)3NKx_{i}(m)\in\Re^{3NK} is the local estimate of xx at time m, aija_{ij} is an entry of adjacency matrix AA of the underlying communication graph GG, αm>0\alpha_{m}>0 is the step size of subgradient algorithm at time mm, and di(m)d_{i}(m) is a subgradient of local objective function at jNiiaijxj(m)\sum_{j\in N_{i}\cup i}a_{ij}x_{j}(m). PXi[x]P_{X_{i}}[x] is the projection of xx onto XiX_{i}, i.e. PXi(x)=argminx¯Xix¯xP_{X_{i}}(x)=\textrm{argmin}_{\bar{x}\in X_{i}}\|\bar{x}-x\|. The distributed projected subgradient algorithm converges as mm\rightarrow\infty:

limmxi(m)xj(m)22=0\displaystyle\lim_{m\rightarrow\infty}\|x_{i}(m)-x_{j}(m)\|^{2}_{2}=0 (6.21)

under the following assumptions [6]:

  1. 1.

    XX is nonempty and has nonempty interior.

  2. 2.

    The graph GG is fixed and strongly connected.

  3. 3.

    aij>ηa_{ij}>\eta, 0<η<10<\eta<1.

  4. 4.

    AA is doubly stochastic.

  5. 5.

    XX is compact.

  6. 6.

    m=0+αm=+\sum^{+\infty}_{m=0}\alpha_{m}=+\infty and m=0+αm2<\sum^{+\infty}_{m=0}\alpha^{2}_{m}<\infty

Remark 1.

The xi(m)x_{i}(m) is a local estimate of xx at time m. The termination condition of the algorithm is that all the local estimates converge sufficiently close to each other, i.e., xi(m)xj(m)22<ϵ\|x_{i}(m)-x_{j}(m)\|^{2}_{2}<\epsilon, and we may assume at most MM iterations the algorithm can converge.

Remark 2.

There are three operations involved in this algorithm. (a) jNiiaijxj(m)\sum_{j\in N_{i}\cup i}a_{ij}x_{j}(m) is a standard distributed averaging step such that xi(m)x_{i}(m) and xj(m)x_{j}(m) reach consensus as mm\rightarrow\infty. (b) αmdi(m)-\alpha_{m}d_{i}(m) is a subgradient step to reduce the local objective function value. (c) PXi[x]P_{X_{i}}[x] projects the averaged and subgradient subtracted solution to the local feasible set XiX_{i}. The combined three steps allows the local solution xi(m)x_{i}(m) to reach consensus with neighbors asymptotically as mm\rightarrow\infty and cooperatively reduce the value of objective function f0=i=1Nfi(x)f_{0}=\sum^{N}_{i=1}f_{i}(x) while satisfying their own local constraint XiX_{i} after the projection PXi[x]P_{X_{i}}[x].

In order to solve Problem 6.6, we express it in the form of problem  6.19 as:

(6.24)

where DiD_{i} computes the jerk of Crazyflie ii, Aeqx=beqA_{eq}\ x=b_{eq} is the initial to final state condition of all Crazyflies, and Ain,ixbin,iA_{in,i}\ x\preceq b_{in,i} includes the convexified collision avoidance constraints of Crazyflie ii with the remaining N1N-1 Crazyflies and other constraints local to ii, e.g., amin,ixiamax,ia_{min,i}\preceq x_{i}\preceq a_{max,i}.

Remark 3.

The assumption 1 that XX has nonempty interior does not strictly hold for problem 6.24 as the equality constraint Aeqx=beqA_{eq}\ x=b_{eq} is present. However experiments show that the algorithm still converges. One reason may be that all the Crazyflies share the same equality constraint Aeqx=beqA_{eq}\ x=b_{eq}, which does not affect the convergence of algorithm that assumes only inequality constraints exist. The assumption 3 and 4 can be guaranteed by setting aij=1Ni+1a_{ij}=\frac{1}{N_{i}+1}, which also simplifies the algorithm design. The assumption 5 is satisfied because of the actuator constraint aminxamaxa_{min}\preceq x\preceq a_{max} is compact. Finally in assumption 6, αm\alpha_{m} is the step size of subgradient used for decreasing the objective function value. Experiments show that the algorithm converges faster when αm\alpha_{m} is set close to 0. This is because the algorithm is solely trying to find a feasible point of XX without too much perturbation from the operation of subtracting subgradients. Since we are more interested in quickly finding a feasible solution rather than its optimality, we set αm=0\alpha_{m}=0 for fastest consensus rate. Although setting αm=0\alpha_{m}=0 violates assumption 6, experiments demonstrate that the algorithm always converges.

Assuming aij=1Ni+1a_{ij}=\frac{1}{N_{i}+1} and αm=0\alpha_{m}=0, the distributed projected subgradient algorithm 6.20 becomes:

xi(m+1)=PXi[jNii1Ni+1xj(m)]\displaystyle x_{i}(m+1)=P_{X_{i}}\left[\sum_{j\in N_{i}\cup i}\frac{1}{N_{i}+1}x_{j}(m)\right] (6.25)

Fig. 6.6 illustrates the process of two agents running the algorithm Eqn. 6.25. The solutions xi(m)x_{i}(m) and xj(m)x_{j}(m) asymptotically converge to the intersection XiXjX_{i}\cup X_{j} and reach consensus as mm\rightarrow\infty.

Refer to caption
Figure 6.6: Distributed projected subgradient algorithm for two agents with αm\alpha_{m} set to 0. The algorithm begins with two initial solutions xi(0)x_{i}(0) and xj(0)x_{j}(0) in their own feasible sets XiX_{i} and XjX_{j} and are progressively averaged and projected to reach consensus in the intersection of XiX_{i} and XjX_{j}.
Remark 4.

The significance of distributed projected algorithm Eqn. 6.25 is that (a) the constraint set XX is decomposed to XiX_{i} and distributed to each Crazyflie. Thus the number of constraints for each Crazyflie is small. (b) the algorithm runs in parallel. Compared to the centralized problem 6.6 where the number of constraints of XX is of order O(N2)O(N^{2}), the number of constraints of XiX_{i} of the problem 6.25 is equal to N1N-1 (because there are N1N-1 other Crazyflies for collision avoidance). The optimization may need to be solved MM times until convergence. As the solving time for convex problem increases quadratically with the number of inequalities, the runtime of problem 6.6 and algorithm 6.25 are of order O(N4)O(N^{4}) and O(M2N2)O(M^{2}N^{2}).

Remark 5.

Although XiX_{i} of Crazyflie ii contains convexified collision avoidance constraints with the remaining N1N-1 Crazyflies, it does not mean it has to have established communication channels with the rest N1N-1 Crazyflies. Fig. 6.7 illustrates an example that 4 Crazyflies are running the distributed algorithm in parallel. There are 3 convexified collision constraints in any Crazyflie ii’s local feasible set XiX_{i}. However each Crazyflie is communicating with only 2 Crazyflies. For example, Crazyflie 1 will only receive x2(m)x_{2}(m) and x3(m)x_{3}(m) at each time m.

Remark 6.

The collision avoidance constraint for any pair of Crazyflies is included in both Crazyflies’ constraint sets. For example in Fig. 6.7, the constraint sets of both Crazyflie 1 and 4 include the collision constraint pair (1,4). This is redundant for the algorithm to converge. It is sufficient to let it be included in one of feasible sets. Nonetheless, this requires a protocol for constraints assignment. For simplicity, the collision constraint for a pair of Crazyflies is included in both feasible sets.

Remark 7.

In order to convexifiy the collision avoidance constraint, before running distributed optimization, the initial solutions must be shared in the network. For the example in Fig. 6.7, Crazyflie 1 needs to know the initial solution of Crazyflie 4 to convexify the collision avoidance constraint between 1 and 4. This is accomplished through the communication path 4-2-1 or 4-3-1. This may cause significant delay when the network is large.

Refer to caption
Figure 6.7: An example of underlying communication graph for 4 Crazyflies. The arrows indicate the direction of message passing. The dashed lines indicate the existence of collision avoidance constraint between two Crazyflies.

6.5 Distributed Trajectory Optimization

6.5.1 Observations

The distributed projected algorithm 6.25 successfully reduces the problem size from O(N2)O(N^{2}) to O(N)O(N). However, even the problem size is O(N)O(N), it will be quickly become not scalable as NN grows because:

  1. 1.

    To linearize collision avoidance constraint, the initial solutions of all Crazyflies must be shared in the network, which may be time-consuming when the network is large.

  2. 2.

    The dimension of xix_{i} is equal to 3NK3NK. Therefore, the communication time of xix_{i} after each optimization may approximately linearly grow with NN.

  3. 3.

    The number of collision avoidance constraints of each Crazyflie is equal to N1N-1. As NN becomes large, the optimization will inevitably be intractable.

To address above problems, we first make three key observations:

  1. 1.

    For the distributed projected algorithm 6.25, each Crazyflie optimizes the trajectories of the remaining N1N-1 Crazyflies. Let xi=[xi1T,,xiNT]Tx_{i}=[x^{T}_{i1},...,x^{T}_{iN}]^{T}, where xij3Kx_{ij}\in\Re^{3K} is Crazyflie ii’s solution of the trajectory of Crazyflie jj. We may limit Crazyflie ii to optimize only xiix_{ii}, to accept other Crazyflies’ optimized trajectories xijx_{ij} directly without the averaging step, and to treat xijx_{ij} of other Crazyflies as static obstacles. Because the trajectories of other Crazyflies will not be optimized, Eqn.(6.15)-(6.16) are used for the convexification and the initial-to-final state constraints of other Crazyflies are also excluded from XiX_{i}. As a result, the distributed projected algorithm becomes:

    xii(m+1)\displaystyle x_{ii}(m+1) =PX¯i[xii(m)],X¯i={Aeq,ixii=beq,iA¯in,ixiib¯in,i\displaystyle=P_{\bar{X}_{i}}\left[x_{ii}(m)\right],\quad\bar{X}_{i}=\left\{\begin{aligned} A_{eq,i}\ x_{ii}=b_{eq,i}\\ \bar{A}_{in,i}\ x_{ii}\preceq\bar{b}_{in,i}\end{aligned}\right. (6.26)
    xij(m+1)\displaystyle x_{ij}(m+1) =xjj(m),jNi\displaystyle=x_{jj}(m),\quad j\in N_{i} (6.27)
    xik(m+1)\displaystyle x_{ik}(m+1) =xjk(m),kNi,jNi and if xjk is the most updated copy of xkk\displaystyle=x_{jk}(m),\quad k\notin N_{i},\ j\in N_{i}\text{ and if $x_{jk}$ is the most updated copy of $x_{kk}$} (6.28)

    where Aeq,ixii=beq,iA_{eq,i}\ x_{ii}=b_{eq,i} is the initial-to-final state constraint of Crazyflie ii and A¯in,ixiib¯in,i\bar{A}_{in,i}\ x_{ii}\preceq\bar{b}_{in,i} has the collision constraints convexified using Eqn. 6.15)- 6.16 and other constraints local to ii. Note that both XiX_{i} and X¯i\bar{X}_{i} have the same number of constraints but with different dimensionality. Eqn. 6.27 means that Crazyflie ii’s solution of neighbor jj is updated with the solution Crazyflie jj has optimized itself. Eqn. 6.28 means that to update non-neighbors’ solution xikx_{ik}, Crazyflie ii selects the most updated one among the neighbors’ solutions.

  2. 2.

    Due to the presence of collision avoidance constraints, along the resulting optimized trajectories, Crazyflies are separated by a significant amount of space from their neighbors. For those Crazyflies who are not neighbors, they are separated by other Crazyflies in between. Therefore the collision avoidance constraints for non-neighbor pairs are actually not active after all. We then could exclude these inactive constraints pairs to reduce the optimization time. This is achieved by defining an collision active region with radius of RactiveR_{active} such that only those Crazyflies who are within this region are neighbors with active collision avoidance constraints. As shown in Fig. 6.8, there are no neighbors detected at time k1k_{1}, whereas at time k2k_{2} Crazyflie i,j,ki,j,k detected neighbors among themselves because they are sufficiently close to each other.

  3. 3.

    If we are able to exclude inactive constraints for non-neighbors, then constraints involving xik,kNix_{ik},\ k\notin N_{i} are excluded from A¯in,ixb¯in,i\bar{A}_{in,i}\ x\preceq\bar{b}_{in,i}. Crazyflie ii then only need to accept neighbors’ solution xij,jNix_{ij},\ j\in N_{i}. The algorithm becomes:

    xii(m+1)\displaystyle x_{ii}(m+1) =PX~i[xii(m)],X~i={Aeq,ixii=beq,iA~in,ixiib~in,i,no non-neighbor constraints\displaystyle=P_{\tilde{X}_{i}}\left[x_{ii}(m)\right],\quad\tilde{X}_{i}=\left\{\begin{aligned} A_{eq,i}\ x_{ii}&=b_{eq,i}\\ \tilde{A}_{in,i}\ x_{ii}&\preceq\tilde{b}_{in,i},\ \text{no non-neighbor constraints}\end{aligned}\right. (6.29)
    xij(m+1)\displaystyle x_{ij}(m+1) =xjj(m),jNi\displaystyle=x_{jj}(m),\quad\forall j\in N_{i} (6.30)
Remark 8.

Without collision constraints with non-neighbors, the optimization time is significantly reduced and Crazyflie jj does not need to communicate xjkx_{jk} to Crazyflie ii any more. Therefore the communication costs are also lowered.

Algorithm 1 Distributed trajectory optimization
1:for each Crazyflie ii do
2:     (pii,vii,xii)(p_{ii},v_{ii},x_{ii})\leftarrow straightLine(pi[0],vi[0],pi[KT],vi[KT])(p_{i}[0],v_{i}[0],p_{i}[KT],v_{i}[KT])
3:     kc,iargmink1,,Kpi[k]ro22k_{c,i}\leftarrow\underset{k\in 1,...,K}{\text{argmin}}\|p_{i}[k]-r_{o}\|^{2}_{2}
4:     (pi,vi,ai)(p_{i},v_{i},a_{i})\leftarrow crossingCenter(pi[0],vi[0],pi[KT],vi[KT],pi[kc,iT],vi[kc,iT])(p_{i}[0],v_{i}[0],p_{i}[KT],v_{i}[KT],p_{i}[k_{c,i}T],v_{i}[k_{c,i}T])
5:end for
6:for each k=1,,Kk=1,...,K do
7:     m0m\leftarrow 0
8:     for all Crazyflie ii do
9:         obstacleSet(i) \leftarrow {pij|pii[k]pij[k]2Ractive,j1,,N,ji}\{p_{ij}\ |\ \|p_{ii}[k]-p_{ij}[k]\|_{2}\leq R_{active},\ \forall j\in 1,...,N,\ j\neq i\}
10:         while existCollision(piip_{ii}, obstacleSet(i)) and m<M1m<M_{1} do
11:              A~in,ixiib~in,i2ndConvexification(xii,obstacleSet(i))\tilde{A}_{in,i}\ x_{ii}\preceq\tilde{b}_{in,i}\leftarrow\text{2ndConvexification}(x_{ii},\ obstacleSet(i))
12:              xiiPX~i[xii]x_{ii}\leftarrow P_{\tilde{X}_{i}}[x_{ii}]
13:              piixiip_{ii}\leftarrow x_{ii}
14:              for all jNij\in N_{i} do
15:                  xijxjjx_{ij}\leftarrow x_{jj}
16:                  pijxijp_{ij}\leftarrow x_{ij}
17:                  obstacleSet(i)pij\text{obstacleSet(i)}\leftarrow p_{ij}
18:              end for
19:              mm+1m\leftarrow m+1
20:         end while
21:         Crazyflie ii tracks (pii[k],vii[k],xii[k])(p_{ii}[k],v_{ii}[k],x_{ii}[k])
22:     end for
23:end for
Refer to caption
(a) At k2k_{2}, i,ji,j detect collision at k3k_{3}
Refer to caption
Refer to caption
(b) At k2k_{2}, i,ji,j re-optimize and share the collision-free trajectories to their neighbors
Figure 6.8: Illustration of Alg. 1

6.5.2 The Algorithm

We summarize above observations in Alg. 1. Fig. 6.8 is an example that illustrates the process of running Alg. 1. At the beginning the flight, each Crazyflie computes an initial trajectory passing through the center of ring as explained in section 6.2 and start tracking the initial trajectory. At each time instant it is detecting neighbors who are within a sphere of radius RactiveR_{active} around it and add their trajectories to its obstacle set. The obstacle sets are used for convexifications of both collision avoidance constraints (Eqn. 6.15-  6.16) and the ring constraints (Eqn. 6.86.12). If there will be collisions between its nominal trajectory xiix_{ii} and neighbors’ trajectories xijx_{ij} in future states, xiix_{ii} will be re-optimized with Eqn. 6.29 such that future collisions are avoided and the new trajectory is shared to their neighbors (Eqn. 6.30). In Fig. 6.8(b) Crazyflie i,ji,j re-optimize and share their trajectories to their neighbors at k2k_{2}, whereas Crazyflie kk does not optimize its trajectory since there are no future collision detected with jj. Crazyflie kk only updates the obstacle set from {pjq}k\{p^{q}_{j}\}_{k} to {pjq+1}k\{p^{q+1}_{j}\}_{k} after having received the re-optimized trajectory pjq+1p^{q+1}_{j}. Note that because Crazyflie kk does not re-optimize its trajectory, the obstacle set of Crazyflie jj keeps pkqp^{q}_{k} unchanged at k2k_{2}.

Alg. 1 allows each Crazyflie to do trajectory optimization in parallel while they are flying. Their neighbors’ trajectories are dynamically added to or removed from the obstacle sets depending on the closeness to their neighbors. Thus the number of constraints and the solving time of each optimization for each Crazyflie is limited as much as possible. Unlike model predictive control, Alg.1 solves optimization only when collisions are detected in the nominal trajectories, but otherwise Crazyflies will only follow the nominal trajectories without recomputing new trajectories. In a word, the trajectory optimization of the swarm was solved in parallel by each Crazyflie with minimal number of collision constraints at only several time instants when collisions were detected.

Refer to caption
(a) piq+1[k]p^{q+1}_{i}[k] and pjq+1[k]p^{q+1}_{j}[k] are not collision-free
Refer to caption
(b) Penalize deviation to reduce the possibility of collision
Refer to caption
(c) Violated constraint always results in collision-free positions
Figure 6.9: Illustration of projection operation
Refer to caption
(d) Initial solutions
Refer to caption
(e) Final solutions
Figure 6.10: Inter-Crazyflie distances of 20 Crazyflies
Refer to caption
Figure 6.11: Planned trajectories through an opening from left to right for 20 Crazyflies

6.5.3 Convergence

As shown in Fig. 6.9(a), since Crazyflie i,ji,j optimize trajectories independently with respect to pjq,piqp^{q}_{j},p^{q}_{i}, the resulting re-optimized trajectories piq+1,pjq+1p^{q+1}_{i},p^{q+1}_{j} are only guaranteed to be collision-free with respect to pjq,piqp^{q}_{j},p^{q}_{i} but may not be collision-free between themselves. Crazyflie i,ji,j need another optimization if there exist collisions between pjq+1p^{q+1}_{j} and piq+1p^{q+1}_{i} and repeat the optimization until the trajectories are collision-free (assume at most M1M_{1} repetitions). Strictly speaking the convergence is not guaranteed [8]. Nonetheless, Alg. 1 reduces the possibility of convergence failure by solving a projection problem in line 12, where the objective of projection problem penalizes the deviation of optimized solution to previous solution. Therefore positions that are already collision-free in previous solutions will be preserved to be collision-free as much as possible. This is illustrated in Fig. 6.9(b). Note that in Fig. 6.9(c) collision constraint convexified from collision violated positions will guarantee the re-optimized positions are collision-free. Although solving projection problem also does not guarantee convergence, experiments show that convergence failures seldomly happen. An example of optimized trajectories for 20 Crazyflies are illustrated in Fig. 6.11 and the inter-Crazyflie distances of the initial solutions as well as optimized solutions are shown in Fig. 6.11. The radius of the ring is set to Rring=0.6R_{ring}=0.6m. The duration of flight is T=Kh=40×0.15s=6sT=Kh=40\times 0.15s=6s. The solver we used is ECOS, which is efficient and open-source [5].

6.5.4 Result Comparison

In this section we compare the performance of Alg. 1 with a decentralized approach that does not define a collision active region for dynamically adding or removing constraints. The decentralized approach will solve the optimization before the flight and each Crazyflie/node includes all collision avoidance constraints with others. As shown in Fig. 6.12(b), the collision set of each node contains all the trajectories of other nodes.

We solved both trajectory optimizations for 20 times and averaged the results. We compared the performance of these two approaches according to:

  1. 1.

    The average number of collision constraints for each Crazyflie

  2. 2.

    The average solving time for each Crazyflie

Fig. 6.13 demonstrates that the average number of constraints N¯collision\bar{N}_{collision} approaches N¯neighbor8\bar{N}_{neighbor}\approx 8 trajectories for Alg. 1 whereas for the decentralized approach it grows linearly. In addition, the average solving time of Alg. 1 is much less than the decentralized approach, which is explained in remark 9 and 10, and the runtime of Alg. 1 whenever a collision detected is of order O(M12N¯neighbors2)O(M_{1}^{2}\bar{N}^{2}_{neighbors}).

Remark 9.

Alg. 1 solves optimization whenever collisions are detected during the flight. Let M1M_{1} be the number of such optimizations, and the average solving time for Alg. 1 is defined as Tavg,1=Ttotal,1M1NT_{avg,1}=\frac{T_{total,1}}{M_{1}N}, whereas the decentralized approach is Tavg,2=Ttotal,2NT_{avg,2}=\frac{T_{total,2}}{N}. Because of the division of M1M_{1}, the average solving time of Alg. 1 is much less the decentralized one. The reason for dividing M1M_{1} is that for real time application, Crazyflie will track the optimized trajectory as soon as each optimization completes. Thus the solving time for each optimization is more interesting than for the total time for all optimizations each Crazyflie has ever solved.

Remark 10.

The decentralized approach in Fig. 6.12(b) often fail to find feasible solutions during optimization and need multiple times of re-convexification and re-optimization before finding the feasible solution. This is one main reason why it takes much longer time than the Alg. 1. The frequent optimization failure may be due to too many convexified non-neighbor constraints were included and the feasible region became too small. Note that the re-convexification is done by the convexification of the infeasible solution returned by the solver.

Refer to caption
(a) Alg.1 dynamically adds or removes constraints
Refer to caption
(b) All collision avoidance constraints with other nodes are taken into account
Figure 6.12: Compare Alg.1 with a decentralized approach
Refer to caption
(c) Average constraints per node v.s. number of nodes
Refer to caption
(d) Average optimization time per node v.s. number of nodes
Figure 6.13: Performance comparison

6.6 Future Improvement

Alg. 1 is fast because the re-optimized trajectory will be directed accepted by neighbors. However Alg. 1 convexifies the collision avoidance constraints using Eqn. 6.15-Eqn. 6.16 (2ndConvexification), which significantly limits the feasible region of the optimization problem. Besides, the convergence is not guaranteed using Eqn. 6.15-Eqn. 6.16, even though the projection operation may reduce this possibility. Here we propose an improvement on the Alg. 1 that uses the convexification Eqn. 6.14 (1stConvexification) so that convergence is not an issue any more at the expense of more frequent communications and optimizations. The idea is that Crazyflie ii optimize both its own and neighbors’ trajectories when collisions are detected. The algorithm is shown in Alg. 2. Similar to Alg. 6.25, Crazyflies that are running Alg. 2 average the neighbors’ and their own solutions to reach consensus, and repeatedly project the averaged solution to local feasible sets. We assume by at most M2M_{2} communications the consensus can be reached. The difference is that for Alg. 2, Crazyflies will not optimize non-neighbors solutions. Since the average number of neighbors approaches a limit, the number of neighbors’ trajectories to optimize is also limited. Therefore Alg. 2 is also scalable with the number of Crazyflies. Given communication time of the trajectories and runtime of projection are sufficiently small, Alg. 2 is superior to Alg. 1 because the convergence issue due to convexification does not exist any more and the convexified constraints have larger feasible regions. The runtime of Alg. 2 is of order O(M22N¯neighbors2)O(M^{2}_{2}\bar{N}^{2}_{neighbors}).

Algorithm 2 Distributed trajectory optimization
1:for each Crazyflie ii do
2:     (pii,vii,xii)(p_{ii},v_{ii},x_{ii})\leftarrow straightLine(pi[0],vi[0],pi[KT],vi[KT])(p_{i}[0],v_{i}[0],p_{i}[KT],v_{i}[KT])
3:     kc,iargmink1,,Kpi[k]ro22k_{c,i}\leftarrow\underset{k\in 1,...,K}{\text{argmin}}\|p_{i}[k]-r_{o}\|^{2}_{2}
4:     (pi,vi,ai)(p_{i},v_{i},a_{i})\leftarrow crossingCenter(pi[0],vi[0],pi[KT],vi[KT],pi[kc,iT],vi[kc,iT])(p_{i}[0],v_{i}[0],p_{i}[KT],v_{i}[KT],p_{i}[k_{c,i}T],v_{i}[k_{c,i}T])
5:end for
6:for each k=1,,Kk=1,...,K do
7:     m0m\leftarrow 0
8:     for all Crazyflie ii do
9:         obstacleSet(i) \leftarrow {pij|pii[k]pij[k]2Ractive,j1,,N,ji}\{p_{ij}\ |\ \|p_{ii}[k]-p_{ij}[k]\|_{2}\leq R_{active},\ \forall j\in 1,...,N,\ j\neq i\}
10:         if existCollision(piip_{ii}, obstacleSet(i)) then
11:              A~in,i[xiiT,xijT,]Tb~in,i1stConvexification(xii,obstacleSet(i))\tilde{A}_{in,i}\ [x^{T}_{ii},x^{T}_{ij},...]^{T}\preceq\tilde{b}_{in,i}\leftarrow\text{1stConvexification}(x_{ii},\ obstacleSet(i))
12:              [xiiT,xijT,]TPX~i[[xiiT,xijT,]T][x^{T}_{ii},x^{T}_{ij},...]^{T}\leftarrow P_{\tilde{X}_{i}}\left[[x^{T}_{ii},x^{T}_{ij},...]^{T}\right]
13:              while xij(m+1)xij(m)2>ϵ\|x_{ij}(m+1)-x_{ij}(m)\|_{2}>\epsilon and m<M2m<M_{2} do \triangleright Test convergence
14:                  for each jNiij\in N_{i}\cup i do
15:                       xijsNii1Ni+1xsj\begin{aligned} &x_{ij}\leftarrow\sum_{s\in N_{i}\cup i}\frac{1}{N_{i}+1}x_{sj}\end{aligned}
16:                       pijxijp_{ij}\leftarrow x_{ij}
17:                       obstacleSet(i)pij\text{obstacleSet(i)}\leftarrow p_{ij} \triangleright Update collision set
18:                  end for
19:                  mm+1m\leftarrow m+1
20:              end while
21:         end if
22:         Crazyflie ii tracks (pii[k],vii[k],xii[k])(p_{ii}[k],v_{ii}[k],x_{ii}[k])
23:     end for
24:end for

Conclusion

This master thesis presented a distributed system to enable a swarm of quadcopters to fly through the openings. The distributed estimation, control and optimization techniques were discussed in details to achieve the goal of the project: the quadcopter swarm is able to fly through an opening subject to local communication and measurement constraints.

We demonstrated that the bearing and distance sensors can be used for localization given one Crazyflie has global position measurement, and that the coupled linear and rotational dynamics of quadcopters that allows Crazyflies to estimate their attitude is crucial to the localization. Since the majority of existing work about distributed control and estimation assumed point mass model without exploring the real dynamics of agent, our work could motivate people to take advantage of the dynamics of agents in future.

We also drew a conclusion that the distributed control is only suitable in an environment of free space. For complex environment, trajectory optimization is necessary to accomplish the challenging tasks that are often difficult for distributed control such as collision avoidance. We had presented the procedures of adapting a distributed optimization method to two trajectory optimization algorithms, and discussed the performance of the first algorithm Alg. 1. The thesis was finalized with the future work where the second scalable trajectory optimization algorithm Alg. 2 was proposed and comparisons to Alg. 1 were highlighted.

Acknowledgement

Here I would like to express my sincere gratitude to Michael Hamer for giving me an opportunity to carry out the master project in Professor D’Andrea’s group. I also thank for his support, patience, continuous guidance and insightful suggestions in the past 6 months. He has been always playing a key role of encouraging me and keeping me on the right track during the course of this project.

Bibliography

  • [1] Federico Augugliaro, Angela P Schoellig, and Raffaello D’Andrea. Generation of collision-free trajectories for a quadrocopter fleet: A sequential convex programming approach. In Intelligent Robots and Systems (IROS), 2012 IEEE/RSJ International Conference on, pages 1917–1922. IEEE, 2012.
  • [2] Francesco Bullo, Jorge Cortés, and Sonia Martinez. Distributed control of robotic networks: a mathematical approach to motion coordination algorithms. Princeton University Press, 2009.
  • [3] Yufan Chen, Mark Cutler, and Jonathan P How. Decoupled multiagent path planning via incremental sequential convex programming. In Robotics and Automation (ICRA), 2015 IEEE International Conference on, pages 5954–5961. IEEE, 2015.
  • [4] Samuel Coogan, Murat Arcak, and Magnus Egerstedt. Scaling the size of a multiagent formation via distributed feedback. In Decision and Control and European Control Conference (CDC-ECC), 2011 50th IEEE Conference on, pages 994–999. IEEE, 2011.
  • [5] A. Domahidi, E. Chu, and S. Boyd. ECOS: An SOCP solver for embedded systems. In European Control Conference (ECC), pages 3071–3076, 2013.
  • [6] Peng Lin, Wei Ren, and Yongduan Song. Distributed multi-agent optimization subject to nonidentical constraints and communication delays. Automatica, 65:120–131, 2016.
  • [7] Shiyuan Lu, Che Lin, Zhiyun Lin, Ronghao Zheng, and Gangfeng Yan. Distributed kalman filter for relative sensing networks. In Control Conference (CCC), 2015 34th Chinese, pages 7541–7546. IEEE, 2015.
  • [8] Daniel Morgan, Soon-Jo Chung, and Fred Y Hadaegh. Model predictive control of swarms of spacecraft using sequential convex programming. Journal of Guidance, Control, and Dynamics, 37(6):1725–1740, 2014.
  • [9] Mark W Mueller, Markus Hehn, and Raffaello D’Andrea. A computationally efficient motion primitive for quadrocopter trajectory generation. IEEE Transactions on Robotics, 31(6):1294–1310, 2015.
  • [10] Kwang-Kyo Oh, Myoung-Chul Park, and Hyo-Sung Ahn. A survey of multi-agent formation control. Automatica, 53:424–440, 2015.
  • [11] Dimitra Panagou, Dušan M Stipanović, and Petros G Voulgaris. Distributed coordination control for multi-robot networks using lyapunov-like barrier functions. IEEE Transactions on Automatic Control, 61(3):617–632, 2016.
[Uncaptioned image]

Institute for Dynamic Systems and Control
Prof. Dr. R. D’Andrea, Prof. Dr. L. Guzzella

Title of work:

Thesis type and date:
Master Thesis,
Supervision:
Michael Hamer
Prof. Dr. Raffaello D’Andrea

Student:

Name: Zheng Jia
E-mail: [email protected]
Legi-Nr.: 13-947-254
Semester: 6

Statement regarding plagiarism:
By signing this statement, I affirm that I have read and signed the Declaration of Originality, independently produced this paper, and adhered to the general practice of source citation in this subject-area.
Declaration of Originality:
http://www.ethz.ch/faculty/exams/plagiarism/confirmation_en.pdf
Zurich, 18. 2. 2025: