Skip to content

fix(mobile): rebuild D* plans and report traversed costs - #996

Closed
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/dstar-plan-state
Closed

Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/dstar-plan-state

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Summary

D* can keep an old goal's zero-cost root when plan() is called again, ignore edits to the costmap, and return a path through infinite-cost obstacles. When a sensor forces a detour, the returned status still reports the original route's cost: a three-unit straight route that becomes a 1 + 2*sqrt(2) detour is reported as cost 3.

Keep the related planning corrections in one change:

  • Build a fresh search tree from the current goal and costmap for each explicit plan() call. Incremental sensor updates continue to use that tree.
  • Restore the heap invariant after removing an open state whose priority decreases, so expansion order remains valid.
  • Accumulate the costs of the steps actually followed after sensor updates.
  • Raise NoPathError for unreachable goals and finish the animation when a query fails.

Public numerical behaviour changes: repeated planning now follows the new goal and costs; sensor detours have their actual traversal cost; unreachable routes raise NoPathError. The expansion count restarts with an explicit new plan. The docstrings record these changes.

Validation

Tested on Linux, Python 3.12.14, NumPy 2.5.5 and SciPy 1.18.1, with native toolbox extensions built using GCC/G++.

  • The 12 regression/control cases produce 8 failures and 4 passes against unchanged main c6a7c747f7e9a5bda3b44f2717908c9ece5f20d9.
  • New tests plus the existing map-coordinate, planner-animation, mobile-planner and cleanup suites: 156 passed, 10 subtests passed. Tests exercise actual routes and sensors, translated/scaled grids, unreachable maps, a repeated goal, and independently computed SciPy shortest paths on weighted grids.
  • mypy succeeds on all 166 source files.
  • The full local repository command reached 92% before tests/test_symbolic_ik.py::test_dh_models exceeded its 50-second limit. The full-suite run therefore remains incomplete; that timeout is in unchanged symbolic inverse-kinematics code. The platform CI matrix and documentation build were not run locally.
  • The new test file passes Ruff. The production file has the same three existing Ruff findings on main and this branch (N999, RUF012, PIE808). Formatting and git diff --check pass.

Prior work

Checked all 504 historical pull requests and the current open issues and PRs. The earlier grid-coordinate work in #791 covers world-coordinate conversion; these search-state, frontier-order, reachability and returned-cost defects are separate. No competing PR was found for this fix.

Checklist

  • Conventional Commits title and focused related changes.
  • Regression tests added and focused tests pass locally.
  • Modern type hints and reST behaviour notes.
  • Numerical and public behaviour changes stated above.
  • Diff reviewed; required checks and advisory Codacy distinction understood.

Primary contributor: Afloat16.

Prepared with OpenAI Codex (GPT-6 Astra Pro) assistance.

Reset the search tree for each explicit plan, repair the frontier after a
priority decrease, and report the cost of the route actually followed.
Raise NoPathError for unreachable goals and finish animations on failure.

Co-Authored-By: OpenAI Codex (GPT-6 Astra Pro) <noreply@openai.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 26 complexity · 0 duplication

Metric Results
Complexity 26
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke

Copy link
Copy Markdown
Owner

Thank you for this, @Afloat16. As with your earlier PRs, we can't update your branch from main because "Allow edits from maintainers" is off, so I rebased your commit onto main in our own repository as PR #1000, keeping you as the author, with one commit of ours that changes the versionchanged notes to 1.5.1. I checked that the new tests fail on main (8 of 12) and pass with your change, and that paths, costs and expansion counts with no sensor are identical to main on 40 random grids. So I am closing this PR in favour of PR #1000. Thank you again.

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.

2 participants