Repository navigation
Compute grid node index from grid indices only (#1318) - #1495
Open
blessedefe4real wants to merge 2 commits into
Open
blessedefe4real wants to merge 2 commits into
blessedefe4real wants to merge 2 commits into
Conversation
calc_index/calc_grid_index subtracted min_x/min_y (meters) from node.x/node.y, which are already grid indices. Because the offset is constant the mapping stayed unique, but the units were mixed and the resulting keys could fall outside [0, x_width * y_width). Use node.y * x_width + node.x in Dijkstra, A*, Theta*, bidirectional A* and bidirectional BFS. Planned paths are unchanged. Add a regression test for the index range.
Check that the first cell maps to index 0 and the last cell to x_width * y_width - 1 when the map origin is not (0, 0) and the resolution is 0.5, for Dijkstra and A*. Both tests fail with the previous formula.
blessedefe4real
force-pushed
the
fix/grid-index-units-1318
branch
2 times, most recently
from
November 6, 2026 21:19
fdcc535 to
7264650
Compare
1 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue
Fixes #1318
What does this implement/fix?
calc_index/calc_grid_indexcomputed(node.y - self.min_y) * self.x_width + (node.x - self.min_x), butnode.x/node.yare already grid indices whilemin_x/min_yare map coordinates in meters, so the units were mixed and indices could fall outside[0, x_width * y_width)when the map does not start at the origin.This uses
node.y * self.x_width + node.xin:PathPlanning/Dijkstra/dijkstra.pyPathPlanning/AStar/a_star.pyPathPlanning/ThetaStar/theta_star.pyPathPlanning/BidirectionalAStar/bidirectional_a_star.pyPathPlanning/BidirectionalBreadthFirstSearch/bidirectional_breadth_first_search.pyPlanned paths from all five planners'
main()are identical before and after.Additional information
As requested in the review of #1360, the tests use a non-zero map origin and a resolution of 0.5, and check that the first cell maps to index 0 and the last to
x_width * y_width - 1(Dijkstra and A*), and that every Dijkstra index is unique and in range. They fail onmasterand pass with this change.#1461 fixes the same line in Dijkstra only; this PR covers the other four planners that copied it.
CheckList
pytest tests -Werrorpasses locally; CI awaiting workflow approval)