Skip to content

fix(dynamics): support arbitrary joint counts in paycap - #731

Merged
petercorke merged 4 commits into
petercorke:mainfrom
huxiaoyi-ovo:fix/paycap-arbitrary-joint-counts
Oct 14, 2026
Merged

petercorke merged 4 commits into
petercorke:mainfrom
huxiaoyi-ovo:fix/paycap-arbitrary-joint-counts

Conversation

@huxiaoyi-ovo

@huxiaoyi-ovo huxiaoyi-ovo commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #728.

The paycap() method previously allocated a fixed six-column capacity array, causing broadcasting errors for robots with other joint counts.

This PR:

  • Supports arbitrary joint counts by returning per-joint capacities with shape (n,), or (m, n) for trajectories.
  • Corrects trajectory length handling and normalizes each wrench independently.
  • Rejects zero wrench directions.
  • Handles joints with zero wrench sensitivity without division by zero.
  • Updates the documentation to describe the actual return values and limiting joint.

The public method signature remains unchanged.

Tests

Added 8 parameterized regression cases covering:

  • 3-, 6-, and 7-DOF robots.
  • Positive and negative wrench directions.
  • Multi-configuration trajectories.
  • Invalid input shapes and zero wrench directions.
  • Joints with zero wrench sensitivity.

Validation

Validated commit 90bc11e infork PR #1(huxiaoyi-ovo#1).

GitHub Actions completed successfully:

  • Python 3.10–3.14 on Ubuntu, Windows, and macOS.
  • Complete core test suite.
  • Coverage and documentation builds.
  • Aggregate test checks.

Result: 19 successful jobs, 1 conditional skip, 0 failures.

The patch changes only Dynamics.py and its regression test file.

@codacy-production

codacy-production Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 11 complexity · 0 duplication

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

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
src/roboticstoolbox/robot/Dynamics.py 0.00% 16 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #731   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14375   14367    -8     
=====================================
+ Misses     14375   14367    -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
petercorke merged commit 6a45f73 into petercorke:main Oct 14, 2026
22 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 14, 2026
@petercorke

Copy link
Copy Markdown
Owner

Thank you for your interest in RTB, and for fixing #728. This is merged. While reading the history I found that the original MATLAB paycap (by Bryan Moutrie) returns the minimum over joints as a scalar capacity, and the Python port dropped that min, which is where the shape problem came from. I'll follow up with that change and a hand-checkable test, and I'll credit this PR in the commit. Thanks again.

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.

paycap crashes for robots with n != 6 and its docstring does not match its behaviour

2 participants