Skip to content

RobotState::getJacobian returns nonzero columns for joints past the branch point of a side-branch link #4039

Backlog

Description

@mindThomas

Description

RobotState::getJacobian() returns a wrong Jacobian for a link that sits on a side branch of a chain group, i.e. a link that is attached (for example by a fixed joint) to an intermediate link of the chain rather than to its tip.

Since #2389 the function iterates forward over all active joints of the group and only stops at the joint whose parent link is the requested link:

for (const JointModel* joint_model : joint_models)
{
  // Stop looping if we reached the child joint of the reference link.
  if (joint_model->getParentLinkModel() == link)
  {
    break;
  }
  ...

A side-branch link is never the parent of a group joint, so the loop does not stop at the branch point and also fills the columns of the joints further down the chain, although they do not move the link. The link passes the input check because getUpdatedLinkModelsSet() contains it, so the call returns true with a silently wrong result.

Before #2389 (e.g. on Humble) the Jacobian was built by walking up from the link through getParentJointModel(), which only visits the link's ancestors and gives the correct result for such links.

This affects any caller that asks for the Jacobian of a link other than the chain tip, for example to compute the velocity of a point on a sensor mounted on an intermediate link, or of a collision witness point on such a link.

ROS Distro

Jazzy

OS and version

Ubuntu 24.04

Source or binary build?

Binary

If binary, which release version?

2.12.4 (the same loop is on main)

If source, which branch?

No response

Which RMW are you using?

CycloneDDS

Steps to Reproduce

Add this test to moveit_core/robot_state/test/robot_state_test.cpp. A revolute joint carries a link mount, a prismatic joint moves tool along z relative to mount, and side_link is fixed to mount:

TEST(getJacobian, SideBranchLinkIgnoresJointsPastTheBranchPoint)
{
  moveit::core::RobotModelBuilder builder("side_branch", "base_link");
  builder.addChain("base_link->mount", "continuous");
  builder.addChain("mount->tool", "prismatic", {}, urdf::Vector3(0.0, 0.0, 1.0));
  builder.addChain("mount->side_link", "fixed");
  builder.addGroupChain("base_link", "tool", "arm");
  ASSERT_TRUE(builder.isValid());
  const moveit::core::RobotModelPtr model = builder.build();
  const moveit::core::JointModelGroup* group = model->getJointModelGroup("arm");
  const moveit::core::LinkModel* side_link = model->getLinkModel("side_link");
  ASSERT_TRUE(group->getUpdatedLinkModelsSet().count(side_link));

  moveit::core::RobotState state(model);
  state.setToDefaultValues();
  state.updateLinkTransforms();

  Eigen::MatrixXd jacobian;
  ASSERT_TRUE(state.getJacobian(group, side_link, Eigen::Vector3d::Zero(), jacobian));
  // Column 1 belongs to the prismatic joint mount->tool, which does not move side_link.
  EXPECT_TRUE(jacobian.col(1).isZero()) << jacobian;
}

Expected behavior

The column of mount->tool is zero, since moving the prismatic joint does not move side_link. This is what the pre-#2389 implementation returns.

Actual behavior

The column of mount->tool is [0, 0, 1, 0, 0, 0], so side_link appears to move along z with the prismatic joint.

Backtrace or Console output

No response

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions