Skip to content

fix(backends): PyPlot backend fixes, Connector as a Protocol, one window-title helper - #788

Merged
petercorke merged 8 commits into
mainfrom
fix/pyplot-backend
Oct 15, 2026
Merged

petercorke merged 8 commits into
mainfrom
fix/pyplot-backend

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Fixes in the PyPlot backends (problems 44 to 48 of the typing pass) and a truthful type for what a backend is.

Fixes

  • ShapePlot.plot used an undefined name (ax) and always raised NameError. Its axes now come from axes_logic, so ax= means "draw into this axes" and None reuses the current 3D axes or makes one, as elsewhere in RTB.
  • EllipsePlot with an etype other than 'v' or 'f' failed later with AttributeError; it raises ValueError at construction. The default centre is a tuple, not a shared list.
  • PyPlot.__repr__ read sim_time before launch set it; it is set in __init__.
  • PyPlot2.launch assumed a figure manager with set_window_title, which a headless backend does not have.

Connector is a Protocol. Swift does not depend on RTB and cannot inherit from Connector, yet load_backend returned it as one. The Protocol states what RTB needs of a backend (launch, step, reset, restart, close, add, remove, hold and the supports_teach and supports_ellipse flags). PyPlot, PyPlot2 and ROS inherit it explicitly, which gives them the defaults and keeps a missing method an error at construction. The teach pendant's ellipsoids are set with setattr rather than being part of the interface.

One set_window_title(fig, title) in roboticstoolbox.tools.plot, used by PyPlot, PyPlot2 and Vehicle (which reached into canvas.manager itself). It does nothing for a figure without a window. It uses spatialmath.base.set_window_title once that exists (SMTB PR rai-opensource/spatialmath-python#263), and the local copy goes then.

Not changed

  • Dynamixel and ROS backends.
  • The argument lists of the backends' methods (they differ and Swift's are not RTB's to change).

Test plan

  • Full suite: 1256 passed, 9 skipped, 1 xfailed
  • mypy clean (164 files)
  • New: tests/test_pyplot_backend_fixes.py
  • CI

🤖 Generated with Claude Code

petercorke and others added 4 commits October 15, 2026 17:18
…aunch, PyPlot2 window title

ShapePlot.plot used an undefined name and always raised NameError.
EllipsePlot with an etype other than 'v' or 'f' failed later with an
AttributeError.  PyPlot.__repr__ read sim_time before launch set it.
PyPlot2.launch assumed a figure manager with set_window_title, which a
headless backend does not have.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… ShapePlot and EllipsePlot use axes_logic

Swift does not depend on RTB and so cannot inherit from Connector, though
load_backend returns it as one.  A Protocol states what RTB needs of a
backend, and the PyPlot backends inherit it for the defaults.  The teach
pendant's ellipsoids are set with setattr, they are not part of the interface.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ends and Vehicle

Vehicle reached into canvas.manager itself; MVTB has its own with a bare
except.  The helper does nothing for a figure without a window.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SMTB PR #263.  The copy stays until the minimum Spatial Math version has it.

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 1 critical · 1 high

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

Results:
2 new issues

Category Results
ErrorProne 1 high
Security 1 critical

View in Codacy

🟢 Metrics 23 complexity · 2 duplication

Metric Results
Complexity 23
Duplication 2

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
petercorke merged commit dcb7982 into main Oct 15, 2026
24 of 25 checks passed
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (be029bd) to head (de9d224).

Files with missing lines Patch % Lines
src/roboticstoolbox/backends/PyPlot/EllipsePlot.py 0.00% 13 Missing ⚠️
src/roboticstoolbox/backends/Connector.py 0.00% 4 Missing ⚠️
src/roboticstoolbox/backends/PyPlot/PyPlot.py 0.00% 4 Missing ⚠️
src/roboticstoolbox/backends/PyPlot/PyPlot2.py 0.00% 2 Missing ⚠️
src/roboticstoolbox/mobile/Vehicle.py 0.00% 2 Missing ⚠️
src/roboticstoolbox/robot/BaseRobot.py 0.00% 2 Missing ⚠️
src/roboticstoolbox/tools/plot.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #788   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        144     144           
  Lines      14871   14853   -18     
=====================================
+ Misses     14871   14853   -18     

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

@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