Skip to content

Fix unit mismatch in Dijkstra calc_index#1360

Open
remete618 wants to merge 1 commit intoAtsushiSakai:masterfrom
remete618:fix/dijkstra-calc-index-units
Open

Fix unit mismatch in Dijkstra calc_index#1360
remete618 wants to merge 1 commit intoAtsushiSakai:masterfrom
remete618:fix/dijkstra-calc-index-units

Conversation

@remete618
Copy link
Copy Markdown

Summary

What changed

PathPlanning/Dijkstra/dijkstra.py, calc_index method:

# Before (mixes grid indices with meter-unit min values)
return (node.y - self.min_y) * self.x_width + (node.x - self.min_x)

# After (uses grid indices only)
return node.y * self.x_width + node.x

node.x and node.y are already grid indices (computed via calc_xy_index which divides by resolution). Subtracting self.min_x/self.min_y (in meters) is a unit mismatch. The algorithm produced correct results because the offset was constant across all nodes, preserving dictionary key uniqueness, but the formula was conceptually wrong.

Test plan

  • Existing Dijkstra tests pass
  • Path output is identical (the index offset was constant, so behavior is unchanged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the implement Dijkstra maybe have issue

1 participant