Algorithm for constructing the optimal trajectory A* for an unmanned aerial vehicle in three-dimensional space

This article discusses the adaptation of the algorithm for constructing the optimal trajectory A * to three-dimensional space, as well as computer modeling of this algorithm in the MatLab environment and the analysis of the results.


Introduction
Modern mobile robots are able to execute not only commands coming from the control center and regulating movement parameters (azimuth, speed, acceleration), but also independently plan the trajectory to achieve the target state, taking into account the need to also solve obstacle avoidance problems. At the same time, orientation in space provided by a navigation system using GPS / GLONASS and supplemented by means of an orientation system: technical vision, a rangefinder, infrared sensors, etc. The combination of these tools provides the mobile robot with objective information about its current location [1][2][3]. Achievement of the target position carried out along a certain trajectory, for preliminary planning of which information needed about the external environment -the space in which the movement will be perform. This information provided by a map of the area, which could be obtain from various sources.However, such a map cannot take into account possible changes caused by the movement of mobile devices (transport, people), natural phenomena (precipitation), anthropogenic impact on the landscape, seasonal changes in nature, etc [4,5].
Nevertheless, the general idea of the terrain provided by the map is sufficient for the implementation of generalized (preliminary) planning of the trajectory of movement.It is supposed to build a threedimensional array of dimension n, filled with values 0 and 1, where 0 is a free path, 1 is an obstacle, for planning the flight trajectory of an unmanned aerial vehicle based on the obtained terrain map. Based on the resulting array, it is possible to calculate the optimal flight trajectory, as well as its modeling, taking into account obstacle avoidance and taking into account the physical dimensions of the aircraft to overcome the most difficult obstacles [6][7][8].

Description of the A* algorithm adapted to three-dimensional space in the Matlab environment
At the very beginning of modeling, you need to know the dimension of space along each axis. 3 variables are initialized to do this: dimension along the X axis, dimension along the Y axis and dimension along the Z axis. Create an array of a given dimension.
Next, it is necessary to initialize the price of one division; we need this parameter to represent the scale of the virtual model in comparison with the real one. Then it is necessary to enter the coordinates of the starting point and the coordinates of the end point to which the movement from the starting point takes place in the 3D space array.
After initialization, these points are placed on the space map and the cells of the array of these points are marked as 2 and 3, where the number 2 marks the starting point, and the number 3 marks the end point. Further, a map of the original terrain is loaded onto the 3D array, where each point with an obstacle is marked with the number 1 on the space map. After initializing all the necessary input data, an algorithm for finding the optimal trajectory is describing. There are 26 options for moving an object from the current point to an adjacent one in 3D space. The list of possible options for the example of the coordinates of the current point (X current + (-1 ... + 1), Y current + (-1 ... + 1), Z current + (-1 ... + 1)).
If the point in question satisfies these conditions, then we calculate the value of the weighting function for this point. Next, the condition is checked -if this is the first point of the candidate, then the value of the weight function and the coordinates of the candidate point are recording. If other points were consider candidates for movement, then the value of the weighting function is compared with the value of the previous point of the candidate, if it is less, then the current considered option is assigned as a candidate. After considering all 26 options, the point is marked as considered it is also necessary to plot a reference point, which corresponds to the candidate point with the smallest value of the weighting function. The candidate point with the smallest weight function becomes the current point under consideration. If there are no candidates out of 26 options, then there is no route to the specified destination. If the candidate point is a target point, then the trajectory to the specified target has been found, therefore, further search for a route is stopped.

Results of modeling A* algorithm
To study the modeling of the A* algorithm adapted to three-dimensional space, a three-dimensional space with a dimension of 10×10×10 with a division value of 1m was taken. To study the modeling of the A* algorithm, adapted to a three-dimensional space, was taken a three-dimensional space with a dimension of 10×10×10 with a division value equal to 1m. Coordinates of the starting point were selected (1, 1, 1). The coordinates of the end point are chosen as the end of space along all 3 axes, namely (10, 10, 10).
The first step of the study is carried out as building a trajectory in empty space, the percentage of filling the space is 0% (Figure 2a), and then in the space filled by 10% (Figure 2b). This Figure 2 shows that the simulation result is a straight trajectory with a space filling of 0%, having a length of 15.59 m; at 10% filling, the trajectory length is 19.49 m.
The next step is the simulation with a space filled by 20% (Figure 3a) in the next step, and then in a space filled by 30% (Figure 3b). The Figure 3 shows that when the space filled by 20%, the simulation result is a straight trajectory with a length of 20.76 m; when filling at 30%, the length of the trajectory is 23.497 m.
Next, we will simulate with a 40% filled space (Figure 4a), and then in a space filled with 50% ( Figure 4b). The Figure 4 shows that when the space filled by 40%, the simulation result is a straight trajectory with a length of 24.8 m; when filling at 50%, the length of the trajectory is 25.97 m.
Next, we will simulate with a 60% filled space (Figure 5a), and then in a 70% filled space ( Figure  5b).   Figure 5 shows that when filling the space by 60%, the simulation result is a straight trajectory having a length of 32.8 m, and when filling 70%, the length of the trajectory is 33.39 m.
In addition, the last step is to perform modeling with the filled space at 80% (Figure 6a), and then in the space filled at 90% (Figure 6b). The Figure 6 shows that when the space is filled by 80%, the simulation result is a straight trajectory with a length of 34.22 m; when filling at 90%, the length of the trajectory is 35.39 m.
Based on the result of the study, it is possible to draw up a graph of the dependence of the length of the trajectory on the percentage of filling the space with obstacles. This graph is shown in Figure  7.  (2) where y(x) is the length of the trajectory, x is the percentage of filling the space.
If this expression is present, it's possible to calculate in advance the approximate size of the trajectory, substituting for x the percentage of filling the space. Figure 8 shows a graph of the dependence of the length of the trajectory on the percentage of filling the space with obstacles, approximated by a polynomial of the sixth degree.

Conclusion
The algorithm for finding the optimal trajectory A* was thoroughly analyzed in this work. Its formulation for three-dimensional space was compiled on the basis of this algorithm, and it was also modeled with help of Matlab. In addition, a study of the space is carried out for the adequacy of constructing the trajectory by loading the foreparts map into the algorithm up to 90%.The results of the study showed that in a space with a dimension of 10×10×10, a division value of 1m, the coordinate of the starting point (1, 1, 1) and the coordinate of the end point (10,10,10), the length of the simulated trajectory is 15.58m in empty space, and when filling the space 90% of the trajectory length is 35.39 m. This suggests that the implemented program copes well with modeling complex paths and the trajectory construction model is adequate. Solving the problems of planning the optimal flight trajectory of an unmanned aerial vehicle in threedimensional space is a promising direction in the field of robotics. It should be noted that when solving the problems of intercepting a moving object by an unmanned aerial vehicle, certain difficulties will appear, which are associated with the fact that a given target is a moving flying object. This requires a quick recalculation of the optimal flight trajectory and an effective quick response of the actuators for constant approach to a moving target. Further research will be devoted to this problem.