OBSTACLE AVOIDANCE IN QUADCOPTER NAVIGATION USING MODIFIED LOCAL MEAN K-NEAREST CENTROID NEIGHBOR METHOD

Quadcopter is a type of Unmanned Aerial Vehicle (UAV) technology, characterized by simple mechanical structure, ease of flying and good maneuvering. In its usage, the quadcopter is required to evade obstacles in its path. Thus, an obstacle avoidance system in a 3D space with both static and dynamic obstacles is. Avoidance direction is determined by considering nearest distance based on the dimensions of the obstacle. Due to limited battery capacity, the quadcopter also needs to consider energy efficiency in obstacle avoidance. The obstacle’s properties and movement direction are also needed in considering the correct avoidance direction. Using a modified Local Mean K-Nearest Centroid Neighbor (LMKNCN) algorithm results in a 97.5% accuracy for avoidance direction decision. The learning process between training data and testing data yielded a computation duration of 0.142341 seconds. The simulations showed that the quadcopter is able to avoid static and dynamic obstacles to reach its destination without collisions.


INTRODUCTION
A quadcopter is a type of unmanned aerial vehicle (UAV) with 4 rotors serving as lift and propulsion.A quadcopter's advantages compared to other UAV configurations include simple mechanical structure, ease of flying and maneuvering.These advantages allow the quadcopter to be used in many fields, such as farming [1], surveillance [2], construction [3], search and rescue [4], delivery [5], and such others.
In doing its assigned tasks, a given quadcopter must avoid many obstacles in its path.Its avoidance system must be adaptable towards both static and dynamic obstacles to make sure the quadcopter is safe and undamaged.
According to [6], avoidance direction decision needs to consider energy usage and distance due to limitations in the quadcopter's battery capacity.This research used K-Nearest Neighbor (KNN) algorithm for avoidance, using travel distance and minimum energy usage.This method is simple and effective in avoiding static obstacles of various dimensions However, there are still a possibility that the quadcopter hits a dynamic obstacle with certain speed.
Dynamic obstacle avoidance mechanism by predicting movement trends (static, dynamically to the left or right) to determine the robot's linear speed is discussed in [7].The robot may avoid the obstacle by increasing and decreasing speed, or outright stopping to wait for the obstacle to pass.This fuzzy logic-based method was able to predict movement trends and assist the robot in choosing the correct speed to avoid the obstacle.The movement trend prediction concept can be adapted towards an avoidance system for dynamic obstacles of varying speeds and directions.
Building upon [6], there is also a need for predicting the obstacle's movement trends to alter the quadcopter's movement direction in addition to its linear speed, thus minimizing evasion travel distance.However, running both movement trend prediction and speed adjustment burdened the KNN algorithm used in [6], resulting in more errors and eventual evasion failures.Local Mean K-Nearest Centroid Neighbor (LMKNCN) algorithm, a development from KNN, was proved by [8]- [9] to have less classification errors than its predecessor, thus its inclusion in the proposed system.
The LMKNCN method was tested in [8]- [9] to require a longer calculation method than KNN, which may influence calculation time, especially with high amount of training data.Thus, the algorithm needs to be modified to modify the algorithm to reduce the amount of executed training data.Grouping training data into a few clusters was proposed by [10]- [11], with each group being represented by a single data point, usually taken from the clusters' midpoints.The results gained by [10]- [11] showed that this method may reduce computation time despite the large number of training data involved.
From the previously discussed research, this paper proposes an avoidance system using a modified LMKNCN algorithm.The modification involved clustering the training data to reduce the amount of data processed by the algorithm in a given time, thus reducing computation time in the classification process.With this modification, it is hoped that the quadcopter will be able to avoid static and dynamic obstacles with a fast, accurate avoidance decision while also minimizing distance and energy.The avoidance classification system has five classes, that is evading to the left, right, up, down, or stopping, based on the obstacle's movement trends and dimensions between the quadcopter and the obstacle.

MATERIAL AND METHODS
This chapter discusses the system's concepts.The quadcopter unit used in the system is a Quanser Qdrone as seen in Fig 1 .The obstacles used will be static and dynamic, while the avoidance system used the LMKNCN method to determine evasion direction.

Quadcopter System
The Quanser Qdrone, a quadcopter designed for outdoor research, was chosen for this research.The quadcopter had a carbon fiber frame for a reduced weight, contributing to better maneuvering and less risk of catastrophic collisions.The drone has 40 cm × 40 cm ×15 cm dimensions and is equipped with propeller protectors.The quadcopter's system model [12] is represented in (1), where , ,  is the quadcopter's position while , ,  is the roll, pitch and yaw speed.The parameters used in the drone are shown in Table 1 depending on the type of drone.The system schema can be seen in Fig 2.

Obstacle Detection
An obstacle may be detected at a minimum distance of 1 meter to the quadcopter, which may be static or dynamic.When an obstacle is detected, direction detection is done to determine its movement, (moving to the left, right, up, down, or static).
After detecting an obstacle, the quadcopter reads its dimensions ℎ  , ℎ  , ℎ  , and ℎ  to classify the obstacle using the modified LMKNCN method.The classification results will be turned into waypoints for the quadcopter's path, changing its direction from the initial target and avoiding the obstacle [13].

Classification Method
This system used a modified Local Mean K-Nearest Centroid Neighbor (LMKNCN) algorithm to reduce the number of calculations needing to be done.Once a dataset has been chosen according to the detected obstacle, the next step is grouping the data into clusters, each with a cluster point determined using the following equation: where   is the i-th cluster point,  is the number of data points, and   is a data point.
In the testing data process, the first step is finding the nearest neighbor between new data and some cluster points.To calculate the nearest neighbor distance the following equation was used: where  is new data and   is the i-th cluster point After finding the nearest cluster, the next step is finding the nearest neighbor between the new data and data inside the cluster using LMKNCN [8]- [9].The steps are as follows: a) Find the nearest neighbor  1 between testing data  and training data in cluster     using an Euclidean distance equation shown in (4).
b) Find the nearest centroid neighbor   between testing data and each centroid data.
The new centroid data is gleaned from the midpoint between a nearest neighbor  1 to the k-th neighbor.
After finding the nearest centroid neighbor, the next step is finding k nearest neighbors.c) Calculating local average centroid vector    from each class   . where

Deviance Distance
The obstacle will be detected by the quadcopter at a distance of 1 meter.The quadcopter will record the obstacle's dimensions (ℎ  , ℎ  , ℎ  , ℎ  ) against the intersection between the quadcopter and the target point. .Each deviance distance ( ,  ,   ,   ) will be calculated using (9).
where   is a deviance distance ,   is the deviance angle , ℎ  is obstacle dimension ,  is the safe distance and   is the distance between the obstacle and the quadcopter.

Energy
Alongside considering deviance distance, the quadcopter must also consider energy [14].In this case, there are two energy types [15].Kinetic energy happens where the quadcopter moves without any altitude changes, whereas potential energy happens where the quadcopter changed altitude.Calculating kinetic energy may be done using (10).
where  is the quadcopter's mass () and  is its velocity (/).Assume that there is no energy loss from the quadcopter changing altitudes.Calculating potential energy may be done using (11).∆  = ..∆ℎ (11) where  is the mass of the quadcopter,  is gravity and ∆ℎ is the height difference between the quadcopter's and the avoidance point's coordinates.
, is the sum of energy needed by the quadcopter to move between its initial coordinates (  ,   ,   ) to the avoidance point's coordinates (  ,   ,   ).The needed energy sum  , is defined as: ∆ , = ∆  + ∆  (12) where ∆  is the potential energy and ∆  is the kinetic energy of the quadcopter.
Evading in different directions require different amounts of energy needed.Evading in lateral directions (left or right) results in potential energy ∆  being zero due to no changes in altitude.However, when the quadcopter evades in vertical directions (up or down), the altitude changes mean the presence of potential energy ∆  .

Quadcopter Control
This research used a proportional-derivative (PD) controller to control the quadcopter's movements.The controller's inner loop is devoted to attitude control, while its outer loop is devoted to position control [16].The quadcopter control system is illustrated in Fig. 5.
From the tuning experiments, the proportional-derivative control parameters used in this research are as follows:

RESULT AND DISCUSSION
This chapter discusses the results of the modified LMKNCN algorithm in doing certain tests.In the evasion direction avoidance tests, the features used in training data [17] is first discussed, as well as accuracy testing.Then, the algorithm is tested in quadcopter flight plans that must reach its target point with static and dynamic obstacles in the way.
The LMKNCN classification features used in this research is the dimensions of the obstacle against the quadcopter's position.The dimensions feature data is processed into deviance distance data.This feature data consisted of 4 parameters, that of upper span ℎ  , left span ℎ  , right span ℎ  , and lower span ℎ  .The deviance distance data  consisted of 4 parameters, that of left, right, up and down deviances.Table 2 shows the feature data used in cluster training data, Table 3 shows the obstacle training data, and Table 4 shows the testing data, all of which resolves as correct.
The simulation tests used a computer with Intel Core i3 CPU of 1.70 GHz and 4 Gb RAM.
The tests result in an accuracy of 97.5% (Table 4).The learning process between training and testing data required a computation time of 0.142341 seconds.

Case 1
In Case 1, the start point is in coordinate (0.5,4,2) and the target point is in coordinate (7.5,4,2).This case has 1 static obstacle in coordinate

Case 2
In Case 2, there is 1 dynamic obstacle moving up and down the positive z-axis.This obstacle has an innate velocity of 0.005/.The quadcopter is positioned at the start point (0.5,4,2) and has the target point (7.5,4,2).The dynamic obstacle has an initial coordinate

Case 3
In Case 3, the quadcopter is placed in the start point (0.5,4,2) and its target point is (7.5,4,2).There are 2 dynamic obstacles with starting coordinates of (3.4,2.2, 2.26) and (5.2,6.41,1.88).The first obstacle has an innate velocity of 0.02 /, moving the the left (positive y-axis).The second obstacle has an innate velocity of 0.01 /, moving to the right (negative y-axis) as shown in Fig 10 and
The closest training cluster data (Table 5) in this case is in Cluster 8.The first closest data in the cluster is the 12th data point.The centroids are located in the 15th and the 16th, shown in Table 6.The most efficient evasion direction is to the right due to the 3 nearest neighbors to the static obstacle training data in Cluster 8 (Table 7) showed the right class.
Table 8 showed that the closest cluster to the obstacle training data is Cluster 8.The first closest training data is the 11th data.The centroids are located in the 12th and 6th data (Table 9).The 3 nearest neighbors showed the down class (Table 10), therefore the evasion direction is to the bottom.
The closest cluster for the first obstacle is Cluster 9, as shown in Table 11.The closest cluster for the second obstacle is Cluster 1, as shown in Table 14.The closest training data in each cluster is the 8th for the first obstacle and the 5th for the second obstacle.The centroids for the first obstacle are the 7th and the 4th (Table 12).The centroids for the second obstacle are the 6th and the 7th (Table 15).For the first obstacle, the most efficient evasion direction is to the right, as shown in Table 13.For the second obstacle, the chosen evasion direction is to the left as shown in Table 16.The simulation results show that the designed system resolves an avoidance decision accuracy of 97.5%.Learning time between training and testing data required a measured computation time of 0.142341 seconds.With this system, the quadcopter was able to avoid static and dynamic obstacles of varying velocities.

Fig 2 .
Fig 2. System scheme Fig 3 illustrates how a quadcopter would read each deviance distance, with a side view in Fig 4 (a) and a top view in Fig 4 (b)

Table 2 .
Cluster training data

Table 3 .
Obstacle training data

Table 5 .
Nearest cluster training data for case 1

Table 8 .
Nearest cluster training data for Case 2

Table 10 .
Nearest static obstacle training data in cluster 8 for case 2

Table 14 .
Nearest cluster training data for Case

Table 15 .
Centroid data Data Pairs

CONCLUSION
This research has been This research discussed obstacle avoidance for quadcopter in a 3D environment.The system is designed to resolve efficient avoidance direction by minimizing energy and distance needed to evade static and dynamic obstacles.A modified Local Mean K-Nearest Centroid Neighbor (LKMNCN) algorithm is used in the system by splitting training data into multiple clusters.The quadcopter in this research used a proportionalderivative controller to reach the desired waypoints.The training data in this research is divided into cluster training data and obstacle training data.The obstacle training data is divided into 5 parts corresponding to the obstacle's characteristics.These include static obstacle data, up-moving, down-moving, right-moving, and left moving data.The nearest neighbor number  is set at 3.