PickNikRobotics / pick_ik

Inverse Kinematics solver for MoveIt
BSD 3-Clause "New" or "Revised" License
68 stars 17 forks source link

Additional information on pick_ik #17

Closed Yadunund closed 1 year ago

Yadunund commented 1 year ago

Hi there,

Hate to be that guy asking for more documentation when something is actively being developed but I hope these questions won't take much time to answer.

Here are some basic questions I have:

Thanks in advance!

tylerjw commented 1 year ago

Thank you for asking. We do have plans to better document this. @sea-bass will be able to better answer your questions about the general usefulness of this as he is actively using it.

On the parameters, one thing you can check out is this file which describes what each of the parameters is and how they work: https://github.com/PickNikRobotics/pick_ik/blob/main/src/pick_ik_parameters.yaml

I hope to have better documentation than that in the future, but for now, I think reading that is the best information we have.

Yadunund commented 1 year ago

@tylerjw the parameters schema is very helpful, thanks for pointing me to that 🙇🏼‍♂️

sea-bass commented 1 year ago

I'll take the action to actually fill in the README of this repo -- thanks for the prompt @Yadunund!

You should be able to default to pick_ik as your solver. It does a few fancier things compared to the default KDL solver, which means it may not be as fast, but is more flexible. So my first recommendation is if the default works fine, probably stick with that. The benefits of pick_ik are:

As you asked about caching, that is not handled directly by pick_ik, but the cached plugin approach should work. I actually haven't tried it, so if you end up going that route, I would appreciate your feedback.

An example kinematics.yaml file might look as follows:

panda_arm:
  kinematics_solver: pick_ik/PickIkPlugin
  kinematics_solver_timeout: 0.05
  kinematics_solver_attempts: 3
  mode: global
  rotation_scale: 0.5
  twist_threshold: 0.001
  cost_threshold: 0.001
  minimal_displacement_weight: 0.0
  gd_step_size: 0.0001

@tylerjw graciously pointed to all the parameters, but there are some key properties to look out for:

You can play with this solver live in RViz, as this plugin is programmed to respond to parameter changes at every solve. This means that you can change values on the fly from the command line, e.g.,

ros2 param set /rviz2 robot_description_kinematics.panda_arm.mode global
ros2 param set /rviz2 robot_description_kinematics.panda_arm.minimal_displacement_weight 0.001

Hope this is a good starting point, and it helps me also figure out how to frame a good README.

Yadunund commented 1 year ago

@sea-bass many thanks for the very descriptive response- they're super useful in understanding more about the plugin! pick_ik sounds really powerful (especially the local vs global modes). Looking forward to testing it out!

Yadunund commented 1 year ago

Just wanted to say pick_ik is awesome! Been using it as the default for a few weeks now in simulation and with a physical robot! Previously the ompl planner was unable to sample goal states when I specified really tight goal tolerances (0.0005) but with pick_ik, i'm able to plan successfully (had to increase `kinematics_solver_timeout to 0.5). Cartesian interpolation succeeds a lot more often too with better quality paths!

However the tradeoffs have been longer planning times. The rotation_scale seems to have a big impact on this duration. My application requires precise orientation so I had set this to 1.0 originally. Had to bring it down to 0.5.

Wondering if you have any other tips for shortening planning duration? What are the implications of increasing the cost_threshold?

Here are the parameters i'm using

manipulator:
  kinematics_solver: pick_ik/PickIkPlugin
  kinematics_solver_timeout: 0.5
  kinematics_solver_attempts: 3
  mode: local
  rotation_scale: 0.5
  position_threshold: 0.001
  orientation_threshold: 0.01
  cost_threshold: 0.001
  minimal_displacement_weight: 0.0
  gd_step_size: 0.0001
  cost_threshold: 0.001
  center_joints_weight: 0.0
  avoid_joint_limits_weight: 0.0
  minimal_displacement_weight: 0.0
sea-bass commented 1 year ago

Great to hear!

I know the planning times are longer with pick_ik, but a timeout of 0.5 seems high regardless. I guess with tight tolerances it makes some sense.

The way the solver works is you will only get a successful solution if position, rotation, and cost are all below their specific thresholds.

Increasing the cost threshold won't make a huge difference if you're only solving for pose without any other side objectives, as the cost is directly tied to the pose error... but it also means you can increase it with no repercussions.

If you were minimizing joint displacement, for example, then you have the choice of either a) turning up the pose thresholds to prioritize the displacement cost objective b) turning up the cose threshold to prioritize meeting the target pose.

I too have seen that the rotation cost can really get the IK solver bogged down, especially for Cartesian interpolation. What worked for me better was using the global solver with multiple threads, adding a minimal joint displacement cost of 0.005 or so, and bumping up the cost threshold to about 0.01.

As far as other ways to speed up planning, besides trying the global solver, you could see if playing with the local solver's gradient descent options (step size, min cost delta, etc.) help. Specifically, you could increase the step size as long as it's not too coarse to overshoot minima. Coupled with the global solver, this may work out?

Yadunund commented 1 year ago

Thanks for the explanations and recommendations! Very insightful. I assumed the global planner would incur a higher computational load. Is it intrinsically multi threaded or is that a parameter to enable?