Automatic route laying method and device based on A-satellite way-finding algorithm
By applying the A-Star Pathfinding algorithm in route design, the route is automatically generated and optimized, and the problems of low efficiency and poor accuracy of manual route design are solved, and more efficient and accurate route layout is achieved.
Patent Information
- Application Number
- CN202510215073.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-03-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Manually designed ship routes are inefficient and inaccurate, and there are problems of human error and repeated modification of routes.
The A-Star Pathfinding algorithm is used to obtain terrain data and water depth, perform rasterization processing, mark the starting point and end point of the route, use the A-Star Pathfinding algorithm to generate the initial route, and arc the turning point to form a recommended route.
Automatic route layout is realized, the problems of inaccurate and repeated modifications of manual route layout are solved, and the efficiency and accuracy of route design are improved.
Smart Images

Figure CN119714299A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of waterway design informatization, and in particular to a method and device for automatically laying out a route based on an A-star pathfinding algorithm. Background Art
[0002] A route is a virtual line in the center of a waterway that is used to guide ships and ensure safety. The route divides the waterway into two parts: a navigation channel and an area where ships are prohibited from passing, thereby ensuring that ships do not collide with other ships during navigation. In the usual waterway engineering design process, routes are often laid out by engineers based on experience, which requires high personal qualities; at the same time, the layout involves repeated modifications, which is time-consuming and labor-intensive; manually laid routes also have problems such as insufficient comprehensive judgment of the bending radius and water flow conditions. Summary of the invention
[0003] In order to solve the problems of low efficiency and inaccurate judgment in manual design of ship routes, the present invention provides a method and device for automatic route layout based on the A-star pathfinding algorithm. By combining terrain data with the A-star pathfinding algorithm, a method for automatic route layout is designed, which is conducive to automatic route layout by writing computer software, and can solve the problems of inaccurate manual route drawing and human errors; it also solves the problem of repeated route modifications due to human subjective judgment.
[0004] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions: A method for automatically laying out routes based on an A-star pathfinding algorithm comprises the following steps: S1, obtaining terrain data, and obtaining a gridded water depth grid based on the terrain data and the water depth; S2, judging the water depth grid data according to the allowable value of the navigation channel depth, and obtaining the passable area; S3, marking the starting point and the end point of the route in the passable area, and using the A-star pathfinding algorithm to obtain an initial route; S4, performing arc processing on the turning point of the initial route to obtain a recommended route.
[0005] As a preferred solution, step S3 specifically includes the following steps: S30, determining the parent node according to the starting point; S31, determining the neighbor grids around the parent node according to the parent node, calculating the distance from the parent node to the neighbor grid, and obtaining the initial cost; S32, calculating the Manhattan distance between the neighbor grid and the end point D as the estimated cost of moving from the neighbor grid to the end point; S33, summing the initial cost and the estimated cost to obtain the total cost of each neighbor grid; S34, selecting a neighboring grid with the smallest total cost from the neighboring grids as a new parent node; S35, repeat steps S31 to S34 until the estimated cost is 0, and obtain several parent nodes; S36. Connect several parent nodes to obtain an initial route.
[0006] As a preferred solution, in step S31, the constraints for the initial cost calculation are: the distance that the current grid moves upward, downward, left, and right is the first distance; the distance that the current grid moves toward the upper left, upper right, lower left, and lower right is the second distance; the first distance and the second distance satisfy the Pythagorean theorem.
[0007] As a preferred solution, the first distance is a, and the second distance is .
[0008] As a preferred solution, in step S36, connecting several parent nodes specifically means: starting from the end point, connecting to the parent nodes of the next level up in sequence until returning to the starting point.
[0009] As a preferred solution, if there are multiple parent nodes in the same level, the parent node closest to the end point D is selected as the grid for connection.
[0010] As a preferred solution, step S4 includes the following steps: checking whether the bending radius of the initial route meets the specification requirements. If the bending radius meets the requirements, the initial route is the recommended route; if the bending radius does not meet the requirements, the bending radius arc is used to replace the broken line to form a recommended route.
[0011] As a preferred solution, step S2 includes the following steps: determining a water depth grid that is greater than or equal to the allowable value of the navigation channel depth as a passable area.
[0012] As a preferred option, the allowable value of the navigation groove depth is 5.0 m.
[0013] Based on the same concept, a device for automatic route layout based on the A-star pathfinding algorithm is also proposed, comprising at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above-mentioned methods for automatic route layout based on the A-star pathfinding algorithm.
[0014] Compared with the prior art, the advantages of the present invention are as follows: the present invention provides a method and device for automatic route layout based on the A-star pathfinding algorithm, which is conducive to automatic route layout by writing computer software, and can solve the problems of inaccurate route drawing and human errors in manual route layout; it also solves the problem of repeated route modifications due to human subjective judgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 This is a flow chart of a method for automatically laying out routes based on the A-star pathfinding algorithm in Example 1; Figure 2 is a schematic diagram of the water depth grid data in Example 1; Figure 3 is a schematic diagram of the passable area in Example 1; Figure 4 It is a schematic diagram of setting the starting point and end point of the waterway in Example 1; Figure 5 This is a schematic diagram of cost calculation for a grid moving in eight directions in Example 1; Figure 6 is a schematic diagram of neighboring grids around the starting grid in Example 1; Figure 7 is a schematic diagram of calculating the distance from the parent node through each neighbor grid to the end point D in Example 1; Figure 8 is a schematic diagram of calculating the total cost with a4 as the parent node in Example 1; Fig. 9 is a schematic diagram of calculating the total cost with a5 as the parent node in Example 1; Fig.10 This is a schematic diagram of putting b2 into the closed list after b2 is screened out in Example 1; Fig.11 is a schematic diagram of calculating the total cost with b2 as the parent node in Example 1; Fig.12 is a schematic diagram of backtracking to obtain the best route in Example 1; Fig.13 It is a schematic diagram of the initial route obtained by tracing back the grid lines in Example 1; Fig.14 is a schematic diagram of the recommended route after arc processing in Example 1; Fig.15 is a schematic diagram of an automatic route layout device based on the A-star pathfinding algorithm in Example 2; Fig.16 is a schematic diagram of a water depth grid after gridding in Example 2; Fig.17 is the initial route map obtained by using the A-star pathfinding algorithm in Example 2; Fig.18 This is the final recommended route map obtained after the broken line is subjected to arc processing in Example 2. DETAILED DESCRIPTION
[0016] The present invention is further described in detail below in conjunction with the examples and specific implementation methods. However, this should not be understood as the scope of the above subject matter of the present invention being limited to the following examples, and all technologies realized based on the content of the present invention belong to the scope of the present invention.
[0017] Example 1 A method for automatically laying out routes based on the A-star pathfinding algorithm, the flow chart is as follows: Figure 1 As shown, the following steps are included: S1, obtaining terrain data, and obtaining gridded water depth raster data according to the terrain data and water depth; S2, judging the water depth grid data according to the allowable value of the navigation channel depth, and obtaining the passable area; S3, marking the starting point and the end point of the route in the passable area, and using the A-star pathfinding algorithm to obtain an initial route; S4, performing arc processing on the turning point of the initial route to obtain a recommended route.
[0018] Step S1 specifically includes the following steps: Import the water depth raster data into the GIS system. The schematic diagram of the water depth raster data is as follows Figure 2 As shown in the figure, the topographic map is divided into several grids, each grid is marked with the corresponding water depth, and the water depth data is discretized to form two-dimensional data, including data rows and data columns. Each grid has a corresponding water depth, such as Figure 2 As shown in the figure, the water depths of the first row of grids are 8.0 m, 4.8 m, 7.6 m, 5.3 m, and 8.8 m. The size of the grid division can be set according to the area and region involved in the route.
[0019] Step S2 specifically includes the following steps: S22, import the allowable value of the navigation channel depth Hmin (assuming it is 5.0 m) into the GIS system; S23, mark the water depth grids less than Hmin as obstacles (indicated by non-blank grids); S24, mark the water depth grids greater than or equal to Hmin as passable areas (indicated by blank grids). The schematic diagram of the passable area is as follows Figure 3 shown.
[0020] Step S3 generally includes the following steps: S30, determine the starting point and the end point of the route, obtain the location information of the starting point grid and the end point grid, and take the starting point S as the parent node of the first level; S31, determining the neighbor grids around the parent node according to the parent node, calculating the distance from the parent node to the neighbor grid, and obtaining the initial cost; S32, calculating the Manhattan distance between each neighbor grid and the end point D as the estimated cost of moving from the neighbor grid to the end point D; S33, summing the initial cost and the estimated cost to obtain the total cost of the parent node moving to the end point D through each neighbor grid; S34, selecting a neighboring grid with the smallest total cost from the neighboring grids as a new parent node; S35, repeat steps S31 to S34 until the estimated cost H is 0, and several parent nodes are obtained; S36. Connect several parent nodes to obtain an initial route.
[0021] In step S31, the constraint conditions for the initial cost calculation are: the distance that the current grid moves upward, downward, leftward, and rightward is the first distance; the distance that moves toward the upper left, upper right, lower left, and lower right is the second distance; the first distance and the second distance satisfy the Pythagorean theorem. Preferably, the first distance is a and the second distance is For example, if the first distance of the current grid upward is 1 and the second distance to the left is 1, then the second distance of the current grid moving upward to the left is .
[0022] Step S30 specifically includes the following steps: manually specifying the starting grid S of the waterway (the starting grid is marked with diagonal lines in two directions), manually specifying the ending grid D of the waterway (the ending grid is marked with a curved grid), and setting the schematic diagram of the starting and ending points of the waterway as shown in FIG. Figure 4 shown.
[0023] Further, step S31 is divided into: S311, set the constraint condition as follows: a grid can move in eight directions around it, where the cost of moving up, down, left, and right is 1, and the cost of moving to the upper left, upper right, lower left, and lower right is 1.4 (approximate value). The cost calculation diagram of a grid moving in eight directions around it is as follows Figure 5 shown.
[0024] S312, adding the starting point S to an open list (Open List), which is used to store the nodes to be checked.
[0025] S313, construct an empty closed list (Closed List), which is used to store checked nodes.
[0026] S314, find all the passable areas around the starting point S. The eight grids around the starting point S are named neighbor grids. The grids with passable areas among all the neighbor grids around the starting point S are marked as oblique grids facing one direction. The schematic diagram of the neighbor grids around the starting point grid is as follows: Figure 6 shown.
[0027] S315, the starting point S is set as its parent node, and the initial cost (denoted as G) of moving from the starting point S to each grid in the surrounding passable area is calculated.
[0028] S32 specifically includes the following steps: S321, add all neighbor grids found in the previous step to the open list (Open List) as nodes to be checked.
[0029] S323, calculate the Manhattan distance H = |x1-x2| + |y1-y2| between each node to be checked and the end point D as the estimated cost (denoted as H) of moving from the node to the end point D, where (x1, y1) is the two-dimensional coordinate of the grid of the node to be checked, and (x2, y2) is the two-dimensional coordinate of the grid where the end point D is located.
[0030] S33 specifically includes the following steps: add the initial cost G and the estimated cost H, and record it as the total cost F. At this time, the value of the total cost F reflects the distance from the parent node (for example, the starting point S) through each neighbor grid to the end point D. The schematic diagram of calculating the distance from the starting point S through each neighbor grid to the end point D is as follows: Figure 7 As shown. The cost from the starting point S to the end point D through the neighbor grid a1 is calculated as follows: the initial cost G from the starting point S to the neighbor grid a1 is 1.4, and the estimated cost H from the neighbor grid a1 to the end point D is 5, so the total cost is F=1.4+5=6.5. Using the same method, the total cost corresponding to a2, a3, a5, and a6 in the nodes to be checked can be calculated.
[0031] S34 specifically includes the following steps: selecting a node with the smallest F value from the open list. Figure 7 As shown, the neighbor grid with the smallest F value is a4, and the total cost corresponding to point a4 is 3, that is, the distance is 3. The neighbor grid with the smallest F value is marked by filling the grid with irregular points. The current node a4 is removed from the Open List and put into the ClosedList. a4 is the node that has been checked.
[0032] S35 specifically includes the following steps: Check the neighbor grids of grid a4. If the neighbor grid is already in the Closed List, ignore it directly. Otherwise, check whether the neighbor grid is in the Open List. If the neighbor grid is not in the Open List, take a4 as the parent node and calculate the initial cost G, estimated cost H and total cost F of the neighbor grid not in the Open List according to the above method (such as Figure 8As shown in the figure, b1 and b2 are neighboring grids that are not in the Open List), and the neighboring grids around a4 that are not in the Closed List and OpenList are added to the Open List. If the neighboring grid is already in the Open List, it is still retained in the Open List. At this point, the updated new open list is obtained. The schematic diagram of calculating the total cost with a4 as the parent node is as follows Figure 8 As shown in , grids b1 and b2 are added to the list, and the point with the smallest total cost F is selected from the updated open list and put into the closed list. Figure 8 As shown, after adding the b1 and b2 grids, the ones with the smallest total cost F in the list are a5, a3, b1 and b2, all of which are 4.4. When the minimum values are equal, any one is selected as the checked node and put into the closed list. In this embodiment, a5 is selected, a5 is put into the closed list as the checked node, and a5 is marked as the checked node and its corresponding parent node is a4.
[0033] S36 specifically includes the following steps: Continue to sample the above method and execute it cyclically to obtain the parent node of the next level. The schematic diagram of calculating the total cost with a5 as the parent node is as follows: Fig. 9 As shown in the figure, with a5 as the parent node, the newly added neighbor grids are c1, c2, and c3. The total cost from the starting point S through the parent node a4, the parent node a5 and the grid c1 to the end point is 7.8. Similarly, the total costs of c2 and c3 are calculated to be 6.4 and 5.8 respectively. The updated open list is as follows Fig. 9 As shown, at this time, in the open list, the ones with the smallest total cost F are a3, b1 and b2, all of which are 4.4. When the minimum values are equal, any one of them is selected as the checked node and put into the closed list. This embodiment selects a3, puts a3 into the closed list as the checked node, and marks a3 as the checked node whose corresponding parent node is the starting point S.
[0034] Next, with a3 as the parent node, the newly added grids are d1 and d2, and the total costs of d1 and d2 are calculated to be 6.4 and 5.8 respectively. The updated open list is as follows Fig.10 As shown, at this time, in the open list, the ones with the smallest total cost F are b1 and b2, both of which are 4.4. When the minimum values are equal, any one of them is selected as the checked node and put into the closed list. In this embodiment, b2 is selected, b2 is put into the closed list as the checked node, and b2 is marked as the checked node and its corresponding parent node is the starting point a4.
[0035] Next, with b2 as the parent node, the newly added grids are e1, e2, and e3. The total costs of e1, e2, and e3 are calculated to be 5.8, 4.4, and 0, respectively. The updated open list is as follows: Fig.11As shown, at this time, in the open list, e3 is equal to 0, indicating that e3 is the end point, e3 is put into the closed list as a checked node, and the parent node of e3 as a checked node is marked as b2. Since the total cost F is 0, it ends.
[0036] like Fig.11 As shown, the checked nodes in the closed list are a4, a5, a3, b2 and e3, and the parent nodes corresponding to a4, a5, a3, b2 and e3 are starting point, a4, starting point, a4 and b2 respectively. Therefore, the parent nodes b2, a4 and starting point are filtered out.
[0037] The steps of S36 are summarized as follows: first, the newly added checked node in the closed list is used as the parent node to find the corresponding newly added neighbor grid, and the newly added neighbor grid is added to the open list to generate an updated open list, and the node with the smallest total cost is found in the updated development list as the newly added checked node, and is put into the closed list, and other nodes are still saved in the open list; Secondly, the newly added checked nodes in the closed list are used as parent nodes to find the corresponding newly added neighbor grids, and the process is repeated according to the previous step to obtain a series of checked nodes in the closed list. The checked nodes in the closed list are not used as parent nodes, but the parent nodes of the checked nodes are extracted as the parent nodes for generating the initial route.
[0038] Further, S4 includes the following specific steps: starting from the end point D, connecting to the parent node of the next level in turn until returning to the starting point S, the connection passing through the parent node is the best route L, and the best route L is used as the initial route. The schematic diagram of backtracking to obtain the best route is as follows Fig.12 As shown, the parent node of the end point D is b2, the parent node of b2 is a4, and the parent node of a4 is the starting point S. Therefore, the initial route is obtained by connecting the end point D, b2, a4 and the starting point S.
[0039] After obtaining the grid of the initial route, S4 further includes the following specific steps: Check whether the bending radius of the initial route L meets the requirements of the specification. If the bending radius meets the requirements of the specification, the initial route L is the recommended route and the calculation ends. If the bending radius does not meet the requirements of the specification, the bending radius arc required by the specification is used instead at the broken line to form the recommended route. The schematic diagram of the recommended route after arc processing is shown in Fig.14 shown.
[0040] Example 2 An automatic route layout device based on the A-star pathfinding algorithm includes at least one processor and a memory that is communicatively connected to the at least one processor; the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above-mentioned methods for automatic route layout based on the A-star pathfinding algorithm. A schematic diagram of an automatic route layout device based on the A-star pathfinding algorithm is shown in FIG. Fig.15 shown.
[0041] In addition, a specific route design is used as an example to verify the solution in Example 1. Fig.16 This is a schematic diagram of the water depth grid after rasterization obtained in step S1, in which the blank part is the passable area determined in step S2, and the starting point S and the end point D are marked. Fig.17 The initial route is obtained by using the A-star pathfinding algorithm in step S3. Fig.18 It is the final recommended route obtained after the arc processing of the broken line in step S4. Due to the adoption of the A-star pathfinding algorithm, the route design can achieve the shortest route distance in theory, and the optimal route can be generated by directly inputting parameters through the construction of a software platform, which saves costs, improves efficiency, and has high accuracy.
[0042] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for automatically laying out routes based on the A-star pathfinding algorithm, characterized in that: The following steps are involved: S1, obtaining terrain data, and obtaining a gridded water depth grid based on the terrain data and the water depth; S2, judging the water depth grid data according to the allowable value of the navigation channel depth, and obtaining the passable area; S3, marking the starting point and the end point of the route in the passable area, and using the A-star pathfinding algorithm to obtain an initial route; S4, performing arc processing on the turning point of the initial route to obtain a recommended route.
2. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 1, characterized in that: Step S3 specifically includes the following steps: S30, determining the parent node according to the starting point; S31, determining the neighbor grids around the parent node according to the parent node, calculating the distance from the parent node to the neighbor grid, and obtaining the initial cost; S32, calculating the Manhattan distance between the neighbor grid and the end point D as the estimated cost of moving from the neighbor grid to the end point; S33, summing the initial cost and the estimated cost to obtain the total cost of each neighbor grid; S34, selecting a neighboring grid with the smallest total cost from the neighboring grids as a new parent node; S35, repeat steps S31 to S34 until the estimated cost is 0, and obtain several parent nodes; S36. Connect several parent nodes to obtain an initial route.
3. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 2, characterized in that: In step S31, the constraints for the initial cost calculation are: the distance that the current grid moves upward, downward, leftward, and rightward is the first distance; the distance that the current grid moves toward the upper left, upper right, lower left, and lower right is the second distance; the first distance and the second distance satisfy the Pythagorean theorem.
4. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 3, characterized in that: The first distance is a, and the second distance is .
5. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 2, characterized in that: In step S36, connecting several parent nodes specifically means: starting from the end point, connecting to the parent nodes of the next level up in sequence until returning to the starting point.
6. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 5, characterized in that: If there are multiple parent nodes at the same level, the parent node closest to the end point is selected as the grid for connection.
7. A method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in any one of claims 1 to 6, characterized in that: Step S4 includes the following steps: checking whether the bending radius of the initial route meets the specification requirements. If the bending radius meets the requirements, the initial route is the recommended route; if the bending radius does not meet the requirements, the bending radius arc is used to replace the broken line to form the recommended route.
8. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 1, characterized in that: Step S2 includes the following steps: determining the water depth grid that is greater than or equal to the allowable value of the navigation channel depth as a passable area.
9. The method for automatically laying out routes based on the A-star pathfinding algorithm as claimed in claim 8, characterized in that: The permissible value of the navigation groove depth is 5.0 m.
10. An automatic route layout device based on A-star pathfinding algorithm, characterized in that: It includes at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a method for automatic route layout based on an A-star pathfinding algorithm as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Unmanned ship track planning method based on deep optimization
CN110006429A
Ship driving route recommendation method and system
CN111292360A
Indoor mobile robot path planning and path optimization method based on improved A* algorithm
CN113485369A
Pirate area ship route planning method and system, electronic equipment and storage medium
CN113961004A
Unmanned ship path planning method based on improved A star algorithm
CN118392183A