fix(compute_ik): seed IK solver with current robot state#2
Open
michaljohnson wants to merge 2 commits into
Open
fix(compute_ik): seed IK solver with current robot state#2michaljohnson wants to merge 2 commits into
michaljohnson wants to merge 2 commits into
Conversation
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.
Summary
Seed the IK solver with the robot's current joint configuration instead of a fresh zero state, so the solver converges to the IK branch nearest the actual robot pose rather than a ±2π wrap-around equivalent.
Problem
compute_ikpreviously constructed a freshRobotState(robot_model)whose joints default to the URDF zero values. KDL / numerical IK solvers converge to whichever solution branch is closest to the seed configuration. For a 6-DOF revolute arm, every Cartesian target has multiple IK solutions plus their ±2π wrap-around equivalents on the wrist and shoulder joints.From a zero seed, the solver had no preference for the natural branch and would frequently land on wrap-around solutions (for example,
shoulder_lift = -4.44 radinstead of the near-current-1.5 rad). Downstream callers usingcompute_ik+plan_to_joint_statethen had to traverse a ~2π joint sweep from the actual current state to the wrap-around target, which usually passes through self-collision configurations and surfaces as a generic "Planning failed".Fix
Read the group's current joint positions from
planning_scene_monitor.read_only()and use them to seed theRobotStatepassed toset_from_ik. Only the group's joints matter for IK seeding because the arm's kinematic chain is the only thing the IK solver evaluates. The monitor is used in read-only context so its view is not mutated.Notes
attemptsis kept on the signature for API stability even though it is not currently threaded intoset_from_ik. Happy to drop it if you'd prefer a cleaner signature.