Skip to content

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

Closed

Description

@petercorke

Dynamics.paycap allocates wmax = np.zeros((trajn, 6)) but assigns an n-element per-joint vector, so any robot with n != 6 raises:

ValueError: could not broadcast input array from shape (7,) into shape (6,)

Repro: rtb.models.DH.Panda().paycap([0, 0, -1, 0, 0, 0], tauR, q=q) with tauR an (n, 2) array of joint torque limits.

For n = 6 it works but returns per-joint scale factors, not the 6-vector wrench the docstring describes. The maximum load along w is wmax.min() and joint is the limiting joint. On a DH Puma 560 at qr, with w = [0, 0, -1, 0, 0, 0], this gave 4392 N limited by joint 2, and recomputing the joint torques at that load put joint 2 exactly at its limit.

Other problems:

  • The docstring signature paycap(q, w, f, tauR) does not match the code paycap(w, tauR, frame=1, q=None), and the frame description ('base'/'ee') does not match the int argument.
  • w is normalised, so it is only a direction, which the docs do not say.
  • It uses gravload, so it gives nonsense on models with zero dynamics such as the default URDF-based Panda. This should be documented or detected.
  • tests/test_DHRobot.py::test_paycap is commented out.

Raised from discussion #430.

Activity

  1. huxiaoyi-ovo commented on Oct 10, 2026

    @huxiaoyi-ovo
    Contributor

    Hi! I'd like to work on this issue.

    I've prepared a focused fix for paycap() to support arbitrary joint counts, correct the trajectory handling, and clarify the return values. I've also added regression tests covering 3-, 6-, and 7-DOF robots.

    I'm validating the changes in my fork before opening an upstream PR. Thanks!

  2. added a commit that references this issue on Oct 14, 2026
    6a45f73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwe got it wrong, will fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions