Robot path planning method based on improved butterfly optimization algorithm
By combining the improved butterfly optimization algorithm and the genetic algorithm, the robot path planning is optimized, the problem of insufficient obstacle model processing in grid environment modeling is solved, and a shorter path length and higher planning efficiency are achieved.
Patent Information
- Application Number
- CN202510924548.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-10-03
AI Technical Summary
In the existing technology, there is still room for improvement in the processing of obstacle models in grid environment modeling, and the path length solved by the optimization algorithm still needs to be further optimized, especially in robot path planning, where the convergence speed and local convergence accuracy are insufficient.
The improved butterfly optimization algorithm is adopted to construct a grid map, interpolate the obstacle model, use the butterfly optimization algorithm to select the shortest path, and combine it with the genetic algorithm mutation process to optimize the path planning.
It improves the efficiency of path planning, avoids local optimal interference, enhances diversity, prevents the algorithm from converging prematurely, increases the possibility of finding a better solution, and reduces the path length.
Smart Images

Figure CN120740593A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of path optimization algorithms, and in particular to a robot path planning method based on an improved butterfly optimization algorithm. Background Art
[0002] Mobile robotics research encompasses navigation and positioning, motion control, and path planning, with path planning being a core area of research. Robotic path planning involves inputting environmental information into the robot, enabling it to find an optimal or near-optimal path from its starting point to its destination without colliding with obstacles.
[0003] In the existing technology, a variety of path planning methods have been proposed, such as the Grey Wolf Optimizer (GWO) algorithm, artificial neural network training algorithm, dragonfly algorithm, grid method, etc. Among them, in the grid method algorithm, the environment can be modeled and the cuckoo algorithm can be improved to perform local optimal path planning and global shortest safe path planning, thereby reducing the algorithm's search time for the optimal path.
[0004] The above are the solutions proposed for path planning. However, the improved algorithm still has some shortcomings for robot path planning, especially the convergence speed and local convergence accuracy, which need to be further optimized. For example, the processing of obstacle models in grid environment modeling still has a lot of room for improvement, and the path solved by the optimization algorithm can still be further optimized to reduce the path length. Summary of the Invention
[0005] The purpose of the present invention is to provide a robot path planning method based on an improved butterfly optimization algorithm to solve the technical problems in the prior art that there is still a lot of room for improvement in the processing of obstacle models in grid environment modeling, and that the path solved by the optimization algorithm can still be further optimized to reduce the path length.
[0006] In order to solve the above technical problems, the present invention specifically provides the following technical solutions: A robot path planning method based on an improved butterfly optimization algorithm comprises the following steps: Step 100: Build an environment model for robot path planning and record the coordinate information and contour information of all obstacles in the robot database; Step 200: Determine the starting point and end point of the grid map corresponding to the environmental model, screen the free grids in each row, and use the route combination set formed by all the selected rows of free grids as an individual in the butterfly population in the butterfly optimization algorithm to form a first generation of routes; Step 300: interpolate free grids between two adjacent rows of free grids in each of the first generation lines to form a second generation path that connects all adjacent grids in the path of the first generation line and has no collisions; Step 400: The path length of each second-generation path is used as the fitness value of the corresponding butterfly individual. The improved butterfly optimization algorithm is used to select the shortest path among all second-generation paths that can be used for normal robot driving. The last generation path in the path solved by the butterfly optimization algorithm is mutated, and the optimal path after mutation is selected to form the third-generation path.
[0007] Furthermore, in step 100, the coordinate information and contour information of all obstacles are recorded in the robot database by: Construct a grid map, where the black grids are obstacle modules and the white grids are movable areas; The positive direction of the X axis is defined from left to right, the positive direction of the Y axis is defined from bottom to top, and the grid length is defined as a unit length. A two-dimensional coordinate plane of the grid map is established, and the grids are numbered for planning the robot's motion path. The specific grid numbers are: ; Where num is the grid number, x is the column number of the current grid, y is the row number of the current grid, and x(max) is the total number of columns in the grid map.
[0008] Furthermore, the obstacle module is a black grid formed by expanding the obstacle model. The specific implementation method of setting the black grid formed by expanding the obstacle model is as follows: The robot in the two-dimensional map is represented by the circumscribed circle projected on the ground. The diameter of the circumscribed circle is D, and D is the length of the grid. Determine the edge line of the obstacle model, and set the free grids through which the edge line passes as black grids; If two adjacent sides of the black grid are connected to two free grids A and B, and free grids A and B are located at the diagonal positions of the 2*2 square grid, the comparison result of the distance L between the obstacle in the black grid and the line connecting the center points of the two connected free grids and D / 2 is further determined. Based on the comparison result of L and D / 2, it is determined whether the two connected free grids should be set as black grids.
[0009] Furthermore, the black grid is divided into two triangular regions C1 and C2 according to the dotted diagonal line, and the minimum distance values min(Lc1) and min(Lc2) of the two triangular regions C1 and C2 are calculated respectively; If the minimum distance min(Lc1) > D / 2 and min(Lc2) > D / 2, then the two adjacent free grids remain blank; If there is a part where the minimum distance min(Lc1) < D / 2 or min(Lc2) < D / 2 in the obstacle model, then the part where L < D / 2 is named the out-of-bounds part, and the free grid adjacent to the triangular region where the out-of-bounds part is located will become a black grid; If there are out-of-bounds parts in both triangular regions, then the free grids adjacent to the two triangular regions of the black grid are both set as black grids.
[0010] Furthermore, in step 300, the implementation method of forming a second-generation path that is continuous and collision-free for all adjacent grids in the path of the first-generation line is as follows: The numbers corresponding to each free grid in the first-generation line are obtained, and the adjacent two rows of grids selected according to the first-generation line are respectively defined as the current grid and the next grid, and it is determined whether the grid in the middle of the current grid and the next grid is a free grid; When the grid in the middle of the current grid and the next grid is a free grid, then this free grid is inserted into the path as an interpolation grid; When the grid in the middle of the current grid and the next grid is not a free grid, then the middle grid is moved in turn from the four directions of up, down, left, and right until it moves into a free grid, and the selected free grid is inserted into the path of the first-generation line; This process is repeated for all non-connected adjacent two points corresponding to free grids in the path of the first-generation line until all adjacent grids in the path of the first-generation line are continuous.
[0011] Furthermore, in step 300, the implementation method of selecting the path with the shortest length and allowing the robot to drive normally among all the second-generation paths is as follows: Each first-generation path is encoded as a sequence {p1, p2,..., pn} composed of n key points; N initial paths are randomly selected from the first-generation paths, and each initial path satisfies the basic constraints; The key points in each initial line are interpolated to generate a continuous second-generation path; The interpolated second-generation path is discretized into a point set, and it is checked whether the discrete points of the second-generation path overlap with the obstacle grids; The collision paths in the second-generation path are removed, and only the second-generation lines that can participate in subsequent optimization are retained.
[0012] Furthermore, in step 400, the implementation method of using an improved butterfly optimization algorithm to select the path with the shortest length and allowing the robot to drive normally among all the second-generation paths is as follows: Each path in the screened second-generation paths is used as a butterfly individual to form a butterfly population composed of the second-generation paths; Calculate the fitness of each butterfly individual, and use the path length of each butterfly individual as the fitness; When updating the path of each individual butterfly through global search, each butterfly updates its own position based on the fitness of other butterflies. The specific implementation method is as follows: ; where x best is the optimal path length among all current butterfly individuals, α is a random coefficient used to control the step length, is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment; When updating the path of each butterfly through local search, each butterfly randomly fine-tunes the position of key points near the current path. The specific implementation method is as follows: ; Where β is the step size and λ is the heavy-tailed distribution random step, which is used to enhance local exploration. is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment.
[0013] Furthermore, after the path of each individual butterfly is updated by the global search method or the local search method, or when no individual butterfly with high fitness is found by the global search method or the local search method for multiple times, a mutation operation is applied to some butterflies in the current population; Recalculate the fitness of the mutated butterflies, select them based on their fitness, and retain the butterflies with high fitness for the next iteration; The global search, local search, and mutation steps are repeated until the termination condition of reaching the maximum number of iterations is met.
[0014] Furthermore, the last generation path in the butterfly optimization algorithm solution path is mutated, and the optimal path after mutation is selected to form the third generation path. The implementation method is as follows: The path with the lowest fitness in each iteration is retained as the current optimal solution, where the path with the lowest fitness is the shortest and collision-free path.
[0015] Mutate the path of the current optimal solution, generate candidate solutions, and evaluate the fitness again; When the maximum number of iterations is reached or the fitness change is less than the threshold, the iteration is stopped and the global optimal path is output.
[0016] Furthermore, the implementation method of mutating the path of the current optimal solution is one of Gaussian mutation, exchange mutation, insertion mutation, reversal mutation, and adaptive mutation; Gaussian mutation is to apply Gaussian noise to a key point (x, y) on the path: x′=x+N(0,σ); y′=y+N(0,σ); Where x′ and y′ are the column and row numbers of the grid after Gaussian noise is applied, N is the variation function, and σ is the variation intensity; The swap mutation randomly selects two key points in the path and swaps their positions: Path=[p1,p2,…,pi,…,pj,…,pn]→[p1,p2,…,pj,…,pi,…,pn]; Insertion mutation randomly selects a key point and inserts it into another random position of the path: Path=[p1,…,pi,…,pj,…,pn]→[p1,…,pj,pi,…,pn]; The inversion mutation is to randomly select a subpath in the path and reverse it: Path=[p1,…,pi,pi+1,…,pj,…,pn]→[p1,…,pj,pj−1,…,pi,…,pn]; Where Path is the path, p1, p2,…, pi, pi+1,…, pj−1, pj,…, pn are the positions of each key point; Adaptive mutation dynamically adjusts the mutation intensity according to the current algorithm state: If convergence is slow, increase the mutation intensity; If the convergence is fast, reduce the mutation intensity.
[0017] Compared with the prior art, the present invention has the following beneficial effects: The present invention combines the advantages of the butterfly optimization algorithm's solving ability with the advantages of the mutation process in the genetic algorithm in improving efficiency, avoiding unnecessary calculations while ensuring solving efficiency. Moreover, the mutation process can avoid the interference of local optimality during calculation, break the rigidity of the current solution, enhance diversity, and introduce randomness in the mutation, preventing the algorithm from converging to a single solution too early, thereby increasing the possibility of finding a better solution. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other implementation drawings based on the provided drawings without inventive effort.
[0019] Figure 1 Schematic diagram of a robot path planning method according to an embodiment of the present invention; Figure 2 A grid map after one expansion of obstacles provided in an embodiment of the present invention; Figure 3 This is an analysis diagram of the second step of obstacle expansion processing provided by an embodiment of the present invention; Figure 4 The first generation circuit diagram of the robot provided by the embodiment of the present invention; Figure 5 A second-generation circuit diagram of a robot provided by an embodiment of the present invention; Figure 6 A third-generation circuit diagram of a robot provided by an embodiment of the present invention; Figure 7 Schematic diagram of simplified strategy 1 provided in an embodiment of the present invention; Figure 8 A diagram showing a simplified strategy 1 example according to an embodiment of the present invention; Figure 9 The fourth-generation path map after optimization of the simplified strategy 1 provided in the embodiment of the present invention; Figure 10 A schematic diagram of simplified strategy 2 provided in an embodiment of the present invention; Figure 11 A comparison chart of the final solution path of the butterfly optimization algorithm provided in an embodiment of the present invention and the solution path of a common genetic algorithm. DETAILED DESCRIPTION
[0020] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0021] like Figure 1 As shown, the present invention provides a robot path planning method based on an improved butterfly optimization algorithm, comprising the following steps: Step 100: Build an environment model for robot path planning and record the coordinate information and contour information of all obstacles in the robot database; Step 200: Determine the starting point and end point of the grid map corresponding to the environmental model, screen the free grids in each row, and use the route combination set formed by all the selected rows of free grids as an individual in the butterfly population in the butterfly optimization algorithm to form a first generation of routes; Step 300: interpolate free grids between two adjacent rows of free grids in each of the first generation lines to form a second generation path that connects all adjacent grids in the path of the first generation line and has no collisions; Step 400: The path length of each second-generation path is used as the fitness value of the corresponding butterfly individual. The improved butterfly optimization algorithm is used to select the shortest path among all second-generation paths that can be used for normal robot driving. The last generation path in the path solved by the butterfly optimization algorithm is mutated, and the optimal path after mutation is selected to form the third-generation path.
[0022] In step 100, the coordinate information and contour information of all obstacles are recorded in the robot database as follows: Construct a grid map, where the black grids are obstacle modules and the white grids are movable areas; The positive direction of the X axis is defined from left to right, the positive direction of the Y axis is defined from bottom to top, and the grid length is defined as a unit length. A two-dimensional coordinate plane of the grid map is established, and the grids are numbered for planning the robot's motion path. The specific grid numbers are: ; Where num is the grid number, x is the column number of the current grid, y is the row number of the current grid, and x(max) is the total number of columns in the grid map.
[0023] For example, in a 20×20 grid, 20 different rows of grids are selected as points that the robot passes through and represented by circles. The set of these 20 grids is used as an individual in the butterfly population in the butterfly optimization algorithm.
[0024] On this basis, we build Figure 2 The grid map shown has black grids for obstacle modules and white grids for movable areas. The lower left corner S is the starting point, and the upper right corner G is the target point.
[0025] The obstacle module is obtained by expanding the obstacle, and all grids involved in the obstacle are set to black. Considering that the robot may come into contact with the expanded obstacle module during movement, the obstacle model needs to undergo a second expansion process.
[0026] The obstacle module is a black grid formed after the dilation processing of the obstacle model. The specific implementation method for setting the black grid formed by the dilation processing of the obstacle model is as follows: Use the circumcircle of the robot's projection on the ground as the robot in the two-dimensional map. The diameter of the circumcircle is D, and D is used as the length of the grid; Determine the edge line of the obstacle model, and set the free grids passed by the edge line as black grids; If two adjacent sides of a black grid are connected to two free grids A and free grid B, and free grid A and free grid B are in the diagonal positions of a 2*2 square grid, then further judge the comparison result of the distance L between the obstacle in the black grid and the center points of the two connected free grids and D / 2. Based on the comparison result of L and D / half, judge whether to set the two connected free grids as black grids.
[0027] Divide the black grid into two triangular regions C1 and C2 along the dotted diagonal, and calculate the minimum distances min(Lc1) and min(Lc2) of the two triangular regions C1 and C2 respectively; If the minimum distance min(Lc1)>D / 2 and min(Lc2)>D / 2, the two connected free grids remain blank; If there is a minimum distance min(Lc1)<D / 2 or min(Lc2)<D / 2 in the obstacle model, the part where L<D / 2 is named the out-of-bounds part, and the free grid connected to the triangular region where the out-of-bounds part is located will become a black grid; If there are out-of-bounds parts in both triangular regions, the free grids connected to the two triangular regions of the black grid are both set as black grids.
[0028] As Figure 3 shown, for example, there is an obstacle in the black grid C. Two adjacent sides of the black grid C are connected to two free grids A and B, and free grids A and B are in the diagonal positions of a 2*2 square grid. Obviously, the minimum distance min(L) in the C1 triangular region is less than D / 2, while the minimum distance min(L) in the C2 triangular region is greater than D / 2. The out-of-bounds part of the obstacle only exists in the C1 triangular region. Therefore, grid A needs to be set as a black grid, and grid B remains a blank grid to avoid the robot from colliding with the obstacle.
[0029] Through the dilation of the obstacle, the problems encountered by "larger-sized" entities such as robots or autonomous vehicles during navigation in narrow spaces are directly solved. Without dilation, the path planning algorithm may plan a theoretically feasible but actually colliding path because the algorithm is usually based on "points" or "center points" for planning and ignores the size of the entity itself. Dilation effectively takes the entity size into account.
[0030] In step 200, the path combination set formed by all selected rows of the free grid is used as an individual in the butterfly population in the butterfly optimization algorithm, and the expression method of forming the first generation path is as follows: each first generation path is encoded as a sequence of n key points {p1, p2, ..., pn}; N initial paths (butterfly individuals) are randomly selected from the first generation of paths, and each initial path satisfies basic constraints (such as fixed starting and end points and no initial collision).
[0031] However, the path formed by these 20 grids would collide with obstacles and could not directly support the robot's passage. Therefore, the first-generation path needed to be interpolated to form a second-generation path. In step 300, the method for interpolating the free grid between two adjacent rows of free grids in each first-generation line is: Interpolate the key points in each initial route to generate a continuous second-generation path; Discretize the interpolated second-generation path into a point set and check whether the discrete points of the second-generation path overlap with the obstacle grid; Eliminate collision paths from the second-generation paths and only retain the second-generation paths that can participate in subsequent optimization.
[0032] Furthermore, the method for forming a second generation path that connects all adjacent grids in the first generation path to form a continuous and collision-free path is as follows: The number corresponding to each free grid in the first generation line is determined, and two adjacent rows of grids selected according to the first generation line are defined as the current grid and the next grid, respectively, to determine whether the grid between the current grid and the next grid is a free grid; When the grid between the current grid and the next grid is a free grid, the free grid is inserted into the path as an interpolation grid; If the grid between the current grid and the next grid is not a free grid, the grid in the middle is moved in the four directions of up, down, left, and right in sequence until it moves to a free grid, and the selected free grid is inserted into the path of the first generation line; This process is repeated for all free grids corresponding to two unconnected adjacent points in the path of the first generation line until all adjacent grids in the path of the first generation line are continuous.
[0033] Repeat this process for all free grids corresponding to two unconnected adjacent points in the path of the first generation line until all adjacent grids in the path of the first generation line are continuous, and output a route for the robot to walk. The algorithm outputs a route for the robot to walk, such as Figure 4 shown.
[0034] The second generation path after interpolation of the first generation path is as follows Figure 5 The solid line in the middle is shown. The path length of each path in the second-generation path set is calculated and used as the fitness value of the individual butterfly. In step 400, the paths of the second-generation paths are formed after interpolation of the first-generation paths. Although the number of grids contained in each path in the second-generation path set is inconsistent, it will cause problems for the overall position update of the butterfly population in the butterfly optimization algorithm. However, the interpolation method used can follow strict logic. Therefore, each first-generation path corresponds one-to-one with the second-generation path.
[0035] In step 400, the method for selecting the shortest path among all second-generation paths and the path that can be used for normal robot travel using the improved butterfly optimization algorithm is as follows: Each path in the screened second-generation paths is used as a butterfly individual to form a butterfly population composed of the second-generation paths; Calculate the fitness of each butterfly individual, and use the path length of each butterfly individual as the fitness; When updating the path of each individual butterfly through global search, each butterfly updates its own position based on the fitness of other butterflies. The specific implementation method is as follows: ; where x best is the optimal path length among all current butterfly individuals, α is a random coefficient used to control the step length, is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment; When updating the path of each butterfly through local search, each butterfly randomly fine-tunes the position of key points near the current path. The specific implementation method is as follows: ; Where β is the step size and λ is the heavy-tailed distribution random step, which is used to enhance local exploration. is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment.
[0036] Among them, the fitness function design is specifically as follows: Calculate the total length of the interpolated path (such as Euclidean distance accumulation).
[0037] Generate a continuous path through interpolation (such as linear or spline interpolation) and check for conflicts with obstacles.
[0038] Fitness formula: Fitness= ; The goal of using the improved butterfly optimization algorithm is to minimize fitness.
[0039] The butterfly optimization algorithm after introducing genetic algorithm mutation retains the original mechanism of butterfly algorithm BOA (pheromone attraction, acoustic communication, position update) and introduces the mutation operator in genetic algorithm GA to enhance the diversity and global search capability of the algorithm.
[0040] The specific implementation is as follows: BOA Main Search: Each butterfly updates its path through a global or local search. Using the BOA's acoustic sensing mechanism (or scent mechanism), the butterfly moves and updates its position to find a better solution. The butterfly adjusts its position based on its proximity to other butterflies and their fitness (for example, shorter paths have lower fitness).
[0041] Introducing GA mutation: When no butterfly with high fitness is found through global search or local search for multiple times, mutation operation is applied to some butterflies in the current population. That is, after each iteration, or when the algorithm stagnates (no better solution is found after multiple consecutive iterations), mutation operation can be applied to some butterflies in the current population (for example, butterflies with low fitness, or some randomly selected butterflies).
[0042] Fitness evaluation and selection: Recalculate the fitness of the mutated butterflies, select them based on their fitness, and retain butterflies with high fitness for the next iteration; Iteration: Repeat the global search, local search, and mutation steps until the termination condition of reaching the maximum number of iterations is met.
[0043] The butterfly optimization algorithm selects the shortest path after interpolation that allows the robot to travel normally. The interpolation process may result in some detours. To prevent these detours from being included in the final solution, the second-generation path is processed.
[0044] The butterfly optimization algorithm far outperforms the genetic algorithm in solving most problems. However, the genetic algorithm has consistently shown strong results for path planning. Therefore, this study incorporates the genetic algorithm's mutation process to improve the butterfly optimization algorithm. To improve computational efficiency and avoid unnecessary calculations, the last generation of paths solved by the butterfly optimization algorithm is mutated, and the optimal mutated path is selected to form the third generation path.
[0045] The butterfly algorithm, which incorporates a genetic algorithm, can avoid local optimality. The BOA may converge to a local optimum, and even the optimal path may not be the global optimum. Mutation can break the rigidity of the current solution, explore new search spaces, and enhance diversity. Mutation introduces randomness, preventing the algorithm from prematurely converging on a single solution and increasing the likelihood of finding a better solution. It also adapts to dynamic environments: If the environment is subject to change (such as moving obstacles), the mutated path may be more robust. In some cases, slight mutations can help the algorithm escape local optimality more quickly and find a better solution.
[0046] The implementation method of mutating the last generation path in the butterfly optimization algorithm solution path and selecting the optimal path after mutation to form the third generation path is as follows: The path with the lowest fitness in each iterative operation is retained as the current optimal solution, where the path with the lowest fitness is the shortest path and has no collisions, that is, a candidate solution is generated: the mutated path is used as a new candidate solution for further optimization.
[0047] Mutate the path of the current optimal solution to generate candidate solutions, and evaluate the fitness again, that is, evaluate the new path: through interpolation and collision detection, evaluate whether the mutated path is better (shorter and feasible).
[0048] When the maximum number of iterations is reached or the fitness change is less than the threshold, the iteration is stopped and the global optimal path is output, that is, a new generation of path is formed: the optimal mutation path is used as the "third generation path" and enters the subsequent optimization stage.
[0049] Furthermore, the implementation method of mutating the path of the current optimal solution is one of Gaussian mutation, exchange mutation, insertion mutation, reversal mutation, and adaptive mutation; Gaussian mutation is to apply Gaussian noise to a key point (x, y) on the path: x′=x+N(0,σ),y′=y+N(0,σ); where σ is the intensity of variation; The swap mutation randomly selects two key points in the path and swaps their positions: Path=[p1,p2,…,pi,…,pj,…,pn]→[p1,p2,…,pj,…,pi,…,pn]; Insertion mutation randomly selects a key point and inserts it into another random position of the path: Path=[p1,…,pi,…,pj,…,pn]→[p1,…,pj,pi,…,pn]; The inversion mutation is to randomly select a subpath in the path and reverse it: Path = [p1, …, pi, pi+1, …, pj, …, pn] → [p1, …, pj, pj−1, …, pi, …, pn]; Adaptive mutation is as follows: Dynamically adjust the mutation intensity according to the current algorithm state: If the convergence is slow, increase the mutation intensity (enhance exploration); If the convergence is fast, decrease the mutation intensity (enhance exploitation).
[0050] As Figure 6 shown, the length of the shortest path obtained by the improved butterfly optimization algorithm is 32.6274. To verify the effectiveness of the improved butterfly optimization algorithm in solving the path planning problem, the improved butterfly optimization algorithm is compared with the genetic algorithm.
[0051] In this embodiment, the improved butterfly optimization algorithm and the genetic algorithm are applied to the path planning problem. The path length obtained by the improved butterfly optimization algorithm is shorter and the number of iterations is less.
[0052] To reduce the energy consumption of the robot during movement, it is necessary to shorten the path length as much as possible. Therefore, this study proposes two simplification strategies to process the third-generation path, and the purpose of maximizing path simplification is achieved by selectively removing points on the path.
[0053] Strategy 1: The determination method of the path that can be simplified is mainly divided into 3 cases as Figure 7 shown.
[0054] It is known that there are Pend points in the path. Assume that the current point is P(i), where i (i < P(end) - 1) is the position of the current point in the path.
[0055] Case a: When the line connecting P(i) and P(i + 2) is the diagonal of a 3×2 rectangular box, if all 6 grids within this rectangular box are free grids, then P(i + 1) will be determined as a deletable point and this matrix will be determined as a reducible rectangle. Case b: When P(i) and P(i + 2) are in the same row, it is necessary to determine whether the 3×3 matrix with the line connecting P(i) and P(i + 2) as the middle line of the rectangle is all free grids. If all 9 grids are free grids, then this matrix will be determined as a reducible rectangle and P(i + 1) will be determined as a deletable point. Case c: When there are two or more consecutive points, that is, when the point P(i) to the point P(i + n c , 1 ≤ n c < P(end) - 1 - i, and all satisfy one of the above two cases, then the points P(i + 1) to P(i + n c +1) can all be determined as deletable points. The horizontal direction of the path is simplified according to the above three cases. The same three cases are also determined and simplified for the vertical direction of the path. Thus, the first step of path simplification is completed.
[0056] Take the dotted box 1-2 as an example, when the robot's running path exists as follows Figure 8 The path can be simplified in the following cases: The dotted rectangle 1 represents a single vertical simplification, and the dotted rectangle 2 represents a path simplification when two or more consecutive points in the vertical direction meet the reduction condition.
[0057] like Figure 9 As shown in Figure 2, the result of simplifying the complete path is that the length of the fourth-generation path is 30.9388 units.
[0058] Strategy 2: The second strategy further processes the optimized path. It primarily processes paths where some of the grids in the n×2 rectangular grid (2×n rectangular grid vertically) formed by three consecutive horizontal points are obstacles, determining whether the path can be simplified. n is the number of horizontal (vertical) grids between the first and third points.
[0059] like Figure 10 As shown in the figure, horizontal simplification is used as an example. When the robot passes through points 1→2→3, point 1 is called the simplification starting point. The number of horizontal grid cells n(in) between points 1 and 3 is calculated. When point 1 has np continuous horizontal free grid cells in the direction of point 3, and point 3 has np continuous horizontal free grid cells in the direction of point 1, the condition for removing point 2 is met, and the path can be simplified. The formulas for calculating n(in) and np are as follows.
[0060] ; In the formula, x1 is the column number of the simplified initial point, and x3 is the column number of the third point ; like Figure 9 As shown in the figure, when the robot passes through the four points 3→4→5→6, it can be found that the 3→4→5 section and the 4→5→6 section both meet the path simplification conditions. At this time, the path is in the simplified path superposition state. Since the 4th point can be deleted when the 3→4→5 section meets the simplification conditions, and the 5th point can be deleted when the 4→5→6 section meets the path simplification conditions, it is considered to simplify the 3→4→5→6 section to 3→6. Figure 11 As shown, the 3→6 route exists in the simplified path 3→5 and the simplified path 4→6, so the feasibility of 3→6 is guaranteed. Generalizing this rule, when there are m consecutive simplified initial points in the path, let Po(ii) be the first simplified initial point, Po(ii+m-1) be the mth simplified initial point, and ii be the sequence number of the point in the robot motion path. In the sequence number of the robot motion path, only Po(ii) and Po(ii+m+1) need to be retained, and the middle points will be deleted to simplify the path.
[0061] Two simplification strategies are introduced into the improved butterfly optimization algorithm and path planning is performed. Figure 11 (a) Depicts the shortest path solved by genetic algorithm path planning, with a path length of 32.6274 units. Figure 11 (b) Depicts the shortest path finally solved by the improved butterfly optimization algorithm. The path length is 30.2914 units, and the path length is significantly reduced.
[0062] The above embodiments are merely exemplary embodiments of the present application and are not intended to limit the scope of the present application. The scope of protection of the present application is defined by the claims. Those skilled in the art may make various modifications or equivalent substitutions to the present application within the essence and scope of protection of the present application, and such modifications or equivalent substitutions shall also be deemed to fall within the scope of protection of the present application.
Claims
1. A robot path planning method based on an improved butterfly optimization algorithm, characterized in that: The following steps are involved: Step 100: Build an environment model for robot path planning and record the coordinate information and contour information of all obstacles in the robot database; Step 200: Determine the starting point and end point of the grid map corresponding to the environmental model, screen the free grids in each row, and use the route combination set formed by all the selected rows of free grids as an individual in the butterfly population in the butterfly optimization algorithm to form a first generation of routes; Step 300: interpolate free grids between two adjacent rows of free grids in each of the first generation lines to form a second generation path that connects all adjacent grids in the path of the first generation line and has no collisions; Step 400: The path length of each second-generation path is used as the fitness value of the corresponding butterfly individual. The improved butterfly optimization algorithm is used to select the shortest path among all second-generation paths that can be used for normal robot driving. The last generation path in the path solved by the butterfly optimization algorithm is mutated, and the optimal path after mutation is selected to form the third-generation path.
2. A robot path planning method based on an improved butterfly optimization algorithm according to claim 1, characterized in that: In step 100, the coordinate information and contour information of all obstacles are recorded in the robot database as follows: Construct a grid map, where the black grids are obstacle modules and the white grids are movable areas; The positive direction of the X axis is defined from left to right, the positive direction of the Y axis is defined from bottom to top, and the grid length is defined as a unit length. A two-dimensional coordinate plane of the grid map is established, and the grids are numbered for planning the robot's motion path. The specific grid numbers are: ; Where num is the grid number, x is the column number of the current grid, y is the row number of the current grid, and x(max) is the total number of columns in the grid map.
3. A robot path planning method based on an improved butterfly optimization algorithm according to claim 2, characterized in that: The obstacle module is a black grid formed by the expansion of the obstacle model. The specific implementation method of the black grid formed by the expansion of the obstacle model is as follows: The robot in the two-dimensional map is represented by the circumscribed circle projected on the ground. The diameter of the circumscribed circle is D, and D is the length of the grid. Determine the edge line of the obstacle model, and set the free grids through which the edge line passes as black grids; If two adjacent sides of the black grid are connected to two free grids A and B, and free grids A and B are located at the diagonal positions of the 2*2 square grid, the comparison result of the distance L between the obstacle in the black grid and the line connecting the center points of the two connected free grids and D / 2 is further determined. Based on the comparison result of L and D / 2, it is determined whether the two connected free grids should be set as black grids.
4. A robot path planning method based on an improved butterfly optimization algorithm according to claim 3, characterized in that: Divide the black grid into two triangular areas C1 and C2 along the dotted diagonal lines, and calculate the minimum distances min(Lc1) and min(Lc2) of the two triangular areas C1 and C2 respectively; If the minimum distance min(Lc1)>D / 2 and min(Lc2)>D / 2, the two adjacent free grids remain blank; The minimum distance min(Lc1) in the obstacle model If both triangular regions have out-of-bounds portions, the free grids connected to the two triangular regions of the black grid are set as black grids.
5. The robot path planning method based on the improved butterfly optimization algorithm according to claim 1, characterized in that: In step 300, the second generation path is formed by connecting all adjacent grids in the first generation path to form a continuous and collision-free path as follows: The number corresponding to each free grid in the first generation line is determined, and two adjacent rows of grids selected according to the first generation line are defined as the current grid and the next grid, respectively, to determine whether the grid between the current grid and the next grid is a free grid; When the grid between the current grid and the next grid is a free grid, the free grid is inserted into the path as an interpolation grid; If the grid between the current grid and the next grid is not a free grid, the grid in the middle is moved in the four directions of up, down, left, and right in sequence until it moves to a free grid, and the selected free grid is inserted into the path of the first generation line; This process is repeated for all free grids corresponding to two unconnected adjacent points in the path of the first generation line until all adjacent grids in the path of the first generation line are continuous.
6. A robot path planning method based on an improved butterfly optimization algorithm according to claim 5, characterized in that: In step 300, the method for selecting the shortest path among all second-generation paths that can be used for normal robot travel is as follows: Encode each first-generation path into a sequence of n key points {p1, p2, ..., pn}; Randomly select N initial paths from the first generation of paths, each of which satisfies basic constraints; Interpolate the key points in each initial route to generate a continuous second-generation path; Discretize the interpolated second-generation path into a point set and check whether the discrete points of the second-generation path overlap with the obstacle grid; Eliminate collision paths from the second-generation paths and only retain the second-generation paths that can participate in subsequent optimization.
7. The robot path planning method based on the improved butterfly optimization algorithm according to claim 5, characterized in that: In step 400, the method for selecting the shortest path among all second-generation paths and the path that can be used for normal robot travel using the improved butterfly optimization algorithm is as follows: Each path in the screened second-generation paths is used as a butterfly individual to form a butterfly population composed of the second-generation paths; Calculate the fitness of each butterfly individual, and use the path length of each butterfly individual as the fitness; When updating the path of each individual butterfly through global search, each butterfly updates its own position based on the fitness of other butterflies. The specific implementation method is as follows: ; where x best is the optimal path length among all current butterfly individuals, α is a random coefficient used to control the step length, is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment; When updating the path of each butterfly through local search, each butterfly randomly fine-tunes the position of key points near the current path. The specific implementation method is as follows: ; Where β is the step size and λ is the heavy-tailed distribution random step, which is used to enhance local exploration. is the path length of a butterfly individual at the current moment, is the path length of the butterfly individual at the next moment.
8. The robot path planning method based on the improved butterfly optimization algorithm according to claim 7, characterized in that: After updating the path of each butterfly individual through global search or local search, or when no butterfly individual with high fitness is found through global search or local search for multiple times, mutation operation is applied to some butterflies in the current population; The fitness of the mutated butterflies is recalculated, and selection is performed based on the fitness, with butterflies with high fitness retained for the next iteration; the global search, local search, and mutation steps are repeated until the termination condition of reaching the maximum number of iterations is met.
9. The robot path planning method based on the improved butterfly optimization algorithm according to claim 8, characterized in that: The last generation of paths solved by the butterfly optimization algorithm is mutated, and the optimal path after mutation is selected to form the third generation path. The implementation method is to retain the path with the lowest fitness in each iteration as the current optimal solution, where the path with the lowest fitness is the shortest and collision-free path. The path of the current optimal solution is mutated to generate candidate solutions, and the fitness is evaluated again. When the maximum number of iterations is reached or the fitness change is less than the threshold, the iteration is stopped and the global optimal path is output.
10. A robot path planning method based on an improved butterfly optimization algorithm according to claim 9, characterized in that: The implementation method of mutating the path of the current optimal solution is one of Gaussian mutation, exchange mutation, insertion mutation, reversal mutation, and adaptive mutation. Gaussian mutation is to apply Gaussian noise to a key point (x, y) on the path: x′=x+N(0,σ); y′=y+N(0,σ); where x′ and y′ are the column and row numbers of the grid after applying Gaussian noise, N is the mutation function, and σ is the mutation intensity; exchange mutation is to randomly select two key points in the path and exchange their positions: Path=[p1,p2,…,pi,…,pj,…,pn]→[p1,p2,…,pj,…,pi,…,pn]; insertion mutation is to randomly select a key point and insert it into another random position of the path: Path=[p1,…,pi,…,pj,…,pn]→[p1,…,pj,pi,…,pn]; reversal mutation is to randomly select a subpath in the path and reverse it: Path=[p1,…,pi,pi+1,…,pj,…,pn]→[p1,…,pj,pj−1,…,pi,…,pn]; where Path is the path, p1,p2,…,pi, pi+1,…,pj−1,pj,…,pn are the positions of each key point; adaptive mutation dynamically adjusts the mutation intensity according to the current algorithm state: if the convergence is slow, the mutation intensity is increased; if the convergence is fast, the mutation intensity is reduced.