Skip to content

KDL IK plugin cleanup - #725

Closed
rhaschke wants to merge 7 commits into
kinetic-develfrom
wip-kdl-cleanup
Closed

rhaschke wants to merge 7 commits into
kinetic-develfrom
wip-kdl-cleanup

Conversation

@rhaschke

@rhaschke rhaschke commented Dec 15, 2017 •

Copy link
Copy Markdown
Contributor

This is an attempt to cleanup and improve the KDL IK plugin.

The first 4 commits simply cleanup code (hopefully) without changing semantics.
326a76f improves IK when passing through singularities. In that case, the step size of the velocity IK solver needs to be decreased to match the highly nonlinear shape of the FK manifold.

The Kinematics plugin has a major design flaw, which I want to discuss here as well:
Currently it's only possible to specify a timeout for the solver. There is no way to specify the number of search attempts (randomly sampling e.g. a new seeds).
However, RobotState::setFromIK provides an attempts argument. But, even if you specify 1 there, the underlying Kinematics plugin will randomly sample seeds until the timeout is reached, which is really annoying if one just wants to test IK for the current seed.

This highlights another design flaw: Both RobotState::setFromIK and the Kinematics plugin perform random seed sampling. I think, this should be done only once! I discussed this issue shortly with @v4hn already and we agreed that the random sampling should be removed from RobotState, but only be done in the IK plugins (TracIK relies on sampling inside the plugin). In that case, the KinematicsBase class should provide a utility function to sample new seeds to avoid reimplementing this functionality in all plugin instances.

However, we need a mechanism to pass a max attempts argument. I'm afraid that all clean solutions will change API. I see the following options:

  • Add an appropriate argument to the function signatures
  • Add an appropriate parameter to KinematicsQueryOptions
  • Some crude hack, passing a special timeout (e.g. negative) to indicate the intend

What do you think?

@rhaschke
rhaschke force-pushed the wip-kdl-cleanup branch 2 times, most recently from 41ff137 to 5f16b39 Compare February 15, 2018 22:41
calling getParentLinkModel() shouldn't be so expensive as to judge another code block
- remove unused variables
- fixed type of max_solver_iterations_
- directly read parameters into class members
This function is doing exactly the same as CartToJnt().
The extra argument lock_redundant_joints is not used at all.
@davetcoleman

Copy link
Copy Markdown
Member

This is great!

match the highly nonlinear shape of the FK manifold.

What is a forward kinematics manifold?

the underlying Kinematics plugin will randomly sample seeds until the timeout is reached,

KDL does not randomly sample seeds AFAIK, only MoveIt!'s wrapper as you pointed out. I'm confused by your statement here

Both RobotState::setFromIK and the Kinematics plugin to random seed sampling. I think, this should be done only once!

Which kin plugin are you talking about?

we agreed that the random sampling should be removed from RobotState

Agreed

Add an appropriate argument to the function signatures

I like this option the best... the intent of that struct is to allow new options to be added.

I also think Melodic would be a perfect time to do a major cleanup of KinematicsBase and just outline the changes in the migration plan. Want to writeup a draft for the new interface?

robot_model::RobotModelPtr robot_model_;

robot_state::RobotStatePtr state_, state_2_;
robot_state::RobotStatePtr state_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

{
const std::vector<const LinkModel*>& links = start->getDescendantLinkModels();
if (!links.empty())
for (const LinkModel* link : links)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some comments to this function?

if (delta_twist_err >= last_delta_twist_err) {
// if the error increased, we are close to a singularity -> reduce step size
double old_step_size = step_size;
step_size *= 0.5; // reduce scale;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to me there should be a min step_size that should be checked s.t. the value can't get too close to zero. does that make sense here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a check a few lines down: if (step_size < eps).

@davetcoleman

Copy link
Copy Markdown
Member

Have you checked this PR against the tests in moveit_kinematic_tests?

@rhaschke

rhaschke commented Apr 3, 2018

Copy link
Copy Markdown
Contributor Author

What is a forward kinematics manifold?

Just the manifold of Cartesian poses spanned by the joint space. Close to a singularity, this manifold has a strong curvature and Jacobian-based IK approaches tend to overshoot.

KDL does not randomly sample seeds AFAIK.

It does, namely via KDLKinematicsPlugin::getRandomConfiguration used here.

Have you checked this PR against the tests in moveit_kinematic_tests?

Now, I did. All tests pass, except one. I need to look into this.

@davetcoleman davetcoleman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address broken kinematics test and retarget melodic-devel branch

@rhaschke rhaschke mentioned this pull request Nov 20, 2018
@rhaschke

Copy link
Copy Markdown
Contributor Author

@davetcoleman I already have prepared locally a branch targeted to Melodic for this.
Unfortunately, I didn't find time yet to look into the test regressions. But I suggest to continue this work for Melodic. What are your (short-term) plans for this as you merged kinetic-devel?

@davetcoleman

Copy link
Copy Markdown
Member

I did not merge this! Re-targeting this for melodic is a good idea, I hadn't realized this was still targeted at kinetic

@rhaschke

Copy link
Copy Markdown
Contributor Author

You merged kinetic-devel into this PR branch. I will close this for now and re-open for Melodic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants