- Original Article
- Open Access

# Simulating unmanned aerial vehicle flight control and collision detection

- Mengtian Liu
^{1, 3}, - Meng Gai
^{2}and - Shunnan Lai
^{2}Email author

**2**:5

https://doi.org/10.1186/s42492-019-0014-9

© The Author(s) 2019

**Received:**2 December 2018**Accepted:**2 May 2019**Published:**21 June 2019

## Abstract

An unmanned aerial vehicle (UAV) is a small, fast aircraft with many useful features. It is widely used in military reconnaissance, aerial photography, searches, and other fields; it also has very good practical-application and development prospects. Since the UAV’s flight orientation is easily changeable, its orientation and flight path are difficult to control, leading to its high damage rate. Therefore, UAV flight-control technology has become the focus of attention. This study focuses on simulating a UAV’s flight and orientation control, and detecting collisions between a UAV and objects in a complex virtual environment. The proportional-integral-derivative control algorithm is used to control the orientation and position of the UAV in a virtual environment. A version of the bounding-box method that combines a grid with a k-dimensional tree is adopted in this paper, to improve the system performance and accelerate the collision-detection process. This provides a practical method for future studies on UAV flight position and orientation control, collision detection, etc.

## Keywords

- Unmanned aerial vehicle
- Proportional-integral-derivative control algorithm
- Orientation control
- Position control
- Grid
- k-dimensional tree
- Collision detection

## Background

An unmanned aerial vehicle (UAV), commonly known as a drone, is an aircraft without a human pilot aboard. It can climb, fall, hover, yaw, etc. UAVs are relatively small and convenient to use. UAVs have broad application prospects in military and civilian areas, including intelligence access, target tracking, monitoring, etc. The UAV is an underactuated system [1] that has six degrees-of-freedom (position and orientation) and multiple control inputs (e.g., rotor speed). It also has multivariable, non-linear, and strong coupling characteristics, all of which make its flight-control design very difficult. In UAV simulation systems, the interaction between a UAV and its possibly-complex surrounding environment must be considered; hence, accurate collision detection is another focus. Accurate collision detection can improve the authenticity and reliability of the UAV simulation system, giving the user a better sense of immersion.

In recent years, with the continuous development and improvement of UAV control theory, applying better control algorithms to flight-control systems has become one of the key problems studied by flight-control researchers. Many different control methods have been presented, e.g., backstepping control [2] and chattering-free sliding-mode altitude control [3], which were applied to UAV flight control and achieved good results. Because the backstepping control method had a certain degree of dependence on the model, Farrell et al. [4] first used neural networks to eliminate dynamic modeling errors. Then, they used a backstepping control method to design a four-rotor controller, and achieved better simulation results. In addition, special tools, e.g., MATLAB/Simulink [5], have also contributed much to this field.

Scholars in the collision-detection field have conducted extensive research and presented efficient detection methods in recent years. These methods can be divided into two phases: spatial-decomposition methods and hierarchical bounding-box methods, they are used as much as possible to reduce the number of collision tests. Spatial decomposition provides broad-phase processing by dividing space into regions, and testing whether objects overlap the same region. It mainly includes three types of spatial partitioning: grids, trees [6], and spatial sorting. The problem with spatial partitioning is determining when to stop dividing the space cells and setting the cell sizes. Turk et al. [7] first proposed using spatial hash tables with uniform partitions to improve the query speed. However, this method is more suitable for cases where the objects’ positions are dispersed. In the worst case, i.e., the objects’ positions are concentrated, it has an O(n^{2}) time complexity. The basic idea of the hierarchical bounding-box method is to use simple geometry to progressively break up the surrounding model. Intersection tests are then used to quickly eliminate disjoint areas, thereby reducing the overall number of tests. Many bounding-box algorithms have been presented: Sphere [8], axis-aligned bounding boxes [9], and oriented bounding boxes [10].

But these methods mentioned above do not have special optimizations for certain scenarios. In this paper, we proposed a hybrid method combining spatial decomposition method with hierarchical method to detect collision. As a result, we can catch small details with high speed.

## Methods

### UAV orientation and position control

- (1)
Calculate the axial deviation (deviation = target desired angle - measured angle);

- (2)
Calculate the proportional term (ratio coefficient P * deviation), integral term (integral coefficient I * angular rate), and differential term (differential coefficient D * angular rate);

- (3)
Sum the resulting outputs (total direction control = proportional item output + micrometer output + integral item output).

The position control guides the UAV along the specified trajectory or in accordance with the designated location hover. The position control in this study is divided into vertical and horizontal position controls. The vertical control calculates the difference between the desired height and the actual height as the desired climb rate, and then uses the PID control algorithm to obtain the UAV’s height. The horizontal-position PID control uses the difference between the expected position and the actual location as the required distance to calculate the desired speed, and then uses the PID control algorithm to obtain the UAV’s position.

### Spatial partition using a grid and a k-dimensional tree

- (1)
For the area where the UAV is located, select the area size (all areas cover all virtual objects);

- (2)
The area obtained in the first step is divided into grid cells of appropriate size by the equalization grid technique;

- (3)
The objects in each grid cell are organized into a k-d tree, and each grid cell holds the root node pointer of the k-dimensional tree (k-d tree) it owns.

### Collision detection

First, we should address the problem of creating a hierarchical bounding box. There are three primary construction-method categories: top-down, bottom-up, and insertion. Among them, top-down methods partition the input into two or more subsets, bound them in the chosen bounding volume, and then recurse over the bounded subsets. Top-down methods are by far the most popular, owing to their ease of implementation. Insertion methods build the hierarchical bounding box incrementally by inserting objects one at a time into the tree. Bottom-up (or agglomerative) methods start with the leaves of the tree as the input set, and then group two or more of them to form a new (internal) node. Bottom-up methods take longer to construct than top-down methods, but usually produce better trees [11].

^{2}) time. Moreover, it must be repeated n-1 times to form a full tree; thus, the total construction time becomes O(n

^{3}). We can sort the leaf nodes according to the bounding box’s volume, and then use a priority-queue structure to store them. It is similar to creating a Huffman tree structure, and the total construction time is reduced to O(n

^{2}log n). The process of creating the hierarchical bounding box is depicted in Fig. 4. By adopting this method, we can define the maximum depth of the collision tree, which is equivalent to the number of layers in the bounding box. Fig. 5 shows the bounding-box levels for a tree model; green indicates a coarse bounding box, and red indicates a fine bounding box. After constructing the hierarchical bounding boxes for the UAV and the possible collider, we can execute the collision-detection algorithm. The hierarchical bounding-box collision-detection algorithm is described as follows, where a&&b indicates a precise collision detected between hierarchical bounding boxes a and b.

## Results

Proportional-integral-derivative parameter

Gesture of unmanned aerial vehicle | Proportional P | Integral I | Differential D |
---|---|---|---|

Pitch angle | 2.7 | 0.03 | 0.75 |

Roll angle | 2.8 | 0.04 | 0.80 |

Yaw angle | 4.4 | 0.06 | 1.50 |

Height | 3.0 | 0.08 | 1.25 |

## Discussion and conclusions

Although we used the classical PID control algorithm in our flight-control system, PID is not robust in terms of parameter uncertainties, and it is difficult to tune its parameters for unstable systems. Recent studies have shown that we can build a stable and precise flight-control system by combining it with a linear quadratic regulator [12]. As future work, we plan to further improve the control-system software functions and increase the flight-control system autonomy, e.g., automatic obstacle avoidance, automatic following, and independent completion of scheduled complex functions.

## Declarations

### Funding

This work was supported by the National Key Technology Research and Development Program of China (Nos. 2015BAK01B06, 2017YFB1002705, 2017YFB1002601, and 2017YFB0203002), the National Marine Public Service Project (No. 201505014–3), the National Natural Science Foundation of China (NSFC) (Nos. 61472010 and 61661146002), and the Equipment Development Project (No. 315050501).

### Authors’ contributions

All authors read and approved the final manuscript.

### Competing interests

The authors declare that they have no competing interests.

### Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Open Access**This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

## Authors’ Affiliations

## References

- Olfati-Saber R (2000) Nonlinear control of underactuated mechanical systems with application to robotics and aerospace vehicles. Dissertation, Massachusetts institute of technologyGoogle Scholar
- Lee H, Kim S, Ryan T, Kim HJ (2013) Backstepping control on se of a micro quadrotor for stable trajectory tracking. In: Proceedings of 2013 IEEE international conference on systems, man, and cybernetics. IEEE, Manchester, pp 4522–4527. https://doi.org/10.1109/SMC.2013.769 View ArticleGoogle Scholar
- González I, Salazar S, Lozano R (2014) Chattering-free sliding mode altitude control for a quad-rotor aircraft: real-time application. J Intell Robot Syst 73(1–4):137–155. https://doi.org/10.1007/s10846-013-9913-8 View ArticleGoogle Scholar
- Farrell J, Sharma M, Polycarpou M (2005) Backstepping-based flight control with adaptive function approximation. J Guid Control Dyn 28(6):1089–1102. https://doi.org/10.2514/1.13030 View ArticleGoogle Scholar
- Prabhakar N, Prazenica RJ, Gudmundsson S, Balas MJ (2016) Transient dynamic analysis and control of a morphing UAV. In: Proceedings of the AIAA guidance, navigation, and control conference, AIAA, San Diego. https://doi.org/10.2514/6.2016-0893
- Noborio H, Fukuda S, Arimoto S (1988) Fast interference check method using octree representation. Adv Rob 3(3):193–212. https://doi.org/10.1163/156855389X00091 View ArticleGoogle Scholar
- Turk G (1989) Interactive collision detection for molecular graphics. Dissertation, University of North CarolinaGoogle Scholar
- Palmer IJ, Grimsdale RL (1995) Collision detection for animation using sphere-trees. Comput Graph Forum 14(2):105–116. https://doi.org/10.1111/1467-8659.1420105 View ArticleGoogle Scholar
- Hubbard PM (1996) Approximating polyhedra with spheres for time-critical collision detection. ACM Trans Graph 15(3):179–210. https://doi.org/10.1145/231731.231732 View ArticleGoogle Scholar
- Gottschalk S, Lin MC, Manocha D (1996) OBBTree: a hierarchical structure for rapid interference detection. In: Proceedings of the 23rd annual conference on computer graphics and interactive techniques. ACM, New York, pp 171–180. https://doi.org/10.1145/237170.237244 View ArticleGoogle Scholar
- Omohundro SM (1989) Five balltree construction algorithms. International computer science institute, BerkeleyGoogle Scholar
- Bagheri S, Jafarov T, Freidovich L, Sepehri N (2016) Beneficially combining LQR and PID to control longitudinal dynamics of a SmartFly UAV. In: Proceedings of 2016 IEEE 7th annual information technology, electronics and mobile communication conference. IEEE, Vancouver, BC, pp 1–6. https://doi.org/10.1109/IEMCON.2016.7746309 View ArticleGoogle Scholar