Repository navigation
Take one position per continuous joint in the Pinocchio plugin (backport #350) - #364
Merged
Merged
Conversation
(cherry picked from commit eb2f8e3) # Conflicts: # kinematics_interface/test/kinematics_interface_common_tests.hpp
Author
|
Cherry-pick of eb2f8e3 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## jazzy #364 +/- ##
==========================================
+ Coverage 86.91% 87.81% +0.89%
==========================================
Files 7 7
Lines 581 640 +59
Branches 78 83 +5
==========================================
+ Hits 505 562 +57
Misses 40 40
- Partials 36 38 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Pinocchio stores a URDF
continuousjoint as (cos, sin), so the model has nq = 2 but nv = 1 for it. The Pinocchio plugin usednqas the joint count and copied the joint vector straight into the configuration (q_ = joint_pos). For a chain with a continuous joint this means:calculate_jacobianon the 2-joint chainlink1->link3logsInvalid joint vector size (2). Expected size is 3.and returns false.calculate_link_transformthen reads its values as (cos, sin), not as an angle. The Jacobian calls (calculate_jacobian,calculate_jacobian_inverseand bothconvert_*) throw an uncaughtstd::invalid_argumentfromcomputeFrameJacobian, because the Jacobian has nq columns and Pinocchio wants nv.The joints outside the chain are locked with
q_fixed = Zero(nq). Zeros are not a rotation for a continuous joint. For example, with joint1 continuous and the chainlink2->link3, the transform of link3 comes back as[1 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 1], with the singular rotationdiag(1, 0, 0). With the chainlink1->link3(used in the new test) the Jacobian is wrong as well.Both lines date from the plugin's first version (#199).
The fix:
num_joints_ismodel_.nv, so the joint vectors, the Jacobian and its inverse have one entry per joint, as in KDL.set_configuration()buildsq_from the joint positions: (cos, sin) for a continuous joint, the position as is for revolute and prismatic joints. It replacesq_ = joint_posin the four methods that set it.pinocchio::neutral(full_model).initialize()returns false for a chain joint with nq != nv that is not continuous (planar, floating), since such a joint has no single position. This is a change for these chains: on master they initialize andcalculate_link_transformworks with a vector of size nq, but every Jacobian call throwsstd::invalid_argumentfromcomputeFrameJacobian(the Jacobian had nq columns, Pinocchio wants nv). Joints like these outside the chain are not affected.Revolute-only chains are unchanged: there nq = nv and the configuration equals the joint vector.
Is this user-facing behavior change?
Yes. Robots with continuous joints now work with the Pinocchio plugin and take the same joint vectors as with KDL.
Did you use Generative AI?
Yes, Claude Code (Claude Opus 5.5) found the bug and wrote the fix, the tests and this description.
Additional Information
plugin_continuous_joint(joint2 continuous, chainlink1->link3, expects the same Jacobian and transform asplugin_jacobian_and_transform_in_root_frame, plus a joint/Cartesian delta round trip) andplugin_continuous_joint_outside_chain(joint1 continuous, chainlink1->link3, compares the Jacobian and transform with the revolute URDF). On master KDL passes both and Pinocchio fails both. With the fix both plugins pass all 14 tests (ros:rolling-ros-base, Pinocchio 4.1.0).q_fixedmakesplugin_continuous_joint_outside_chainfail again.link1andlink2tolink3, at 500 random configurations each (angles up to +-6 rad). The Jacobian, the transform, the Jacobian inverse and the joint-to-Cartesian deltas agree to 2.5e-13.colcon testpasses for all three packages. The clang-format,ament_cpplintandament_cppcheckhooks pass on the changed files (run one by one, clang-format 23.1.3 as pinned).TODOs
To send us a pull request, please:
colcon testandpre-commit run(requires you to install pre-commit bypip3 install pre-commit)This is an automatic backport of pull request #350 done by [Mergify](https://mergify.com).