|
| 1 | +pick_ik Kinematics Solver |
| 2 | +========================= |
| 3 | + |
| 4 | +`pick_ik <https://github.com/PickNikRobotics/pick_ik>`_ is an inverse kinematics (IK) solver compatible with MoveIt 2, |
| 5 | +developed by PickNik Robotics. It is designed to provide robust and customizable IK solutions, |
| 6 | +offering a wide range of features. |
| 7 | + |
| 8 | +The solver in ``pick_ik`` is a reimplementation of `bio_ik <https://github.com/TAMS-Group/bio_ik>`_, |
| 9 | +integrating a global optimizer and a local optimizer. The global optimizer utilizes evolutionary algorithms to explore |
| 10 | +alternative solutions within the solution space and identify global optima. Building upon the results obtained by the global optimizer, |
| 11 | +the local optimizer applies gradient descent for iterative refinement of the solution. It takes a potential optimum solution provided |
| 12 | +by the global optimizer as input and aims to improve its accuracy and ultimately convergence to the most optimum solution. |
| 13 | + |
| 14 | +Getting Started |
| 15 | +--------------- |
| 16 | +Before proceeding, please ensure that you have completed the steps outlined in the :doc:`Getting Started Guide </doc/tutorials/getting_started/getting_started>`. |
| 17 | + |
| 18 | +Additionally, it is required to have a MoveIt configuration package specifically tailored to your robot. |
| 19 | +This package can be created using the :doc:`MoveIt Setup Assistant </doc/examples/setup_assistant/setup_assistant_tutorial>`. |
| 20 | + |
| 21 | +Installation |
| 22 | +------------ |
| 23 | + |
| 24 | +From binaries |
| 25 | +^^^^^^^^^^^^^ |
| 26 | +Make sure your ROS 2 installation is sourced and run the following command :: |
| 27 | + |
| 28 | + sudo apt install ros-$ROS_DISTRO-pick-ik |
| 29 | + |
| 30 | +From source |
| 31 | +^^^^^^^^^^^ |
| 32 | + |
| 33 | +Create a colcon workspace. :: |
| 34 | + |
| 35 | + export COLCON_WS=~/ws_moveit2/ |
| 36 | + mkdir -p $COLCON_WS/src |
| 37 | + |
| 38 | +Clone this repository in the src directory of your workspace. :: |
| 39 | + |
| 40 | + cd $COLCON_WS/src |
| 41 | + git clone -b main https://github.com/PickNikRobotics/pick_ik.git |
| 42 | + |
| 43 | +Set up colcon mixins. :: |
| 44 | + |
| 45 | + sudo apt install python3-colcon-common-extensions |
| 46 | + sudo apt install python3-colcon-mixin |
| 47 | + colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml |
| 48 | + colcon mixin update default |
| 49 | + |
| 50 | +Build the workspace. :: |
| 51 | + |
| 52 | + cd /path/to/your/workspace |
| 53 | + colcon build --mixin release |
| 54 | + |
| 55 | +Usage |
| 56 | +----- |
| 57 | + |
| 58 | +Using pick_ik as a Kinematics Plugin |
| 59 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 60 | + |
| 61 | +You can use :doc:`MoveIt Setup Assistant </doc/examples/setup_assistant/setup_assistant_tutorial>` to create |
| 62 | +the configuration files for your robot to use it with MoveIt, or edit the ``kinematics.yaml`` file in your |
| 63 | +robot's config directory to use pick_ik as the IK solver. :: |
| 64 | + |
| 65 | + panda_arm: |
| 66 | + kinematics_solver: pick_ik/PickIkPlugin |
| 67 | + kinematics_solver_timeout: 0.05 |
| 68 | + kinematics_solver_attempts: 3 |
| 69 | + mode: global |
| 70 | + position_scale: 1.0 |
| 71 | + rotation_scale: 0.5 |
| 72 | + position_threshold: 0.001 |
| 73 | + orientation_threshold: 0.01 |
| 74 | + cost_threshold: 0.001 |
| 75 | + minimal_displacement_weight: 0.0 |
| 76 | + gd_step_size: 0.0001 |
| 77 | + |
| 78 | + |
| 79 | +.. note:: |
| 80 | + |
| 81 | + You can launch a preconfigured demo with ``pick_ik`` using the following command: |
| 82 | + |
| 83 | + .. code-block:: |
| 84 | +
|
| 85 | + ros2 launch moveit2_tutorials demo_pick_ik.launch.py |
| 86 | +
|
| 87 | + The command starts a demo similar to the one in :doc:`MoveIt Quickstart in RViz </doc/tutorials/quickstart_in_rviz/quickstart_in_rviz_tutorial>` |
| 88 | + tutorial. However, this demo specifically utilizes the robot kinematics configuration file ``kinematics_pick_ik.yaml`` |
| 89 | + located at the ``moveit2_tutorials/doc/pick_ik/config`` directory :codedir:`here<how_to_guides/pick_ik/config/kinematics_pick_ik.yaml>`. |
| 90 | + |
| 91 | +Parameter Description |
| 92 | +^^^^^^^^^^^^^^^^^^^^^ |
| 93 | + |
| 94 | +For an exhaustive list of parameters, refer to the `parameters YAML file <https://github.com/PickNikRobotics/pick_ik/blob/main/src/pick_ik_parameters.yaml>`__. |
| 95 | + |
| 96 | +Some key parameters you may want to start with are: |
| 97 | + |
| 98 | +- ``mode``: If you choose ``local``, this solver will only do local gradient descent; if you choose ``global``, |
| 99 | + it will also enable the evolutionary algorithm. Using the global solver will be less performant, but if you're |
| 100 | + having trouble getting out of local minima, this could help you. We recommend using ``local`` for things like |
| 101 | + relative motion / Cartesian interpolation / endpoint jogging, and ``global`` if you need to solve for goals |
| 102 | + with a far-away initial condition. |
| 103 | + |
| 104 | +- ``memetic_<property>``: All the properties that only kick in if you use the ``global`` solver. |
| 105 | + The key one is ``memetic_num_threads``, as we have enabled the evolutionary algorithm to solve on multiple threads. |
| 106 | + |
| 107 | +- ``position_threshold`` / ``orientation_threshold``: Optimization succeeds only if the pose difference is less than |
| 108 | + these thresholds in meters and radians respectively. A ``position_threshold`` of 0.001 would mean a 1 mm accuracy and |
| 109 | + an ``orientation_threshold`` of 0.01 would mean a 0.01 radian accuracy. |
| 110 | + |
| 111 | +- ``cost_threshold``: This solver works by setting up cost functions based on how far away your pose is, |
| 112 | + how much your joints move relative to the initial guess, and custom cost functions you can add. |
| 113 | + Optimization succeeds only if the cost is less than ``cost_threshold``. Note that if you're adding custom cost functions, |
| 114 | + you may want to set this threshold fairly high and rely on ``position_threshold`` and ``orientation_threshold`` to be your deciding factors, |
| 115 | + whereas this is more of a guideline. |
| 116 | + |
| 117 | +- ``approximate_solution_position_threshold`` / ``approximate_solution_orientation_threshold``: |
| 118 | + When using approximate IK solutions for applications such as endpoint servoing, ``pick_ik`` may sometimes return solutions |
| 119 | + that are significantly far from the goal frame. To prevent issues with such jumps in solutions, |
| 120 | + these parameters define maximum translational and rotation displacement. |
| 121 | + We recommend setting this to values around a few centimeters and a few degrees for most applications. |
| 122 | + |
| 123 | +- ``position_scale``: If you want rotation-only IK, set this to 0.0. If you want to solve for a custom ``IKCostFn`` |
| 124 | + (which you provide in your ``setFromIK()`` call), set both ``position_scale`` and ``rotation_scale`` to 0.0. |
| 125 | + You can also use any other value to weight the position goal; it's part of the cost function. |
| 126 | + Note that any checks using ``position_threshold`` will be ignored if you use ``position_scale = 0.0``. |
| 127 | + |
| 128 | + |
| 129 | +- ``rotation_scale``: If you want position-only IK, set this to 0.0. If you want to treat position and orientation equally, |
| 130 | + set this to 1.0. You can also use any value in between; it's part of the cost function. Note that any checks using ``orientation_threshold`` |
| 131 | + will be ignored if you use ``rotation_scale = 0.0``. |
| 132 | + |
| 133 | +- ``minimal_displacement_weight``: This is one of the standard cost functions that checks for the joint angle difference between |
| 134 | + the initial guess and the solution. If you're solving for far-away goals, leave it to zero or it will hike up your cost function for no reason. |
| 135 | + Have this to a small non-zero value (e.g., 0.001) if you're doing things like Cartesian interpolation along a path or endpoint jogging for servoing. |
| 136 | + |
| 137 | +You can test out this solver live in RViz, as this plugin uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ |
| 138 | +package to respond to parameter changes at every solve. This means that you can change values on the fly using the ROS 2 command-line interface, e.g., |
| 139 | + |
| 140 | +.. code-block:: |
| 141 | +
|
| 142 | + ros2 param set /rviz2 robot_description_kinematics.panda_arm.mode global |
| 143 | +
|
| 144 | + ros2 param set /rviz2 robot_description_kinematics.panda_arm.minimal_displacement_weight 0.001 |
0 commit comments