Skip to content

fix(mobile): Bug2 animation, trapped, border handling, and docstrings - #780

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

petercorke merged 4 commits into
mainfrom
bug/mobile-bug2

Conversation

@petercorke

@petercorke petercorke commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

What

Bug2.py (entries 23-25 of the typing-pass problem list, h = None, and what a review of the file turned up).

Bugs fixed (each test failed first)

  • run(animate=True) raised on current Matplotlib: set_data was given the 1-D start point on the first frame.
  • run() without animation drew a marker at the grid origin on the current axes (and could create a figure). The artists are now made only when animating.
  • next() called plt.show(block=True) before raising "robot is trapped", which blocks a script (entry 25).
  • The movie argument implied animate but no movie was written; it now uses MovieWriter.
  • run(**kwargs) swallowed unknown arguments. fig5_5.py passes label='path'; label is now a real argument that names the trail in the legend (default "robot path"), and anything else is a TypeError.
  • start == goal gave a division by zero in hom_line and a RuntimeWarning.
  • plot_m_line ignored its style for a vertical m-line. It now forwards *args, **kwargs to plot, so plot_m_line("r-") and plot_m_line(color="g") both work.
  • edgelist / adjacent_point wrapped around at the left and top borders and raised at the right and bottom. The area outside the image is now outside the blob. The paths for the house floorplan (both directions) and map1 are identical before and after.
  • Bare except: clauses (entry 24), the unused h, d, l, y, and dir shadowing the builtin are removed.

Docstrings and types

Path is ndarray(N,2) (it said (2,N)), m_line is R3, the direction names were wrong (NW twice), a mangled author list, :type current: for trail, and hom_line was undocumented.

Behaviour change: a diagonal crossing of the m-line is now seen

Bug2 reported "robot is trapped" when the m-line passed exactly through block corners at 45 degrees. The crossing test was abs(inner) <= 0.5 cells, but a line at 45 degrees to the grid passes between two diagonal neighbours at 0.707 from each, so the robot could step over it without ever being within half a cell. The tolerance is now sqrt(2)/2 (plus 1e-9 for rounding, since a diagonal neighbour is exactly that far away).

Effect on existing paths, measured: of the book cases (house floorplan both ways, map1) and three block cases, only one path changes: the house floorplan, bedroom to kitchen (Fig 5.5), from 1307 points to 1306. kitchen -> br3 (3985), map1 (334) and the straight and shallow block paths are identical.

The published number 1307 therefore needs an erratum. The change is documented in the run docstring (.. versionchanged:: 1.4.5) and a test pins the new length.

Notes for the book scripts (petercorke/RVC3-python#55)

  • fig5_5.py passes label='path', which now takes effect (legend text "path" instead of "robot path").
  • The Fig 5.5 path is 1306 points rather than 1307 (see above); the route is otherwise the same.

Full suite 1065 passed (with both compiled extensions), mypy clean.

🤖 Generated with Claude Code

Defects (each with a test that failed first):
- run(animate=True) raised on current Matplotlib: set_data was given the 1-D
  start point on the first frame
- run() without animation drew a marker at the origin on the current axes
  (and could create a figure); the trail artists are now made only if animating
- the movie argument implied animate but no movie was written; it now uses
  MovieWriter
- run(**kwargs) swallowed unknown arguments (fig5_5.py passes label='path',
  which is now a real argument naming the trail in the legend)
- next() called plt.show(block=True) before raising 'robot is trapped'
- start == goal gave a division by zero (hom_line) and a RuntimeWarning
- plot_m_line ignored its style for a vertical m-line; it now forwards
  *args, **kwargs to plot like the other single-line plots
- edgelist/adjacent_point wrapped around at the left and top borders and
  raised at the right and bottom; the area outside the image is now outside
  the blob, which leaves every book path unchanged
- bare except clauses removed; unused h, d, l, y; dir shadowed the builtin

Docstrings and types: ndarray(N,2) path, R3 m-line, ArrayLike2, corrected
direction names, the authors' names, hom_line documented.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 high

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

Results:
2 new issues

Category Results
ErrorProne 1 high
Security 1 high

View in Codacy

🟢 Metrics 42 complexity · 0 duplication

Metric Results
Complexity 42
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.

The robot has crossed the m-line when it is within half a cell of it, but a
line at 45 degrees to the grid passes between two diagonal neighbours at
sqrt(2)/2 from each, so it could be stepped over and the robot was reported as
trapped.  The tolerance is sqrt(2)/2 (plus rounding).  The only published path
that changes is the house floorplan bedroom to kitchen example, 1306 points
instead of 1307 (versionchanged 1.4.5 in the docstring, a test pins it).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/roboticstoolbox/mobile/Bug2.py 0.00% 50 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #780   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        144     144           
  Lines      14729   14733    +4     
=====================================
- Misses     14729   14733    +4     

☔ 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.

@petercorke
petercorke merged commit 44ce707 into main Oct 15, 2026
22 of 23 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
petercorke added a commit that referenced this pull request Oct 15, 2026
…Bug2 and PRM fixes (#782)

* test(mobile): planner base contract tests (WIP, failing until the implementation commit)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* refactor(mobile): PlannerBase declares no verbs; validate_start_goal; stepping loop moves to DistanceTransformPlanner

PlannerBase is no longer an ABC and has no plan/next/query. Planners
define the verbs that make sense for them. validate_start_goal replaces
the base query's validation. Bug2 no longer inherits plan/query that raise.
DistanceTransformPlanner.query owns the stepping loop; next=/movie= are
deprecated no-ops.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* refactor(mobile): RRT and Dstar validate start through validate_start_goal; QuinticPoly and CurvaturePoly already do

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* feat(mobile): NoPathError for a valid problem with no solution

Raised by DistanceTransform, PRM, Lattice, QuinticPoly and Bug2 (trapped).
It is a RuntimeError subclass, so existing handlers continue to work.
Query before plan is a single RuntimeError text across planners.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* feat(mobile): animation helper on PlannerBase; animate and movie at the constructor

animation_start/frame/end own pacing and the movie file, the planner
draws.  DistanceTransform, Bug2, RRT and Dstar use it, with a per-call
override.  DistanceTransform.query movie is now implemented.  Dstar.plan
animate/progress are deprecated no-ops, and Dstar.query no longer prints.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(mobile): shaped argument types and trimmed redundant :type: lines in RRT, Lattice, Dstar, Dubins, ReedsShepp

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(mobile): planner families, failure and animation in the planning docs and PlannerBase

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* feat(mobile): PRMPlanner collision_step, the spacing in cells of the edge collision test

Default None keeps the existing approximate test.  OccGrid gains cellsize.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs(mobile): PRMPlanner collision_step, smaller values give no gain

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(mobile): Bug2 raises NoPathError instead of looping when the goal is enclosed

Meeting the same hit point twice means no progress.  The house path is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(mobile): Bug2 leaves an obstacle only where the next m-line step is free

Removes the repeated cells from a leave that is blocked at once, and ends
the run for a goal enclosed by an obstacle.  House bedroom to kitchen is
1304 points (1307 published, 1306 with the tolerance change in #780).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* fix(mobile): Bug2 does not repeat the cell where an obstacle is first hit

House bedroom to kitchen is 1302 points (1307 published).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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