Skip to content

coriolis() and Robot.copy().rne() fail for URDF/ETS robots: copied links keep their original parent #730

Open

Description

@petercorke

robot.coriolis(q, qd) raises ValueError: Link(...) is not in list for every URDF-based Robot I tried: UR5, KinovaGen3, LBR, and a two-link URDF with full inertials. DH robots are unaffected.

coriolis calls nofriction(), which calls copy(). The same error occurs for robot.copy().rne(q, qd, qdd) directly, while rne on the original robot works. Cause: after copy() each link's parent (and the joint's parent) still refers to the original robot's link object, so self.links.index(joint.parent) in Robot.rne (group_of_link_idx.get(...)) fails.

Repro (any URDF with dynamics):

import numpy as np
from roboticstoolbox.models.URDF.URDFRobot import URDFRobot

r = URDFRobot("/path/to/two_links_robot.urdf")   # two revolute joints, with <inertial> elements
q, qd = np.array([0.3, -0.5]), np.array([0.1, 0.2])
r.rne(q, qd, np.zeros(2))           # OK
r.copy().rne(q, qd, np.zeros(2))    # ValueError: Link(...) is not in list
r.coriolis(q, qd)                   # ValueError: Link(...) is not in list

Notes

Fix: have Robot.__deepcopy__ remap each link's parent (and children) onto the copied links, and add a regression test that copy() then rne equals the original.

Found while answering Adineh94's question in discussion #158.

Activity

  1. huxiaoyi-ovo commented on Oct 10, 2026

    @huxiaoyi-ovo
    Contributor

    I'd like to take this issue. I've prepared and validated a fix in my fork and will open a PR shortly.

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