Skip to content

fix(mobile): DistanceTransform, PRM, QuinticPoly and CurvaturePoly planners - #781

Merged
petercorke merged 4 commits into
mainfrom
bug/mobile-planners-a
Oct 15, 2026
Merged

petercorke merged 4 commits into
mainfrom
bug/mobile-planners-a

Conversation

@petercorke

@petercorke petercorke commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

What

Entries 26-30 of the typing-pass problem list, and what a full review of the four planner files turned up. Stacked on #778 (the PRMPlanner.plot override has to match the new PlannerBase.plot); until #778 merges this PR also shows its commits.

Bugs fixed (each test failed first)

DistanceTransformPlanner

  • next() wrapped around at the left and top borders: for a goal on the opposite edge it stepped off the map, and query() never terminated.
  • An unknown metric raised UnboundLocalError; it is a ValueError (also from the constructor).
  • plot_3d always called a blocking plt.show(). It has block (default True, as before) and path_style (ls is deprecated).
  • The class docstring example passed distance="manhattan"; the argument is metric. It only ran because unknown arguments were swallowed (fixed on fix(mobile): PlannerBase argument checks, plot without side effects, and <thing>_style arguments #778 itself).

PRMPlanner

  • plot printed "plotted background" and "plotted roadmap" (entry 27) and returned None; it now returns the axes. vertex=/edge= become vertex_style=/edge_style=, defaults VERTEX_STYLE/EDGE_STYLE, old names deprecated (the book's fig5_19.py and fig5_20.py use them).
  • plan(animate=...) was accepted and did nothing (deprecated).
  • query required start and goal, and inserted the arguments as given rather than the validated start and goal; both are now optional and default to the constructor's.
  • Unused attributes removed; the class docstring described a distance transform planner.

QuinticPolyPlanner

  • goal_vel and goal_acc were ignored: the start values were passed as the goal (entry 28). The book does not use this planner.
  • When no path time met the acceleration and jerk limits it silently returned the last candidate, which violates them; it is now a RuntimeError.
  • It printed "find path!!", and start/goal were kept as given (a tuple), not as arrays (entry 29).

CurvaturePolyPlanner

  • It printed the optimizer result on every query, its example imported DubinsPlanner and then used CurvaturePolyPlanner (a NameError in the docs build), and solvepath had a mutable default argument.

Test changes

tests/test_prm_constructor.py asserted the private call _create_roadmap(npoints, thresh, None), including the dead animate argument; it now asserts (npoints, thresh).

Each roadmap connection is one edge, not two

_create_roadmap visited every ordered pair of vertices, so each connection was added from both of its ends. pgraph's UGraph is a multigraph and does not de-duplicate, so the roadmap held two parallel edges per connection:

  • the edge count was doubled (the book's 10,000 edges is 5,000 connections);
  • current pgraph draws parallel edges as two arcs (curvature +/-0.175), where older pgraph overlaid them, so a regenerated roadmap looked like lenses rather than straight lines.

Each unordered pair is now considered once. Measured on the house floorplan, seed=0:

before after
50 points 222 edges, 12 components 111 edges, 12 components
300 points 10,000 edges, 13 components 5,000 edges, 13 components
query br3 -> kitchen, br2 -> kitchen identical path arrays
drawn with current pgraph arcs straight lines, as in the book

The two printed edge counts in the book's notebook change (erratum, petercorke/RVC3-python#55).

Not changed, noted

  • PRMPlanner._test_path samples round(length) points along an edge, so an edge shorter than half a cell is not tested at all. A denser test is not "more correct": three plausible tests (the current one, both ends plus a point per cell, and the grid cells along the segment) disagree on at most 16 of 13,640 candidate connections, and none is exact. Left as it is.
  • CurvaturePolyPlanner does not check whether the optimizer succeeded. On the book's cases it does (end error 1e-4 to 4e-3). A warning is proposed separately.

Full suite 1106 passed (both compiled extensions, pinned SMTB), mypy clean.

🤖 Generated with Claude Code

@codacy-production

codacy-production Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 high

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
ErrorProne 2 high
Security 1 high

View in Codacy

🟢 Metrics 58 complexity · 0 duplication

Metric Results
Complexity 58
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 and others added 2 commits October 15, 2026 12:33
…anners

Defects (each with a test that failed first):
- DistanceTransformPlanner.next wrapped around at the left and top borders, so
  a path from the left edge to a goal on the right edge never ended (query
  looped forever); an unknown metric raised UnboundLocalError; plot_3d always
  called a blocking plt.show() and its ls argument is renamed path_style
- PRMPlanner.plot printed debug text; vertex/edge become vertex_style/
  edge_style (the old names deprecated); plan(animate=) was accepted and did
  nothing (deprecated); query required start and goal and inserted the raw
  arguments rather than the validated ones
- QuinticPolyPlanner ignored goal_vel and goal_acc (the start values were used
  for the goal), returned an infeasible path silently when no time met the
  limits (now RuntimeError), printed 'find path!!', and kept start and goal as
  given rather than as arrays
- CurvaturePolyPlanner printed the optimizer result, its docstring example
  imported the wrong class and had a mutable default argument

Docstrings and types: ArrayLike2/ArrayLike3, the class docstring of PRMPlanner
described a distance transform planner, typos, stale __main__ demos removed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
_create_roadmap visited every ordered pair of vertices, so each connection was
added from both of its ends.  pgraph's UGraph does not de-duplicate (it is a
multigraph), so the roadmap had two parallel edges per connection: the edge
count shown was doubled (the book's 10,000 is 5,000 connections), and current
pgraph draws parallel edges as two arcs instead of one straight line.

Each unordered pair is now considered once, from the earlier vertex.  For the
house floorplan, seed 0: 50 points 222 -> 111 edges, 300 points 10,000 ->
5,000 edges; the number of components and both query paths are identical.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke force-pushed the bug/mobile-planners-a branch from 8d7e64c to cd9443f Compare October 15, 2026 02:34
@petercorke
petercorke changed the base branch from bug/mobile-planner-base to main October 15, 2026 02:34
@petercorke
petercorke merged commit 53becb4 into main Oct 15, 2026
22 of 23 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (44ce707) to head (9a97583).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/roboticstoolbox/mobile/PRMPlanner.py 0.00% 37 Missing ⚠️
...roboticstoolbox/mobile/DistanceTransformPlanner.py 0.00% 25 Missing ⚠️
src/roboticstoolbox/mobile/QuinticPolyPlanner.py 0.00% 9 Missing ⚠️
src/roboticstoolbox/mobile/CurvaturePolyPlanner.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #781   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        144     144           
  Lines      14733   14746   +13     
=====================================
- Misses     14733   14746   +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant