Path Optimization for Mobile Robots using Genetic Algorithms

This article proposes a path planning strategy for mobile robots based on image processing, the visibility graphs technique, and genetic algorithms as searching/optimization tool. This proposal pretends to improve the overall execution time of the path planning strategy against other ones that use visibility graphs with other searching algorithms. The global algorithm starts from a binary image of the robot environment, where the obstacles are represented in white over a black background. After that four keypoints are calculated for each obstacle by applying some image processing algorithms and geometric measurements. Based on the obtained keypoints, a visibility graph is generated, connecting all of these along with the starting point and the ending point, as well as avoiding collisions with the obstacles taking into account a safety distance calculated by means of using an image dilation operation. Finally, a genetic algorithm is used to optimize a valid path from the start to the end passing through the navigation network created by the visibility graph. This implementation was developed using Python programming language and some modules for working with image processing ang genetic algorithms. After several tests, the proposed strategy shows execution times similar to other tested algorithms, which validates its use on applications with a limited number of obstacles presented in the environment and low-medium resolution images. Keywords—Optimization; path planning; genetic algorithms; visibility graphs


I. INTRODUCTION
Today more than ever, robotics is part of the daily life in most of the world specially in big cities where the automation and smart stuff is everywhere. Mobile robots area has been widely researched not only in its mechanical design and locomotion type but in its motion planning [1], [2] in applications such as movement in indoor environments [3], obstacle avoidance [4], navigation in complex mazes [5], path planning [6], [7], and some times using open source robotics software [8]. Researching areas like UAVs (Unmanned Aerial Vehicles) and self-driving or autonomous vehicles have maintained the interest on one of the most important issues for mobile robots, the path planning. In this area, one of the most used algorithm has been the visibility graphs [9] supported by image processing algorithms [10]. These visibility graphs generates a high dense network of possible paths through the some navigation keypoints obtained from the obstacles image that is related with the navigation scene to solve by the mobile robot. This path network includes also both the starting point and the ending point, then a valid and short path has to be found from the start to the end passing through some segments of the connection network, for that reason it is necessary to apply a decision or optimization algorithm [11] to choose the best path inside on that network. A lot of different optimization algorithms has been used for the path planning issue such as ant colony optimization [12], [13], particle swarm for mobile robots [14], [15], [16], [17], chaotic particle swarm [18] particle swarm for manipulators [19], brain storm optimization [20], Fuzzy-Wind Driven algorithm [21], rapidly-exploring trees [22], gray wolf algorithm [23] among others.
The Genetic Algorithms GAs are searching and optimization methods based on the natural selection process and the genetic operations involved in it, these ones have been used for solving problems in a lot of different engineering areas including robotics and of course path planning [24], [25], [26] and other variations such as the Taxi carpooling algorithm [27].
Therefore, this research aims to propose a path planning strategy combining both the visibility graphs method using image processing algorithms and genetic algorithms to optimize and obtain the best path, improving the overall execution time respect other related works. All of this strategy is proposed to be solved by means of using free software in this case all of the algorithms will be implemented on Python language using modules such as: scikit-image and geneticalgorithm2.
The paper is organized as follows: Section 2 presents the methodology proposed to find the optimal path for mobile robots using Genetic Algorithms (GAs), describing all processes to identify the obstacles image by capturing the image of navigating environment; going through the keypoints obtaining, then generating visibility graph, and subsequently selecting path optimization using GAs. Section 3 presents the results of implementing the path planning strategy in Python 3 language and testing in different navigation environments to evaluate overall execution time. Finally, Section 4 presents the conclusions about this research's main ideas, including possible future jobs.

II. METHODOLOGY
The path planning strategy for mobile robots proposed in this article is based on image capture of the navigating environment in which the robot is involved [28], [29], where the obstacles are perfectly differentiated from the void room. First step is the calculation of some keypoints for each obstacle in the scene in order to reduce the amount of information to work with by the planning algorithm. After that, all the possible paths from the start to the end are calculated, all of them passing through the previously detected keypoints, producing a highly dense path network. Finally, the optimization algorithm [30] is applied to the path network in order to obtain the shortest path. The complete process can be sumarized through the flow chart shown in Fig. 1, where it starts from a binary image of the environment (a black background and white obstacles), then some keypoints by each obstacle are calculated, after that a visibility graph is generated and finally only one path is selected. In the next sections, each step of the process is explained in detail.

A. Obstacles Image
The proposed strategy starts with a Black & White image of the scene with the obstacles [31], this binary image has a black background and the obstacles are represented in white as the example shown in Fig. 2. This image can be obtained from a camera located at the top of the robot environment and after turned into binary by means of applying an image threshold operation.

B. Keypoints Obtaining
The keypoints obtaining step is supported by some digital image algorithms, first the binary image of the obstacles is dilated in order to expand the obstacles border, applying the correspondent image morphology operation. After, the main two axis and the centroid of each dilated obstacle are calculated, this is done labeling and measuring each separated region in the binary image (obstacles). Finally, four keypoints per obstacle are calculated.

1) Image Dilation:
In this proposal, the navigation keypoints are based on the obstacles borders, but this takes into account a safe distance between these ones and the robot [32]. That distance is calculated from to the maximum radius of the robot according to the eq. 1 and correspons to the dilation radius r d .
Where r m is the maximum radius of the robot and ∆r is a radius tolerance defined at 10% in this case. Finally, r d has to be an integer and it is represented in pixel units.
Once the dilation radius r d is obtained, the morphology dilation operation is performed on the obstacles image by means of applying a 2D convolution between the original binary image and a square shape as wide as r d . The result is shown in Fig. 3, where the obstacles are the same as the binary image (see Fig. 2), but their area is expanded because of the dilation operation. This operation allows assuming obstacles with major areas to avoid future collisions due to the maximum radius of the mobile robot. 2) Obstacle keypoints Computing: After dilating the obstacles image, each obstacle is labeling and measured in order to find its centroid and its two main axis, from this data a ∆x and a ∆y are calculated for each axis according to eq. 2.
Where l i is the length of each main axis i of the obstacles axis set I and θ the orientation of the major axis detected. Finally from these deltas, the keypoints are calculated according to the eq. 3.
∀i ∈ I, ∀j ∈ J : www.ijacsa.thesai.org Where j is each of the calculated points set J for each main axis set I and (x 0 , y 0 ) is the centroid of each obstacle. The cardinality of the sets I and J is |I| = |J| = 2, so for each obstacle two main axis are calculated, and for each of them two points are generated, for a total of 4 generated keypoints by obstacle, as shown in Fig. 4.

C. Visibility Graph Generation
After generating all of the navigating keypoints including the starter and ending points, the visibility graph [33] is generated (see Fig. 6) connecting all of these points (drawing lines on the image) and after avoiding the crossing with the obstacles as shown in Fig. 7.
The collision avoidance between these lines and the obstacles is calculated by means of applying binary image  operations, specifically a binary XOR operation (exclusive disjunction) between the dilated obstacles image and a copy of the same image with the specific line drawn in black. If there is a collision, a black segment line will appear over an obstacle, that means that the two images will be different. Both images have to be totally equals (pixel by pixel) for validating the line, so each resultant pixel has to accomplish the eq. 4, Where I and J for this equation, are the sets of all valid indices in both dimensions of the dilated obstacles image A and the image B which has the dilated obstacles plus the drawn line.

D. Path Optimization-Selection
For selecting the shortest possible path in the generated visibility graph, it is possible to use a lot of different selection or optimization algorithms such as the A * algorithm [34]. In this proposal, Genetic Algorithms (GAs) are used as optimization tool [35] in order to find the shortest (and then the most efficient) path in the dense navigating network generated by the visibility graph. 1) Target Function: Once defined the complete set of keypoints P including the start p s and the end p e , it is necessary to define the target function to optimize f (P ), this depends on the cumulative distance of each segment p i p (i+1) from p s to p e , that accomplishes with the eq. 4. For the target function definition, it is necessary to define the solution set X as shown in eq. 5, where each x represents an index for reading the keypoints set P , so the set X detemine the order of a subset P X ⊆ P which is a possible solution (a short path).
The number of indices of the solution set X corresponds to the number of objects in the scene, plus the inital and ending points thus n = n-obstacles + 2. The number of elements of the set X is less or equal of the number of elements of the subset P X , so |P X | ≤ |X|, This occurs because a P xi different from P x n equals the ending point P e , that is meant the path reaches the final in less steps than the maximum allowed n, so it is necessary to determine the real number of steps m. This last is possible applying the eq. 6.
Once the steps m have been computed, the optimization target function is defined from the solution set X as shown in eq. 7.
Where | −−−−−−→ p xi p (xi+1) | is the distance of a segment between two sequential keypoints. This target function is subject to the first element of P k were the starting point p s , then it is generating the optimization restriction shown in eq. 8.
Additionally, as were described in the visibility graph section, the target function also has an obstacle collision restriction which can be implemented applying the eq. 4 2) Genetic Algorithm Implementation: The genetic algorithm proposed in this article for optimizing the visibility graph is setup as follows: there is no limit for the maximum number of iterations, the number of iterations without any improvement in the target function (fitness function) is set in 20, the crossover and mutation type era defined as uniform, the selection type is roulette, a 100 individuals population is defined, the rest of parameters are shown in Table I. The fitness function or target function to minimize by the genetic algorithm is implemented according to the eq. 7 and specifying the restrictions (see eq. 4 and eq. 8), generation a penalty when one of them is not accomplished, that is meant f (P ) is carried to a maximum value f (P ) max which corresponds to the total perimeter of the image A, then f (P ) max = A xmax * 2 + A ymax * 2. On the other hand the genome is built from the set X, taking into account that ∀i ∈ {0, 1, 2 . . . n} : x i ∈ E, the genome is simply generated in order as shown in Table II, being each gene an integer variable. No other variable different to the x i is necessary to be appended to the genome.

III. RESULTS
All of the proposed path planning strategy was implemented in Python 3 language on a simple office laptop (whose features are described in Table III) running a GNU/Linux distribution. In total 10 tests were done over different navigation environments, all of them with the 6 obstacles as shown in most of figures. In average only the genetic algorithm execution time was in the interval of (65, 94)s with an average value of 81.3s which is comparable with other previously tested algorithms such as A * which showed over the same conditions an average execution time of 83s. The genetic algorithm took in average 51.5 generations (iterations) to reach an average f (X) = 1115, the Fig. 8 shows a plot of one of the tests done, where the best target function in each generation is plotted. This specific example, reaches the convergence value in 44 generations. For the specific algorithm setup used, never this one reaches the maximum number of iterations (200), always this stops by reaching the maximum number of iterations without improvement the fitness function (20), that is meant the algorithm rapidly reaches a minimum but this is not necesary the global (see Fig. 9).
In order to find the global minimum a new test was done, this time with no limits of number of generations and generations without improvement. As a result this last test gave an execution time of 21min 33s, almost 16 times more than the original tests, and this one reaches a f (X) = 1027.7  which represents an improvement of 7.83%, obtained after 829 generations. The minimizing plot of this second test is shown in Fig. 10, where it is possible to graphically realize that the target function value has practically no changes from the generation number 110. The final path generated by this last test is shown in Fig. 11.
On the other hand, the image processing operations in charge of generating the collision restriction, spend around of the 43% of the total execution time of the genetic algorithm, mainly due to their use of pixel-to-pixel image comparisons which have a high computational cost. This execution time, can be exponentially increased by a linear increasing in the image dimensions.

IV. CONCLUSION
The proposed strategy of path planning based on visibility graphs and genetic algorithms, gave as a result execution times similar to other previously tested algorithms, in cases of simple environments such as the ones with a low amount of obstacles. According to the optimization parameters and environment images used, the genetic algorithm finds a valid solution with  workable execution times. If the resolution of the environment input image or the number of obstacles increases, this proposed strategy will reach high execution times which will make it difficult to apply it on a real time robotics navigation task. This last could happen also is the application needs that the genetic algorithm finds the global minimum.
This proposal implements a safety distance between the obstacles and the mobile robot, this distance is based on an image dilation operation, this technique can limit the possible paths in the visibility graph as shown in Fig. 7 where a connection line is missing for the obstacle in the upperleft corner, as well as obstacles with concave shape could generate issues due to the methodology used for calculating the keypoints.
As future work, it is proposed to generate and automatic image resizing (without information losing) in order to reduce its dimensions and therefore the computing time involved in the image operations within the target function to be solved by the genetic algorithm. Another future work proposal is to develop a path planning strategy that uses directly the genetic algorithm over all the navigating free space of the image, so that the solution set will be not an index set but a set of (x, y)