Skip to content

fix(pyplot): restore planar simulation stepping - #978

Closed
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/planar-simulation-stepping
Closed

Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/planar-simulation-stepping

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

PyPlot2.step() raises AttributeError for a normal, writable Robot2 because it reads the old control_type attribute instead of control_mode.

Correcting that name alone still leaves velocity integration 1000 times too small: the public step takes seconds, but the planar integrator divides dt by 1000. A 0.4 rad/s joint starting at 0.2 rad reaches 0.200004 after a 0.01 s step instead of 0.204.

Change

Use the robot's public control mode and integrate qd * dt, matching the documented seconds and the existing 3D backend. Clarify the supported stepping behavior.

Behavior change: ordinary planar simulations now step successfully and advance at the requested joint velocity. Position/acceleration modes retain their existing non-integrating behavior, and read-only or pinned drawings keep their existing semantics.

Validation

  • Twelve tests exercise the public step method with real Agg figures and inspect the actual line endpoints using independent two-link sine/cosine kinematics.
  • Coverage includes multiple time steps, changing/signed/zero velocities, p/v/a modes, read-only plots, a pinned and a live drawing sharing one robot, and independently controlled robots.
  • Unchanged main: 9 failed, 3 passed.
  • Control-name correction alone: 7 failed, 5 passed, demonstrating that the tests also detect the time-unit bug.
  • Complete fix plus three existing plotting/backend modules: 76 passed, 1 skipped, 6 subtests passed.
  • mypy: all 166 source files passed. New tests pass Ruff lint/format; git diff --check passes.
  • The full repository/platform matrix was not run locally.

Prior work

Checked all 103 fork heads and the actual patches of 14 related upstream PRs. Older fork comparisons contain no PyPlot2 implementation changes. #875 adds non-positive-dt guards, #873 adds independently posed drawings, and #788 repairs backend setup; none corrects this stepping path. The broader style issue #646 is independent.

Primary contributor: Afloat16.

Prepared with ChatGPT (GPT-6 Astra Pro) assistance.

Use the public control_mode property and integrate velocity over seconds
in PyPlot2, matching the step contract and the three-dimensional backend.

Co-Authored-By: ChatGPT (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 12 complexity · 1 duplication

Metric Results
Complexity 12
Duplication 1

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.

@Afloat16 Afloat16 closed this Nov 19, 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