**3. Trajectory planning for a set of waypoints**

Due to the low inertia of quadrotor it is necessary to calculate a smooth trajectory to minimize the risk of collapse. Euler–Lagrange equations are used to find the minimum *snap* trajectory [15, 19]. For a two waypoints trajectory, the boundary conditions of position, velocity, acceleration, and *jerk* are defined in **Table 1**.

With this boundary conditions the equations' coefficients for the two-points optimal desired trajectory are calculated for each coordinate of position (*xdes*, *ydes* and *zdes*) and orientation (*ψdes*) (8).

$$
\begin{bmatrix} \mathcal{X}\_{d\boldsymbol{\omega}} \\ \mathcal{Y}\_{d\boldsymbol{\omega}} \\ \mathcal{Z}\_{d\boldsymbol{\omega}} \\ \mathcal{Y}\_{d\boldsymbol{\omega}} \end{bmatrix} = \begin{bmatrix} c\_{1,7} & c\_{1,6} & c\_{1,5} & c\_{1,4} & c\_{1,3} & c\_{1,2} & c\_{1,1} & c\_{1,0} \\ c\_{2,7} & c\_{2,6} & c\_{2,5} & c\_{2,4} & c\_{2,3} & c\_{2,2} & c\_{2,1} & c\_{2,0} \\ c\_{3,7} & c\_{3,6} & c\_{3,5} & c\_{3,4} & c\_{3,3} & c\_{3,2} & c\_{3,1} & c\_{3,0} \\ c\_{4,7} & c\_{4,6} & c\_{4,5} & c\_{4,4} & c\_{4,3} & c\_{4,2} & c\_{4,1} & c\_{4,0} \end{bmatrix} \begin{bmatrix} t^{\beta} \\ t^{\delta} \\ t^{\delta} \\ t^{\beta} \\ t^{4} \\ t^{3} \\ t^{2} \\ t \\ \textbf{1} \end{bmatrix} \tag{8}
$$


**Table 1.** *Boundary conditions.*

*Quadrotor Unmanned Aerial Vehicles: Visual Interface for Simulation and Control… DOI: http://dx.doi.org/10.5772/intechopen.97435*

Desired angles for *roll* (*ϕdes*) and *pitch* (*θdes*) are calculated from *ψdes*, the equations depend on which control strategy is employed.

This procedure yields a minimum *snap* trajectory for two points. For additional waypoints it is necessary to consider more equations and intermediary restrictions [15].

The tool calculates the complete optimized trajectory for any set of waypoints. Desired trajectory **r***des*, orientation *ψdes*, and their derivatives are calculated for being used in the control algorithms.

#### **4. Attitude and trajectory following control strategies**

Some of the challenges to be overcome in quadrotor operation are: attitude stability for large angles, trajectory following, collision avoidance through aggressive maneuvers, monitoring, and others [2, 4].

The control architecture employed in the following control strategies uses two cascaded loops. The inner loop (attitude control) runs in a fast time-scale and is assumed exponentially stable. The outer loop (position control) runs in a slow time-scale, with a higher bandwidth [4]. All of them employ a feed-forward with proportional plus derivative structure (FF-PD). The tool is open to easily add more control strategies.

#### **4.1 Small angle control**

Besides the force each rotor produces a moment in the rigid body perpendicular to the plane of rotation of the propeller (*Mi*), contrary to the direction of rotation of the propellers. *L* is the size of the quadrotor arm (**Figure 1**) and **J** the inertia matrix

> *Jxx* 0 0 0 *Jyy* 0 0 0 *Jzz*

Due to the forces produced by the rotors, moments are produced in the rigid body (*L* � *Fi*), causing the system to rotate around the *x* and *y* axes. The rotation around the *z* axis is due to the torque created by the rotation of the motors, which are fixed to the plant. Based on the Coriolis Equation, the equation that describes

> 3 7 5

For simulating the measurement noise, the tool allows to add a random signal to position and orientation variables and their derivatives. A first order delay between the comands *u*<sup>1</sup> and **u2** and rotor speed variations, with a time constant *τ* seconds,

Due to the low inertia of quadrotor it is necessary to calculate a smooth trajectory to minimize the risk of collapse. Euler–Lagrange equations are used to find the minimum *snap* trajectory [15, 19]. For a two waypoints trajectory, the boundary conditions of position, velocity, acceleration, and *jerk* are defined in **Table 1**. With this boundary conditions the equations' coefficients for the two-points optimal desired trajectory are calculated for each coordinate of position (*xdes*, *ydes*

> *c*1,7 *c*1,6 *c*1,5 *c*1,4 *c*1,3 *c*1,2 *c*1,1 *c*1,0 *c*2,7 *c*2,6 *c*2,5 *c*2,4 *c*2,3 *c*2,2 *c*2,1 *c*2,0 *c*3,7 *c*3,6 *c*3,5 *c*3,4 *c*3,3 *c*3,2 *c*3,1 *c*3,0 *c*4,7 *c*4,6 *c*4,5 *c*4,4 *c*4,3 *c*4,2 *c*4,1 *c*4,0

**Time** *t* **Position** *xdes*ð Þ*t* **Velocity** *x*\_ *des*ð Þ*t* **Acceleration** *x*€*des*ð Þ*t* **Jerk** *x*€*des*ð Þ*t* 0 *xdes*ð Þ 0 0 00 *T xdes*ð Þ *T* 0 00

9 >=

B

�

*p q r*

3 7 5

9 >=

B

� **J**

*t* 7 *t* 6 *t* 5 *t* 4 *t* 3 *t* 2 *t* 1

(8)

*p q r*

3 7 5

9 >=

B

(7)

>;

2 6 4

8 ><

>:

>;

2 6 4

8 ><

>:

>;

3 7

<sup>5</sup> (6)

**J** ¼

*L F*ð Þ <sup>2</sup> � *F*<sup>4</sup> *L F*ð Þ <sup>1</sup> � *F*<sup>3</sup> *M*<sup>1</sup> þ *M*<sup>2</sup> þ *M*<sup>3</sup> þ *M*<sup>4</sup>

was included in the tool to simulate the rotor dynamics.

**3. Trajectory planning for a set of waypoints**

the angular acceleration in the *Frame* **B** is in (7).

2 6 4

8 ><

*Robotics Software Design and Engineering*

>:

and *zdes*) and orientation (*ψdes*) (8).

*xdes ydes zdes ψdes*

**Table 1.**

**106**

*Boundary conditions.*

2 6 4

presented in (6).

**J**

*p*\_ *q*\_ *r*\_ 3 7 5

9 >=

B

¼

>;

2 6 4

8 ><

>:

Small Angle control assumes an operation not too far from the hovering condition. A simple heuristic method with FF-PD control calculates the required accelerations for the desired trajectory (9).

$$\begin{bmatrix} \ddot{\boldsymbol{x}}\_c \\ \ddot{\boldsymbol{y}}\_c \\ \ddot{\boldsymbol{z}}\_c \end{bmatrix} = \mathbf{r}\_{des} + K\_p \mathbf{e}\_r + K\_d \mathbf{e}\_r \tag{9}$$

It is assumed small deviations from zero in *roll* and *pitch* angles, small deviations in the *yaw* angle from the desired value, and angular velocities close to zero. The algorithm assumes all upward-pointing thrust vectors (control signal *u*<sup>1</sup> in (10)).

$$
\mu\_1 = m(\mathbf{g} + \ddot{\mathbf{z}}\_c) \tag{10}
$$

After linear simplifications the equations for attitude control are defined in (11) and (12) [16].

$$\eta\_c = \begin{bmatrix} \phi\_c \\ \theta\_c \\ \psi\_c \end{bmatrix} = \begin{bmatrix} \frac{1}{g} \left( \ddot{\mathbf{x}}\_c \sin \left( \boldsymbol{\nu}\_{des} \right) - \ddot{\boldsymbol{\nu}}\_c \cos \left( \boldsymbol{\nu}\_{des} \right) \right) \\\\ \frac{1}{g} \left( \ddot{\mathbf{x}}\_c \cos \left( \boldsymbol{\nu}\_{des} \right) + \ddot{\boldsymbol{\nu}}\_c \sin \left( \boldsymbol{\nu}\_{des} \right) \right) \\\\ \boldsymbol{\nu}\_{des} \end{bmatrix} \tag{11}$$
 
$$\boldsymbol{\nu}\_c = \begin{bmatrix} \boldsymbol{p}\_c \\ \boldsymbol{q}\_c \\ \boldsymbol{r}\_c \end{bmatrix} = \mathbf{T} \boldsymbol{\eta}\_c \tag{12}$$

A PD control law is used for attitude control and to calculate **u**<sup>2</sup> (13) [16].

$$\mathbf{u}\_2 = K\_R(\eta\_\varepsilon - \eta) + K\_\nu(\nu\_\varepsilon - \nu) \tag{13}$$

#### **4.2 Desired thrust vector control**

At high speeds and *roll* and *pitch* angles far away from zero, a more robust strategy is necessary. A FF-PD control law calculates the control signal *u*<sup>1</sup> for the trajectory following and compensates the gravity. Vector **t** is calculated with the attitude for the desired effect (14). As *u*<sup>1</sup> acts along the *z* direction in frame **B** (axis **b***z*), it must be referred to frame **I** (15).

$$\mathbf{t} = m\left(\mathbf{r}\_{des} + K\_p \mathbf{e}\_r + K\_d \mathbf{e}\_r\right) + mg \mathbf{a}\_z \tag{14}$$

$$u\_1 = \mathbf{t}^T \mathbf{R} \mathbf{b}\_x \tag{15}$$

**b***<sup>x</sup>* ¼

*Quadrotor Unmanned Aerial Vehicles: Visual Interface for Simulation and Control…*

With **t** and **b***<sup>x</sup>* is possible to calculate **R***des* with (25) to (27) [17].

<sup>Ψ</sup> <sup>¼</sup> <sup>1</sup> 2

**<sup>e</sup>***<sup>R</sup>* <sup>¼</sup> <sup>1</sup> 2 **R***T des* **R**<sup>I</sup>

**4.4 Particle swarm optimization for control gains tuning**

**<sup>e</sup>***<sup>ν</sup>* <sup>¼</sup> *<sup>ν</sup>* � **<sup>R</sup>**<sup>I</sup>

The control vector **u**<sup>2</sup> is calculated in (31) [17].

*DOI: http://dx.doi.org/10.5772/intechopen.97435*

**<sup>u</sup>**<sup>2</sup> <sup>¼</sup> *<sup>ν</sup>* � **<sup>J</sup>** *<sup>ν</sup>* <sup>þ</sup> **<sup>J</sup>**ð�*KR***e***<sup>R</sup>* � *<sup>K</sup>ν***e***ν*Þ � **<sup>J</sup>** ^*ν***R**<sup>I</sup>

proportional and derivative gains (32).

the error increases above a predefined limit.

**5. The graphical user interface**

**109**

robust approach [17].

2 6 4

**<sup>b</sup>***<sup>z</sup>* <sup>¼</sup> **<sup>t</sup>**

**<sup>b</sup>***<sup>y</sup>* <sup>¼</sup> **<sup>b</sup>***<sup>z</sup>* � **<sup>b</sup>***<sup>x</sup>* k k **b***<sup>z</sup>* � **b***<sup>x</sup>*

**R***des* ¼ **b***<sup>y</sup>* � **b***<sup>z</sup>* **b***<sup>y</sup>* **b***<sup>z</sup>*

tr **<sup>I</sup>**<sup>3</sup>�<sup>3</sup> � **<sup>R</sup>***<sup>T</sup>*

Attitude tracking error and angular velocity error are calculated from (29, 30).

**<sup>B</sup>** � **<sup>R</sup>**<sup>I</sup> **B** *<sup>T</sup>* **<sup>R</sup>***des* � �<sup>∨</sup>

> **B** *T*

**<sup>R</sup>***des <sup>ν</sup>des* � **<sup>R</sup>**<sup>I</sup>

� � (32)

**B**

A PSO algorithm is employed to tune the control gains. Some adjustments were performed to reduce the processing [14, 15], s. Each particle *α<sup>i</sup>* is a vector with the

*α<sup>i</sup>* ¼ *Kp Kd KR K<sup>ν</sup>*

desired trajectory and tests each particle, calculating the RMS error. The PSO algorithm evolves in the direction of the best validated solution in each iteration, until achieving a minimum error tolerance. For faster convergence, every time a particle is evaluated, the evaluation is interrupted in the middle of the trajectory if

Using a predefined set of waypoints chosen by the user, the code calculates the

A user-friendly 3D animated GUI was developed in MatLab. It is able to evaluate and compare the performance of various quadrotor control strategies for any userchosen trajectory. A few of quadrotor parameters are easily set in this interface [15]. A red vertical line indicates the upper side of the device, and a red circle the front rotor. Waypoints are represented by red markers, the desired trajectory is on

(27) calculates the desired attitude for the quadrotor given **t** and *ψdes*. The basin of attraction Ψ (28) is bigger than in the previous strategy (23) as this is a more

> *des* **R**<sup>I</sup> **B**

cos *ψdes* sin *ψdes* 0

3 7

<sup>5</sup> (24)

k k**<sup>t</sup>** (25)

� � (27)

� �<2 (28)

*<sup>T</sup>* **<sup>R</sup>***des <sup>ν</sup>des* (30)

**B** *T* **<sup>R</sup>***des <sup>ν</sup>*\_ *des* � � (31)

(26)

(29)

The axis **b***<sup>z</sup>* is desired to be aligned with **t**. The desired rotation matrix **R***des* is calculated from the equation of rotation of **b***<sup>z</sup>* in the direction of **t** (16).

$$\mathbf{R}\_{des}\mathbf{b}\_{\mathbf{z}} = \frac{\mathbf{t}}{||\mathbf{t}||}\tag{16}$$

As we know *ψdes* we use (16) to calculate *ϕdes* and *θdes*. **R***des* is constructed with these three angles with the same structure of (2). The error in rotation Δ**R** is calculated from (17).

$$
\Delta \mathbf{R} = \left(\mathbf{R}\_{\mathbf{B}}^{\mathrm{I}}\right)^{T} \mathbf{R}\_{des} \tag{17}
$$

With the Rodrigues formula [20], the axis of rotation **v** and the rotation angle *β* are calculated (18). **I**<sup>3</sup>�<sup>3</sup> is the identity matrix and **v**^ is the skew-symmetric matrix of **v** (19). The related error is calculated with (20).

$$
\Delta \mathbf{R} = \mathbf{I}\_{3 \times 3} \cos \beta + \mathbf{v} \mathbf{v}^T (\mathbf{1} - \cos \beta) + \hat{\mathbf{v}} \sin \beta \tag{18}
$$

$$
\hat{\mathbf{v}} = \begin{bmatrix}
\mathbf{0} & -v\_3 & v\_2 \\
v\_3 & \mathbf{0} & -v\_1 \\
\end{bmatrix} \tag{19}
$$

$$\mathbf{e}\_{\mathcal{R}} = \beta \mathbf{v} \tag{20}$$

A PD control law is used to calculated **u**<sup>2</sup> (22).

$$\mathbf{e}\_{\nu} = \nu\_{\mathfrak{c}} - \nu \tag{21}$$

$$\mathbf{u}\_2 = \boldsymbol{\nu} \times \mathbf{J} \boldsymbol{\nu} + \mathbf{J} (-K\_R \, \mathbf{e}\_R - K\_\nu \, \mathbf{e}\_\nu) \tag{22}$$

Basin of attraction Ψ limits the set of rotations from which the quadrotor is able to converge to the hovering state. It is a dimension of the set of angular and linear velocities for a stable performance. For this control strategy it must be lower than 2 (23).

$$\Psi = \text{tr}\left(\mathbf{I}\_{3 \times 3} - \mathbf{R}\_{des}^T \mathbf{R}\_{\mathbf{B}}^1\right) < 2 \tag{23}$$

#### **4.3 Geometric tracking control**

Geometric Tracking Control exhibits almost global exponential attractiveness to the zero equilibrium of tracking errors [17]. **t** and *u*<sup>1</sup> are calculated as in (14) and (15). **b***<sup>x</sup>* is the desired direction vector in the first body-fixed axis (24).

*Quadrotor Unmanned Aerial Vehicles: Visual Interface for Simulation and Control… DOI: http://dx.doi.org/10.5772/intechopen.97435*

$$\mathbf{b}\_{\mathbf{x}} = \begin{bmatrix} \cos \psi\_{d\mathbf{s}} \\ \sin \psi\_{d\mathbf{s}} \\ \mathbf{0} \end{bmatrix} \tag{24}$$

With **t** and **b***<sup>x</sup>* is possible to calculate **R***des* with (25) to (27) [17].

$$\mathbf{b}\_{\mathbf{z}} = \frac{\mathbf{t}}{||\mathbf{t}||}\tag{25}$$

$$\mathbf{b}\_{\mathcal{V}} = \frac{\mathbf{b}\_{\mathbf{z}} \times \mathbf{b}\_{\mathbf{x}}}{||\mathbf{b}\_{\mathbf{z}} \times \mathbf{b}\_{\mathbf{x}}||}\tag{26}$$

$$\mathbf{R}\_{des} = \begin{bmatrix} \mathbf{b}\_{\mathcal{Y}} \times \mathbf{b}\_{\mathcal{z}} & \mathbf{b}\_{\mathcal{Y}} & \mathbf{b}\_{\mathcal{z}} \end{bmatrix} \tag{27}$$

(27) calculates the desired attitude for the quadrotor given **t** and *ψdes*. The basin of attraction Ψ (28) is bigger than in the previous strategy (23) as this is a more robust approach [17].

$$\Psi = \frac{1}{2}\operatorname{tr}\left(\mathbf{I}\_{3\times3} - \mathbf{R}\_{des}^T \mathbf{R}\_{\mathbf{B}}^1\right) < 2\tag{28}$$

Attitude tracking error and angular velocity error are calculated from (29, 30). The control vector **u**<sup>2</sup> is calculated in (31) [17].

$$\mathbf{e}\_{\mathcal{R}} = \frac{1}{2} \left( \mathbf{R}\_{dcs}^T \mathbf{R}\_{\mathbf{B}}^1 - \mathbf{R}\_{\mathbf{B}}^{\mathrm{I}} \prescript{T}{}{\mathbf{R}}\_{dcs} \right)^\vee \tag{29}$$

$$\mathbf{e}\_{\nu} = \nu - \mathbf{R}\_{\mathbf{B}}^{\mathrm{T}} \mathbf{R}\_{des} \boldsymbol{\nu}\_{des} \tag{30}$$

$$\mathbf{u}\_2 = \boldsymbol{\nu} \times \mathbf{J} \boldsymbol{\nu} + \mathbf{J} (-K\_R \mathbf{e}\_R - K\_\nu \mathbf{e}\_\nu) - \mathbf{J} \left(\hat{\nu} \mathbf{R}\_\mathbf{B}^{\mathrm{I}} \mathbf{R}\_{\mathrm{des}} \boldsymbol{\nu}\_{\mathrm{des}} - \mathbf{R}\_\mathbf{B}^{\mathrm{I}} \mathbf{R}\_{\mathrm{des}} \boldsymbol{\dot{\nu}}\_{\mathrm{des}}\right) \tag{31}$$

#### **4.4 Particle swarm optimization for control gains tuning**

A PSO algorithm is employed to tune the control gains. Some adjustments were performed to reduce the processing [14, 15], s. Each particle *α<sup>i</sup>* is a vector with the proportional and derivative gains (32).

$$a\_i = \begin{bmatrix} K\_p & K\_d & K\_R & K\_\nu \end{bmatrix} \tag{32}$$

Using a predefined set of waypoints chosen by the user, the code calculates the desired trajectory and tests each particle, calculating the RMS error. The PSO algorithm evolves in the direction of the best validated solution in each iteration, until achieving a minimum error tolerance. For faster convergence, every time a particle is evaluated, the evaluation is interrupted in the middle of the trajectory if the error increases above a predefined limit.

#### **5. The graphical user interface**

A user-friendly 3D animated GUI was developed in MatLab. It is able to evaluate and compare the performance of various quadrotor control strategies for any userchosen trajectory. A few of quadrotor parameters are easily set in this interface [15].

A red vertical line indicates the upper side of the device, and a red circle the front rotor. Waypoints are represented by red markers, the desired trajectory is on

**4.2 Desired thrust vector control**

*Robotics Software Design and Engineering*

**b***z*), it must be referred to frame **I** (15).

**v** (19). The related error is calculated with (20).

**v**^ ¼

A PD control law is used to calculated **u**<sup>2</sup> (22).

2 6 4

calculated from (17).

than 2 (23).

**108**

**4.3 Geometric tracking control**

At high speeds and *roll* and *pitch* angles far away from zero, a more robust strategy is necessary. A FF-PD control law calculates the control signal *u*<sup>1</sup> for the trajectory following and compensates the gravity. Vector **t** is calculated with the attitude for the desired effect (14). As *u*<sup>1</sup> acts along the *z* direction in frame **B** (axis

**t** ¼ *m* **r***des* þ *Kp* **e***<sup>r</sup>* þ *Kd* **e***<sup>r</sup>*

calculated from the equation of rotation of **b***<sup>z</sup>* in the direction of **t** (16).

*u*<sup>1</sup> ¼ **t**

The axis **b***<sup>z</sup>* is desired to be aligned with **t**. The desired rotation matrix **R***des* is

**<sup>R</sup>***des***b***<sup>z</sup>* <sup>¼</sup> **<sup>t</sup>**

As we know *ψdes* we use (16) to calculate *ϕdes* and *θdes*. **R***des* is constructed with

**B**

With the Rodrigues formula [20], the axis of rotation **v** and the rotation angle *β* are calculated (18). **I**<sup>3</sup>�<sup>3</sup> is the identity matrix and **v**^ is the skew-symmetric matrix of

> 0 �*v*<sup>3</sup> *v*<sup>2</sup> *v*<sup>3</sup> 0 �*v*<sup>1</sup> �*v*<sup>2</sup> *v*<sup>1</sup> 0

Basin of attraction Ψ limits the set of rotations from which the quadrotor is able to converge to the hovering state. It is a dimension of the set of angular and linear velocities for a stable performance. For this control strategy it must be lower

> *des* **R**<sup>I</sup> **B**

Geometric Tracking Control exhibits almost global exponential attractiveness to the zero equilibrium of tracking errors [17]. **t** and *u*<sup>1</sup> are calculated as in (14) and

<sup>Ψ</sup> <sup>¼</sup> tr **<sup>I</sup>**<sup>3</sup>�<sup>3</sup> � **<sup>R</sup>***<sup>T</sup>*

(15). **b***<sup>x</sup>* is the desired direction vector in the first body-fixed axis (24).

<sup>Δ</sup>**<sup>R</sup>** <sup>¼</sup> **<sup>I</sup>**<sup>3</sup>�<sup>3</sup> cos *<sup>β</sup>* <sup>þ</sup> **v v***<sup>T</sup>*ð Þþ <sup>1</sup> � cos *<sup>β</sup>* **<sup>v</sup>**^ sin *<sup>β</sup>* (18)

3 7

**u**<sup>2</sup> ¼ *ν* � **J** *ν* þ **J**ð Þ �*KR* **e***<sup>R</sup>* � *K<sup>ν</sup>* **e***<sup>ν</sup>* (22)

these three angles with the same structure of (2). The error in rotation Δ**R** is

<sup>Δ</sup>**<sup>R</sup>** <sup>¼</sup> **<sup>R</sup>**<sup>I</sup>

� � <sup>þ</sup> *mg***a***<sup>z</sup>* (14)

*<sup>T</sup>***Rb***<sup>z</sup>* (15)

k k**<sup>t</sup>** (16)

� �*<sup>T</sup>* **<sup>R</sup>***des* (17)

**e***<sup>R</sup>* ¼ *β***v** (20)

**e***<sup>ν</sup>* ¼ *ν<sup>c</sup>* � *ν* (21)

� �<2 (23)

<sup>5</sup> (19)

### *Robotics Software Design and Engineering*

**Figure 2.** *Graphical user interface.*

dashed blue line, and the 3D interface axis limits are automatically adjusted from the waypoints (**Figure 2**).

Waypoints, quadrotor parameters and simulation comands are set in th buttons on the left side of the GUI.

angle of *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>0</sup><sup>∘</sup>

*Quadrotor parameters [3].*

**Table 2.**

**Table 3.** *Waypoints test 1.*

**111**

**6.1 Elliptical helix trajectory**

, Case 2 with *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>88</sup><sup>∘</sup>

trajectory along with the *x* axis of inertial frame **i***x*.

control strategies available in the tool were graphically and numerically validated.

**Parameter Value Units** *Jxx* <sup>4</sup>*:*<sup>856</sup> � <sup>10</sup>�<sup>3</sup> *kg:m*<sup>2</sup> *Jyy* <sup>4</sup>*:*<sup>856</sup> � <sup>10</sup>�<sup>3</sup> *kg:m*<sup>2</sup> *Jzz* <sup>8</sup>*:*<sup>801</sup> � <sup>10</sup>�<sup>3</sup> *kg:m*<sup>2</sup> *<sup>k</sup>* <sup>2</sup>*:*<sup>980</sup> � <sup>10</sup>�<sup>6</sup> *<sup>N</sup>:<sup>s</sup>*

*Quadrotor Unmanned Aerial Vehicles: Visual Interface for Simulation and Control…*

*DOI: http://dx.doi.org/10.5772/intechopen.97435*

*g* 9*:*81 *m=s*

*m* 0*:*468 *kg Ax* 0*:*25 *kg=s Ay* 0*:*25 *kg=s Az* 0*:*25 *kg=s <sup>b</sup>* <sup>1</sup>*:*<sup>100</sup> � <sup>10</sup>�<sup>7</sup> *<sup>N</sup>:m:<sup>s</sup>*

*L* 0*:*225 *m Ni max* 8500 *rpm Ni min* 1300 *rpm τ* 0*:*1 *s*

The first trajectory waypoints (**Table 3**) describe an elliptical helix in a forward

*t s*ð Þ *x*desð Þ *m y*desð Þ *m z*desð Þ *m ψ*desð Þ rad 0.00 �0.40 0.00 2.00 0.00 1.20 0.00 0.00 2.00 0.00 1.80 0.20 0.00 2.60 0.00 2.40 0.40 0.40 2.00 1.57 3.00 0.60 0.00 1.40 3.14 3.60 0.80 �0.40 2.00 4.71 4.20 1.00 0.00 2.60 6.28 4.80 1.20 0.40 2.00 7.85 5.40 1.40 0.00 1.40 9.42 6.00 1.60 �0.40 2.00 11.00 6.60 1.80 0.00 2.60 12.57 7.20 1.80 0.00 2.60 12.57

, and Case 3 with *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>178</sup><sup>∘</sup>

. The three

<sup>2</sup>*=rad*<sup>2</sup>

2

<sup>2</sup>*=rad*<sup>2</sup>

The user may test its own control strategy just by creating the corresponding code like the following example:

```
function New_Controller
% declare global variables
global quad;
% holds the quadrotor in the last waypoint
if(quad.iteracao > length(quad.rdes(1,:)))
Controlador_Position_Hold()
end
% start the controller code and calculate the global control commands
quad.u1=...
quad.u2=...
```
The code New\_Controller.m must be stored in the folder Controllers, and will be recognized in the dropdown menu in the lower left side of **Figure 2**.

## **6. Results**

The tool developed in MatLab and is available in GitHub [21]. The values employed for these results are in **Table 2** [3].

For simulating the measurement noise, a random signal was added to position (<sup>0</sup>*:*<sup>01</sup> *<sup>m</sup>*) and orientation (<sup>0</sup>*:*5<sup>∘</sup> ) variables and their derivatives. Maximum and minimum motor speeds make the simulation more reliable. A time constant *τ* of 0.1 *s* for dynamic rotor speed variation was considered.

Two sets of waypoints of challenging trajectories were tested, each one was simulated in three different initial conditions: Case 1 starting with an orientation


*Quadrotor Unmanned Aerial Vehicles: Visual Interface for Simulation and Control… DOI: http://dx.doi.org/10.5772/intechopen.97435*

**Table 2.** *Quadrotor parameters [3].*

dashed blue line, and the 3D interface axis limits are automatically adjusted from

Waypoints, quadrotor parameters and simulation comands are set in th buttons

The user may test its own control strategy just by creating the corresponding

% start the controller code and calculate the global control commands

The code New\_Controller.m must be stored in the folder Controllers, and will

The tool developed in MatLab and is available in GitHub [21]. The values

For simulating the measurement noise, a random signal was added to position

minimum motor speeds make the simulation more reliable. A time constant *τ* of 0.1

Two sets of waypoints of challenging trajectories were tested, each one was simulated in three different initial conditions: Case 1 starting with an orientation

) variables and their derivatives. Maximum and

be recognized in the dropdown menu in the lower left side of **Figure 2**.

the waypoints (**Figure 2**).

*Graphical user interface.*

on the left side of the GUI.

global quad;

end

**Figure 2.**

**6. Results**

**110**

quad.u1=... quad.u2=...

code like the following example:

function New\_Controller % declare global variables

*Robotics Software Design and Engineering*

Controlador\_Position\_Hold()

employed for these results are in **Table 2** [3].

*s* for dynamic rotor speed variation was considered.

(<sup>0</sup>*:*<sup>01</sup> *<sup>m</sup>*) and orientation (<sup>0</sup>*:*5<sup>∘</sup>

% holds the quadrotor in the last waypoint if(quad.iteracao > length(quad.rdes(1,:)))

angle of *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>0</sup><sup>∘</sup> , Case 2 with *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>88</sup><sup>∘</sup> , and Case 3 with *<sup>ϕ</sup>*ð Þ¼ <sup>0</sup> <sup>178</sup><sup>∘</sup> . The three control strategies available in the tool were graphically and numerically validated.
