Path planning method and device, storage medium and electronic equipment
By introducing methods to obtain maps to be planned and determine the set of path points in the A* algorithm, the dependence problem of the A* algorithm in the selection of heuristic functions is solved, and the efficiency of path planning and the accuracy of paths are improved.
Patent Information
- Application Number
- CN202411877416.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
AI Technical Summary
The performance of the A* algorithm in path planning depends on the choice of heuristic functions. If the heuristic function cannot effectively estimate the cost of the path, it may not be able to find the shortest path or the efficiency is reduced, and the computational efficiency is not good.
By obtaining the path points and connection relationships in the map to be planned, the path points passing through from the starting point to the end point are determined based on the current route point until the complete path is planned. This method does not require heuristic function operations on all adjacent points, which improves path planning efficiency.
The efficiency of path planning is improved, and the generated paths are more biased towards the endpoint, avoiding the dependence of the A* algorithm on the selection of heuristic functions.
Smart Images

Figure CN119831117A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of games, and more specifically, to a path planning method, device, storage medium and electronic device. Background Art
[0002] Pathfinding algorithms are used to find a path from one node (starting point) to another node (end point) in a graph, thereby providing path planning. In the field of games, A * The algorithm is used for path planning. However, in practice, it is found that * As a direct search method for solving the shortest path in a static road network, the algorithm is essentially an optimization of breadth-first search, which requires the use of a "heuristic" function to estimate the movement cost and the estimated cost to the end point to solve it.
[0003] Therefore, A * The performance of the algorithm depends heavily on the choice of heuristic function. If the heuristic function cannot estimate the cost from the current node to the target node well, A * The algorithm may not be able to find the shortest path or its efficiency may be reduced, and the algorithm must calculate the heuristic function once for each position that can be reached from the current position, so there is also the problem of poor efficiency. Summary of the invention
[0004] In order to overcome at least one of the deficiencies in the prior art, the present invention provides a path planning method, device, storage medium and electronic device, specifically including:
[0005] In a first aspect, the present application provides a path planning method, the method comprising:
[0006] Acquire a map to be planned, wherein the map to be planned has a plurality of path points distributed therein, a connection relationship is pre-established between the plurality of path points, and the connection relationship represents a connected path between two of the connected path points;
[0007] Determine a starting point and an end point from the plurality of path points, and use the starting point as the first waypoint from the starting point to the end point;
[0008] Determine, according to the current waypoint, a current set of adjacent waypoints from the plurality of waypoints, wherein the current set of adjacent waypoints includes reachable waypoints, and the reachable waypoints represent waypoints connected to the current waypoint;
[0009] If the end point is not included in the current set of adjacent path points, a new waypoint is determined based on the current set of adjacent path points, and the process returns to determining the current set of adjacent path points from the multiple path points based on the current waypoints until a path from the starting point to the end point is planned.
[0010] In conjunction with the optional implementation manner of the first aspect, determining a new waypoint according to the current set of adjacent path points includes:
[0011] Determine a current candidate point set from the current adjacent path point set, wherein the current candidate point set includes candidate points, and the candidate points represent reachable path points located in the periphery;
[0012] Based on the current set of candidate points, new waypoints are determined.
[0013] In conjunction with the optional implementation manner of the first aspect, determining a new waypoint according to the current candidate point set includes:
[0014] The candidate points in the current candidate point set that meet the preset screening conditions are taken as the points to be evaluated;
[0015] If the point to be evaluated does not have a reachable path point, and there are multiple candidate points in the current candidate point set, the point to be evaluated is removed from the current candidate point set, and the candidate point in the current candidate point set that meets the preset screening conditions is returned to be used as the point to be evaluated;
[0016] If the current point to be evaluated does not have a reachable path point, and the number of candidate points in the current candidate point set is single, the current waypoint is removed from the candidate point set of the previous waypoint to obtain a new candidate point set, and the previous waypoint is used as the new waypoint, and the process returns to the step of using the candidate point in the current candidate point set that meets the preset screening condition as the point to be evaluated;
[0017] If the point to be evaluated includes a reachable path point, the point to be evaluated is used as a new waypoint.
[0018] In combination with the optional implementation manner of the first aspect, the candidate points in the current candidate point set that meet the preset screening conditions are used as the points to be evaluated, including:
[0019] A point to be evaluated that is closest to a reference line and the end point is determined from the current candidate point set, wherein the reference line is a line connecting the current waypoint and the end point.
[0020] In conjunction with the optional implementation manner of the first aspect, determining the point to be evaluated that is closest to the reference line and the end point from the current candidate point set includes:
[0021] For each candidate point in the current candidate point set, the current waypoint is taken as a vertex, and the angle between the candidate point, the current waypoint and the end point is obtained;
[0022] Calculate the projection length of the line between the candidate point and the current waypoint on the reference line;
[0023] The point to be evaluated is determined from the current candidate point set according to the included angle and the projection length corresponding to each candidate point in the current candidate point set.
[0024] In combination with an optional implementation manner of the first aspect, determining the point to be evaluated from the current candidate point set according to the angle and the projection length corresponding to each candidate point in the current candidate point set includes:
[0025] For each candidate point in the current candidate point set, a weight of the candidate point is obtained according to the angle and projection length corresponding to the candidate point;
[0026] According to the weight of each candidate point in the current candidate point set, the point with the largest weight is selected as the point to be evaluated.
[0027] In combination with the optional implementation manner of the first aspect, obtaining the weight of the candidate point according to the angle and the projection length corresponding to the candidate point includes:
[0028] Obtaining an angle coefficient according to the angle corresponding to the candidate point, wherein the angle coefficient is positively correlated with the angle;
[0029] The ratio between the projection length of the candidate point and the angle coefficient is used as the weight of the candidate point.
[0030] In a second aspect, the present application further provides a path planning device, the device comprising:
[0031] An initialization module is used to obtain a map to be planned, wherein the map to be planned has a plurality of path points distributed therein, and a connection relationship is pre-established between the plurality of path points, wherein the connection relationship represents a connected path between two of the connected path points;
[0032] The initialization module is further used to determine a starting point and an end point from the multiple path points, and use the starting point as the first waypoint from the starting point to the end point;
[0033] A path planning module, configured to determine a current set of adjacent path points from a plurality of path points according to a current waypoint, wherein the current set of adjacent path points includes reachable path points, and the reachable path points represent path points connected to the current waypoint;
[0034] The path planning module is also used to determine a new waypoint based on the current set of adjacent path points if the destination is not included in the current set of adjacent path points, and return to determine the current set of adjacent path points from the multiple path points based on the current waypoints until a path from the starting point to the destination is planned.
[0035] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0036] Determine a current candidate point set from the current adjacent path point set, wherein the current candidate point set includes candidate points, and the candidate points represent reachable path points located in the periphery;
[0037] Based on the current set of candidate points, new waypoints are determined.
[0038] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0039] The candidate points in the current candidate point set that meet the preset screening conditions are taken as the points to be evaluated;
[0040] If the point to be evaluated does not have a reachable path point, and there are multiple candidate points in the current candidate point set, the point to be evaluated is removed from the current candidate point set, and the candidate point in the current candidate point set that meets the preset screening conditions is returned to be used as the point to be evaluated;
[0041] If the current point to be evaluated does not have a reachable path point, and the number of candidate points in the current candidate point set is single, the current waypoint is removed from the candidate point set of the previous waypoint to obtain a new candidate point set, and the previous waypoint is used as the new waypoint, and the process returns to the step of using the candidate point in the current candidate point set that meets the preset screening condition as the point to be evaluated;
[0042] If the point to be evaluated includes a reachable path point, the point to be evaluated is used as a new waypoint.
[0043] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0044] A point to be evaluated that is closest to a reference line and the end point is determined from the current candidate point set, wherein the reference line is a line connecting the current waypoint and the end point.
[0045] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0046] For each candidate point in the current candidate point set, the current waypoint is taken as a vertex, and the angle between the candidate point, the current waypoint and the end point is obtained;
[0047] Calculate the projection length of the line between the candidate point and the current waypoint on the reference line;
[0048] The point to be evaluated is determined from the current candidate point set according to the included angle and the projection length corresponding to each candidate point in the current candidate point set.
[0049] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0050] For each candidate point in the current candidate point set, a weight of the candidate point is obtained according to the angle and projection length corresponding to the candidate point;
[0051] According to the weight of each candidate point in the current candidate point set, the point with the largest weight is selected as the point to be evaluated.
[0052] In conjunction with the optional implementation manner of the second aspect, the path planning module is further specifically configured to:
[0053] Obtaining an angle coefficient according to the angle corresponding to the candidate point, wherein the angle coefficient is positively correlated with the angle;
[0054] The ratio between the projection length of the candidate point and the angle coefficient is used as the weight of the candidate point.
[0055] In a third aspect, the present application further provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the path planning method is implemented.
[0056] In a fourth aspect, the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the path planning method is implemented.
[0057] Compared with the prior art, this application has the following beneficial effects:
[0058] The present application provides a path planning method, device, storage medium and electronic device. Among them, the electronic device obtains a map to be planned, wherein a plurality of path points are distributed in the map to be planned, and a connection relationship is pre-established between the plurality of path points, and the connection relationship represents a connected path between two connected path points; a starting point and an end point are determined from the plurality of path points, and the starting point is used as the first waypoint from the starting point to the end point; based on the current waypoint, a current set of adjacent path points is determined from the plurality of path points, wherein the current set of adjacent path points includes reachable path points, and the reachable path points represent path points connected to the current waypoint; if the end point is not included in the current set of adjacent path points, a new waypoint is determined based on the current set of adjacent path points, and the process returns to determining the current set of adjacent path points from the plurality of path points based on the current waypoint, until the path from the starting point to the end point is planned. In this way, compared to A *The algorithm does not need to perform "heuristic" function calculations on all adjacent points of the current transit point, thereby improving the efficiency of path planning, and the generated path is more biased towards the end point. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 A schematic diagram of a path planning method according to an embodiment of the present invention;
[0061] Figure 2 A schematic diagram of the connection relationship between path points provided in an embodiment of the present application;
[0062] Figure 3 One of the process details of the path planning method provided in the embodiment of the present application;
[0063] Figure 4 A schematic diagram of the candidate point screening principle provided in the embodiment of the present application;
[0064] Figure 5 A second schematic diagram of the process details of the path planning method provided in an embodiment of the present application;
[0065] Figure 6 A schematic diagram of the principle of the waypoint selection strategy provided in the embodiment of the present application;
[0066] Figure 7 A schematic diagram of the structure of a path planning device provided in an embodiment of the present application;
[0067] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0069] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0070] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0071] In the description of this application, it should be noted that the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0072] Based on the above statement, as introduced in the background technology, A * As a commonly used path planning algorithm in games, its performance depends largely on the choice of heuristic function. If the heuristic function cannot estimate the cost from the current node to the target node well, A * The algorithm may not be able to find the shortest path or its efficiency may be reduced, and the algorithm must calculate the heuristic function once for each position that can be reached from the current position, so there is also the problem of poor efficiency.
[0073] Based on the discovery of the above technical problems, the inventors have proposed the following technical solutions to solve or improve the above problems through creative work. It should be noted that the defects in the solutions in the above prior art are the results obtained by the inventors after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of the present application for the above problems below should all be the contributions made by the inventors to the present application in the process of invention and creation, and should not be understood as technical contents known to those skilled in the art.
[0074] In view of this, this embodiment provides a path planning method. Figure 1 As shown, the method includes:
[0075] S1, obtaining the map to be planned.
[0076] There are multiple path points distributed in the map to be planned, and connection relationships are pre-established between the multiple path points. The connection relationship represents a connected path between two connected path points.
[0077] S2, determining a starting point and an end point from a plurality of path points, and taking the starting point as the first passing point from the starting point to the end point.
[0078] S3, according to the current waypoint, determine the current adjacent waypoint set from multiple waypoints.
[0079] The current set of adjacent path points includes reachable path points, and the reachable path points represent path points connected to the current waypoints.
[0080] S4, determine whether the current set of adjacent path points includes the end point. If not, execute S5, otherwise, execute S6.
[0081] S5, determine a new waypoint based on the current set of adjacent path points, and return to step S3 for execution.
[0082] S6, taking the end point as the last waypoint, and obtaining a path formed by connecting all the waypoints.
[0083] Thus, compared to A * Algorithm, this embodiment does not need to perform "heuristic" function calculations on all adjacent points of the current transit point, and the generated path is more biased towards the end point.
[0084] It should be noted that the electronic device implementing the method may be, but is not limited to, a mobile terminal, a tablet computer, a laptop computer, a desktop computer, a server, etc. The server may be a single server or a server group. The server group may be centralized or distributed (for example, the server may be a distributed system). In some embodiments, the server may be local or remote relative to the user terminal. In some embodiments, the server may be implemented on a cloud platform; as an example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud (CommunityCloud), a distributed cloud, an inter-cloud (Inter-Cloud), a multi-cloud (Multi-Cloud), etc., or any combination thereof. In some embodiments, the server may be implemented on an electronic device having one or more components.
[0085] To make the solution provided by this embodiment clearer, the following uses a server as an electronic device to implement the method. Figure 1Each step of the method shown is described in detail. However, it should be understood that the operations of the flowchart may not be implemented in order, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowchart, or remove one or more operations from the flowchart under the guidance of the content of this application.
[0086] Therefore, continue to see Figure 1 , the method comprising:
[0087] S1, obtaining the map to be planned.
[0088] There are multiple path points distributed in the map to be planned, and connection relationships are pre-established between the multiple path points, and the connection relationship represents a connected path between two connected path points. The map to be planned is a map in the game world, and the number of multiple path points in the map to be planned and the connection relationship between the multiple path points can be randomly generated, or can be manually set by the developer according to the actual terrain in the map to be planned.
[0089] Based on the above embodiments, the introduction of the path points and connection relationships in the planning map is continued. Figure 1 , the method further comprises:
[0090] S2, determining a starting point and an end point from a plurality of path points, and taking the starting point as the first passing point from the starting point to the end point.
[0091] S3, according to the current waypoint, determine the current adjacent waypoint set from multiple waypoints.
[0092] The current set of adjacent path points includes reachable path points, and reachable path points represent path points connected to the current waypoints. Figure 2 As shown, the figure shows multiple path points, some of which are connected by connecting lines, while some of the path points have no connecting lines, that is, there is no connection between the two. For the path points at both ends of the connecting line, it means that there is a direct road between the two path points, and the player can control the game character to move from one of the path points to another. If there are no connecting relationships between the two path points, it means that there is no direct road between the two path points, and the player needs to control the game character to take a detour from other path points to reach them. Therefore, for each path point, the path point connected to it is called a reachable path point, and the reachable path points of each path point can constitute an adjacent path point set.
[0093] Based on the introduction of the adjacent path point set in S3 in the above embodiment, continue to refer to Figure 1 , the method further comprises:
[0094] S4, determine whether the current set of adjacent path points includes the end point. If not, execute step S5, otherwise, execute step S6.
[0095] S5: Determine a new waypoint based on the current set of adjacent waypoints.
[0096] Considering that when there are many reachable path points in the current adjacent path point set, it may take too long to select a new waypoint, so the current adjacent path point set is first screened. Figure 3 As shown, an optional implementation of step S5 includes:
[0097] S5-1, determine the current candidate point set from the current adjacent path point set.
[0098] The current candidate point set includes candidate points, which represent reachable path points located in the periphery. For example, the end point is represented as B(x2, y2), and the current waypoint is represented as C(x1, y1). Using the coordinates of these two points, the general equation corresponding to the straight line passing through points C and B is calculated as ax+by+c=0, where the calculation expressions of a, b, and c are respectively:
[0099] a=By-Cy
[0100] b=Cx-Bx
[0101] c=.x*Cy-Cx*By
[0102] The equation ax+by+c=0 will divide the current set of adjacent path points into two parts, and remove the path points located in the middle of the two divided parts. That is, for any part, first, for the reachable waypoints with equal x values, only the one with the largest y value is retained as a candidate point; then, for the reachable waypoints with equal y values, only the one with the largest x value is retained as a candidate point. For example, Figure 4 As shown in the figure, the current waypoint C, its reachable waypoints are divided into two parts by the straight line passing through points C and B, and the outermost reachable waypoints can be used as candidate points.
[0103] Of course, in some other optional implementations, the straight line passing through points C and B can also be retained as the approach point. That is, for any part of them, first for the reachable waypoints with equal x values, only the one with the smallest y value is retained as the candidate point; then for the reachable waypoints with equal y values, only the one with the smallest x value is retained as the candidate point.
[0104] S5-2, determining a new waypoint based on the current candidate point set.
[0105] In this embodiment, a greedy algorithm is used to find new waypoints to continue iteration. Figure 5As shown, in the optional implementation manner provided in this embodiment, step S5-2 includes:
[0106] S5-2-1, select the candidate points that meet the preset screening conditions in the current candidate point set as the points to be evaluated.
[0107] In this regard, it should be understood that when selecting the point to be evaluated, the line between the selected point to be evaluated and the current waypoint should be as close to the reference line as possible, and the position should be as close to the end point as possible. This screening strategy can reduce the distance of the detour. Among them, the reference line is the line between the current waypoint and the end point. Therefore, the server can determine the point to be evaluated that is closest to the reference line and the end point from the current candidate point set. As an optional implementation, S5-2-1 may include:
[0108] S5-2-1-1, for each candidate point in the current candidate point set, take the current waypoint as the vertex, and obtain the angle between the candidate point and the current waypoint and the end point.
[0109] For example, it is assumed that the nth candidate point is represented as Dn, the current waypoint is represented as C, the end point is represented as B, and the angle formed by the three points with the current waypoint as the vertex is D:
[0110] D=acos(CDn*CB) / (|CDn|*|CB|)
[0111] S5-2-1-2, calculate the projection length of the line between the candidate point and the current waypoint on the reference line.
[0112] Assuming that the length of CDn is represented by L, the expression is:
[0113] L=sqrt((Dn.xC.x)*(Dn.xC.x)+(Dn.yC.y)*(Dn.yC.y))
[0114] Wherein, Dn.x represents the horizontal coordinate of the candidate point Dn, and Dn.y represents the vertical coordinate of the candidate point Dn; similarly, Cx represents the horizontal coordinate of the previous waypoint C, and Cy represents the vertical coordinate of the previous waypoint C.
[0115] Combining the angle and length L obtained above, the expression of the projection length Lt is:
[0116] Lt=L*cos(D*3.1415 / 180)
[0117] S5-2-1-3, determine the point to be evaluated from the current candidate point set according to the angle and projection length corresponding to each candidate point in the current candidate point set.
[0118] As an optional implementation, for each candidate point in the current candidate point set, the server can obtain the weight of the candidate point based on the angle and projection length corresponding to the candidate point; based on the weight of each candidate point in the current candidate point set, select the point with the largest weight as the point to be evaluated.
[0119] When calculating the weight of the candidate point, the server can obtain the angle coefficient according to the angle corresponding to the candidate point, wherein the angle coefficient is positively correlated with the angle; and the ratio between the projection length of the candidate point and the angle coefficient is used as the weight of the candidate point. It can be understood that this implementation evaluates the candidate point from two aspects: the angle formed by the candidate point and the distance between the candidate point and the end point, and selects the candidate point with the smallest angle possible and the closest to the end point as the point to be evaluated.
[0120] Exemplarily, taking the angle D and the projection length Lt obtained in the above implementation as an example, the expression of the angle coefficient F is:
[0121] F=1+(D*D / V)
[0122] Wherein, V represents a preset parameter, and its value in this embodiment is 10. Of course, when implementing this solution, technicians can make adaptive adjustments as needed. Based on the above angle coefficient F , The weight P of the candidate point is:
[0123] P=Lt / F
[0124] Therefore, the longer the projection length, the greater the weight, and the smaller the angle, the greater the weight, and both determine the degree of fit between the candidate point and the reference line and the distance from the end point.
[0125] S5-2-2, determine whether the point to be evaluated has a reachable path point. If yes, execute S5-2-6, otherwise, execute S5-2-3.
[0126] S5-2-3, determine whether there are multiple candidate points in the current candidate point set. If yes, execute S5-2-4, otherwise, execute S5-2-5.
[0127] S5-2-4, remove the point to be evaluated from the current candidate point set, and return to step S5-2-1 for execution.
[0128] S5-2-5, remove the current waypoint from the candidate point set of the previous waypoint to obtain a new candidate point set, and use the previous waypoint as the new waypoint. Then, return to step S5-2-1 for execution;
[0129] S5-2-6, the point to be assessed shall be used as a new waypoint.
[0130] In order to make the implementation of the above step S5-2 easier to understand, the above implementation is further described below in conjunction with 6, and for the convenience of description, it is assumed here that Figure 6 Only the candidate point set is shown in Figure 6 As shown, it is assumed that P1 is the first waypoint, P2 is determined as the second waypoint based on P1, P3 is determined as the third waypoint based on P2, and P4 is determined as the fourth waypoint based on P3.
[0131] When determining a new waypoint based on P4, P4 has a total of 4 candidate points, namely Q1, Q2, Q3, and Q4. Assume that Q1 is first determined as the point to be evaluated, but Q1 does not have a reachable path point, so Q1 is removed from the current candidate point set of P4.
[0132] Then, Q3 is determined as the point to be evaluated from the remaining Q2, Q3, and Q4, but Q3 also has no reachable path points, so Q3 is removed from the current candidate point set of P4.
[0133] Then, Q4 is determined as the point to be evaluated from the remaining Q2 and Q4, but Q4 also has no reachable path points, so Q4 is removed from the current candidate point set of P4.
[0134] Finally, P4 only has one candidate point Q2, but Q2 also has no reachable path points. Since there is only a single candidate point left in P4's candidate point set, namely Q2 that has been traversed, and there are no other untraversed candidate points, the previous waypoint P3 is used as a new waypoint again, and P4 is removed from P3's candidate point set. Then, a new waypoint is determined from the remaining candidate points based on P3.
[0135] Based on the description of the above embodiment for the new waypoint in step S5, see Figure 1 , the method further comprises:
[0136] S6, taking the end point as the last waypoint, and obtaining the path formed by connecting all the waypoints. In this way, the modeling of angles and distances in the above embodiment can be more in line with the concept of the "physical world", and the path points can be clipped at the same time to reduce the number of pathfinding calculations, and the calculated path is more oriented toward the end point. In addition, it should be noted that during the implementation of the above embodiment, the waypoints will change dynamically, and the current waypoint is the most recently determined waypoint. Similarly, the candidate point set will change with the changes in the waypoints, and the number of candidate points in the candidate point set of the same waypoint will also change. The current candidate point set refers to the most recently determined candidate point set.
[0137] Based on the same inventive concept as the path planning method provided in this embodiment, this embodiment also provides a path planning device, which includes at least one software function module that can be stored in the memory 21 or fixed in the electronic device in the form of software. The processor in the electronic device is used to execute the executable module stored in the memory 21. For example, the software function module and computer program included in the device. Please refer to Figure 7 , functionally speaking, the device may include:
[0138] Initialization module 11 is used to obtain a map to be planned, wherein a plurality of path points are distributed in the map to be planned, and a connection relationship is pre-established between the plurality of path points, and the connection relationship represents a connected path between two connected path points;
[0139] The initialization module 11 is further used to determine a starting point and an end point from a plurality of path points, and use the starting point as the first passing point from the starting point to the end point;
[0140] A path planning module 12, configured to determine a current set of adjacent path points from a plurality of path points according to a current waypoint, wherein the current set of adjacent path points includes reachable path points, and the reachable path points represent path points connected to the current waypoint;
[0141] The path planning module 12 is also used to determine a new waypoint based on the current set of adjacent path points if the destination is not included in the current set of adjacent path points, and return to determine the current set of adjacent path points from multiple path points based on the current set of adjacent path points until a path from the starting point to the destination is planned.
[0142] In this embodiment, the initialization module 11 is used to implement Figure 1 In steps S1 and S2, the path planning module 12 is used to implement Figure 1 Therefore, for the detailed description of each of the above modules, please refer to the specific implementation of the corresponding steps. In addition, it should be noted that since the above-mentioned path planning method has the same inventive concept, the path planning device can also implement other steps or sub-steps of the method through the above modules, which will not be described in detail in this embodiment.
[0143] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0144] It should also be understood that if the above implementation is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0145] Therefore, this embodiment also provides a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by the processor, the path planning method provided in this embodiment is implemented. Among them, the storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, etc., which can store program codes.
[0146] This embodiment provides an electronic device for implementing the path planning method. Figure 8 As shown, the electronic device may include a processor 22 and a memory 21. In addition, the memory 21 stores a computer program, and the processor implements the path planning method provided in this embodiment by reading and executing the computer program corresponding to the above implementation in the memory 21.
[0147] Continue to see Figure 8 The electronic device further includes a communication unit 23. The memory 21, the processor 22 and the communication unit 23 are electrically connected to each other directly or indirectly through a system bus 24 to achieve data transmission or interaction.
[0148] The memory 21 may be an information recording device based on any electronic, magnetic, optical or other physical principle, used to record execution instructions, data, etc. In some embodiments, the memory 21 may be, but is not limited to, a volatile memory, a non-volatile memory, a storage drive, etc.
[0149] In some embodiments, the volatile memory may be a random access memory (RAM); in some embodiments, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), a flash memory, etc.; in some embodiments, the storage drive may be a disk drive, a solid-state drive, any type of storage disk (such as a CD, a DVD, etc.), or a similar storage medium, or a combination thereof, etc.
[0150] The communication unit 23 is used to send and receive data through a network. In some embodiments, the network may include a wired network, a wireless network, a fiber optic network, a telecommunication network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof. In some embodiments, the network may include one or more network access points. For example, the network may include a wired or wireless network access point, such as a base station and / or a network switching node, through which one or more components of the service request processing system may be connected to the network to exchange data and / or information.
[0151] The processor 22 may be an integrated circuit chip having a signal processing capability, and the processor may include one or more processing cores (e.g., a single-core processor or a multi-core processor). By way of example only, the processor may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), or a microprocessor, or any combination thereof.
[0152] Understandably, Figure 8 The structure shown is for illustration only. The electronic device may also have Figure 8 More or fewer components than shown, or with Figure 8 Different configurations are shown. Figure 8 The components shown may be implemented in hardware, software or a combination thereof.
[0153] It should be understood that the apparatus and method disclosed in the above-mentioned embodiments can also be implemented in other ways. The apparatus embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0154] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A path planning method, characterized in that: The method comprises: Acquire a map to be planned, wherein the map to be planned has a plurality of path points distributed therein, a connection relationship is pre-established between the plurality of path points, and the connection relationship represents a connected path between two of the connected path points; Determine a starting point and an end point from the plurality of path points, and use the starting point as the first waypoint from the starting point to the end point; Determine, according to the current waypoint, a current set of adjacent waypoints from the plurality of waypoints, wherein the current set of adjacent waypoints includes reachable waypoints, and the reachable waypoints represent waypoints connected to the current waypoint; If the end point is not included in the current set of adjacent path points, a new waypoint is determined based on the current set of adjacent path points, and the process returns to determining the current set of adjacent path points from the multiple path points based on the current waypoints until a path from the starting point to the end point is planned.
2. The path planning method according to claim 1, characterized in that: Based on the current set of adjacent path points, new waypoints are determined, including: Determine a current candidate point set from the current adjacent path point set, wherein the current candidate point set includes candidate points, and the candidate points represent reachable path points located in the periphery; Based on the current set of candidate points, new waypoints are determined.
3. The path planning method according to claim 2, characterized in that: Based on the current candidate point set, new waypoints are determined, including: The candidate points in the current candidate point set that meet the preset screening conditions are taken as the points to be evaluated; If the point to be evaluated does not have a reachable path point, and there are multiple candidate points in the current candidate point set, the point to be evaluated is removed from the current candidate point set, and the candidate point in the current candidate point set that meets the preset screening conditions is returned to be used as the point to be evaluated; If the current point to be evaluated does not have a reachable path point, and the number of candidate points in the current candidate point set is single, the current waypoint is removed from the candidate point set of the previous waypoint to obtain a new candidate point set, and the previous waypoint is used as the new waypoint, and the process returns to the step of using the candidate point in the current candidate point set that meets the preset screening condition as the point to be evaluated; If the point to be evaluated includes a reachable path point, the point to be evaluated is used as a new waypoint.
4. The path planning method according to claim 3, characterized in that: The candidate points in the current candidate point set that meet the preset screening conditions are used as the points to be evaluated, including: A point to be evaluated that is closest to a reference line and the end point is determined from the current candidate point set, wherein the reference line is a line connecting the current waypoint and the end point.
5. The path planning method according to claim 4, characterized in that: Determine the point to be evaluated that is closest to the reference line and the end point from the current candidate point set, including: For each candidate point in the current candidate point set, the current waypoint is taken as a vertex, and the angle between the candidate point, the current waypoint and the end point is obtained; Calculate the projection length of the line between the candidate point and the current waypoint on the reference line; The point to be evaluated is determined from the current candidate point set according to the included angle and the projection length corresponding to each candidate point in the current candidate point set.
6. The path planning method according to claim 5, characterized in that: According to the angle and projection length corresponding to each candidate point in the current candidate point set, the point to be evaluated is determined from the current candidate point set, including: For each candidate point in the current candidate point set, obtain the weight of the candidate point according to the angle and projection length corresponding to the candidate point; According to the weight of each candidate point in the current candidate point set, the point with the largest weight is selected as the point to be evaluated.
7. The path planning method according to claim 6, characterized in that: The step of obtaining the weight of the candidate point according to the angle and the projection length corresponding to the candidate point includes: Obtaining an angle coefficient according to the angle corresponding to the candidate point, wherein the angle coefficient is positively correlated with the angle; The ratio between the projection length of the candidate point and the angle coefficient is used as the weight of the candidate point.
8. A path planning device, characterized in that: The device comprises: An initialization module is used to obtain a map to be planned, wherein the map to be planned has a plurality of path points distributed therein, and a connection relationship is pre-established between the plurality of path points, wherein the connection relationship represents a connected path between two of the connected path points; The initialization module is further used to determine a starting point and an end point from the multiple path points, and use the starting point as the first waypoint from the starting point to the end point; A path planning module, configured to determine a current set of adjacent path points from a plurality of path points according to a current waypoint, wherein the current set of adjacent path points includes reachable path points, and the reachable path points represent path points connected to the current waypoint; The path planning module is also used to determine a new waypoint based on the current set of adjacent path points if the destination is not included in the current set of adjacent path points, and return to determine the current set of adjacent path points from the multiple path points based on the current waypoints until a path from the starting point to the destination is planned.
9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the path planning method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory stores a computer program, and when the computer program is executed by the processor, the path planning method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Route planning method and device, electronic equipment and computer readable storage medium
CN120996317A
