Setup IKFast Kinematics Plugin

This script facilitates the creation of a ROS 2 kinematics plugin wrapper around an IKFast solver generated by OpenRAVE. It generates the necessary C++ wrapper code, plugin configuration, and updates the build system to compile the plugin.

Note

This script does not generate the IKFast solver C++ file itself. You must generate it using OpenRAVE (e.g., using a docker image like openrave-ikfast) and place the resulting <robot_name>_ikfast.cpp file in the src folder of your package.

Prerequisites

  • An existing ROS 2 package (create one using create-new-package if needed).

  • The IKFast solver file generated by OpenRAVE (usually named <robot_name>_ikfast.cpp).

Usage

Execute the script from the root of your target package:

setup-ikfast-plugin ROBOT_NAME [CLASS_NAME]

Arguments

  • ROBOT_NAME: The name of the robot. This should match the prefix of your IKFast solver file (e.g., if file is myrobot_ikfast.cpp, use myrobot).

  • CLASS_NAME (Optional): The C++ class name for the plugin. If omitted, it is auto-generated from the robot name (e.g., myrobot -> MyrobotKinematics).

Interactive Steps

  1. License Selection: Choose a license header for the generated files.

  2. Configuration Check: Confirm if package.xml and CMakeLists.txt are already configured for an IKFast plugin. If “no” (default), the script will automatically add dependencies and build rules.

  3. Confirmation: Review the proposed names and paths before proceeding.

Generated Files

The script creates the following files in your package:

  • src/<robot_name>_ikfast_plugin.cpp: The ROS 2 plugin wrapper implementation.

  • <robot_name>_ikfast.xml: Plugin description file for pluginlib.

  • test/test_<robot_name>_ikfast_plugin.cpp: A GoogleTest file to verify the plugin’s functionality (FK, Jacobian, IK).

Updates to Existing Files

If you selected “no” for the configuration check, the script updates:

  • package.xml: Adds dependencies on pluginlib, kinematics_interface, kinematics_interface_ikfast, and rclcpp.

  • CMakeLists.txt: Adds library target, include directories, dependencies, and install rules. It also configures the test target.

Post-Generation Steps

  1. Ensure your generated IKFast solver file (e.g., src/<robot_name>_ikfast.cpp) is present.

  2. Build the package:

    cb --packages-select <your_package_name>
    
  3. Run the generated tests to verify the plugin:

    ct --packages-select <your_package_name>