PickNikRobotics / pick_ik

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

`pick_ik` is 10x slower than `bio_ik` #60

Open sea-bass opened 1 year ago

sea-bass commented 1 year ago

I finally did some benchmarking thanks to @Robotawi's help, and unfortunately the results are not encouraging.

Turns out that pick_ik's use of MoveIt's RobotState::updateLinkTransforms() + RobotState::getGlobalLinkTransform() for forward kinematics is 10x slower than the caching mechanism applied in bio_ik -- and that contributes to basically all the slowdowns in the benchmark.

https://github.com/ros-planning/moveit2/blob/main/moveit_core/robot_state/src/robot_state.cpp#L377-L379

We should fix this by looking at the tricks employed by bio_ik and improving MoveIt's RobotState to contain these capabilities!

One key thing that will need to happen here if we enable caching in RobotState is we can't just reuse the same RobotState instance for all the FK function calls. Basically, each memetic thread and local gradient descent call should use its own state so that the caching actually pays off. We'll also need to copy over from bio_ik the notion of a "link schedule" where the perturbations we evaluate first should happen at the tip of the kinematic chain(s) to minimize link pose recomputes.

timonegk commented 9 months ago

Permalink to the code you referenced: https://github.com/ros-planning/moveit2/blob/01bae77cddcbb23edd1f7ba3de5487393a0261c5/moveit_core/robot_state/src/robot_state.cpp#L377-L379