Skip to content

fix(blocks): DiffSteer NameError and VehiclePlot shared defaults, with types and docstrings - #775

Merged
petercorke merged 5 commits into
mainfrom
bug/diffsteer-block-x0
Oct 15, 2026
Merged

petercorke merged 5 commits into
mainfrom
bug/diffsteer-block-x0

Conversation

@petercorke

@petercorke petercorke commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

What

A fix and a review of blocks/mobile.py (the bdsim vehicle blocks).

Bugs fixed

  • DiffSteer() without x0 raised NameError (slef for self), so the block could not be created with its default. Bicycle and Unicycle were fine.
  • VehiclePlot had mutable default arguments (polyargs={}, labels=[...]) and updated polyargs in place, so a size given to one VehiclePlot leaked into every later one.
  • VehiclePlot(scale=<ndarray>) crashed on scale != "auto". Any sequence is accepted now; a [min, max] applies to both axes.
  • x0 was checked with an assert (skipped under -O) and stored as given. It is now converted and checked with base.getvector: a wrong length is a ValueError and the state is always an ndarray.
  • A leftover print("done") in VehiclePlot.start is removed.

Removed

The unused a argument of the DiffSteer block. Nothing in RTB or the RVC3 notebooks and figure scripts passes it.

Types and docstrings

  • ArrayLike3, R3, float, Callable[[Axes], None] and bdsim's SimulationState replace Any.
  • Wrong documented defaults for the DiffSteer block (speed_max, steer_max), "Inital", a misspelt class reference, .. deprecated:: with its version (1.4.0), redundant :type: lines removed, :raises: added.

Testing

Ten new tests in MobileBlockTest, each of which failed before its fix. The vehicle-block calls in the RVC3 figure scripts still work (x0 as list or array, scale=[0, 10], size, shape, init). mypy is clean.

Renamed (old names deprecated, still work)

VehiclePlot: path → path_style, init → init_func, scale → limits (it is the axis limits, and clashed with VehiclePolygon's scale, the vehicle size), polyargs → polygon_style. See petercorke/rvc-ecosystem#15 for the convention.

🤖 Generated with Claude Code

petercorke and others added 3 commits October 15, 2026 07:50
The default branch for x0 used the misspelt name slef, so DiffSteer() without
x0 could not be created.  Bicycle and Unicycle were fine.  A test constructs
each of the three vehicle blocks without x0.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…iclePlot shared defaults

File review of blocks/mobile.py, following the NameError fix:

- x0 is validated and converted with base.getvector, so a wrong length is a
  ValueError (was an assert) and the stored state is an ndarray, not whatever
  was passed
- VehiclePlot: polyargs={} and labels=[...] were mutable defaults and polyargs
  was updated in place, so a size given to one VehiclePlot leaked into every
  later one; now copied.  An ndarray scale crashed; a [min, max] scale is
  applied to both axes for any sequence.  Removed a leftover print('done')
- types: ArrayLike3, R3, float, Callable[[Axes], None], SimulationState instead
  of Any
- docstrings: wrong defaults for DiffSteer speed_max and steer_max, 'Inital',
  Diffsteer class reference, .. deprecated:: with its version (1.4.0),
  redundant :type: lines removed, :raises: added

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
It was never read and nothing in RTB or RVC3 passes it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@codacy-production

codacy-production Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

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

Results:
1 new issue

Category Results
Security 1 high

View in Codacy

🟢 Metrics 82 complexity · 13 duplication

Metric Results
Complexity 82
Duplication 13

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.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/roboticstoolbox/blocks/mobile.py 0.00% 49 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #775   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14663   14671    +8     
=====================================
- Misses     14663   14671    +8     

☔ 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 and others added 2 commits October 15, 2026 08:08
…cated

path -> path_style, init -> init_func, scale -> limits (it is the axis limits,
and clashed with VehiclePolygon's scale, which is the vehicle size),
polyargs -> polygon_style.  The old names still work and warn.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@petercorke
petercorke merged commit f59eee8 into main Oct 15, 2026
22 of 23 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 15, 2026
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