Arm Forward and Inverse Kinematics Example
Description
- Path:
/home/lab/kuavo-ros-opensource/src/manipulation_nodes/motion_capture_ik
Build
cd /home/lab/kuavo-ros-opensource #repository directory
sudo su
catkin build kuavo_sdk
catkin build motion_capture_ikLaunch
Launch Parameters
The following are optional parameters when launching the IK module:
visualize: Whether to visualize in Rviz, defaults tofalserobot_version: Robot version number, defaults to theROBOT_VERSIONenvironment variablecontrol_hand_side: Sets which arm(s) to control; 0 controls only the left arm, 1 controls only the right arm, 2 controls both arms. Defaults to 2eef_z_bias: Offset for the end effector z coordinate, defaults to-0.17, in mmodel_path: Path to the URDF file loaded during IK solving; usually no need to set manually. By default it is searched for and set from the kuavo_assets package according torobot_versionmodel_path_vis: URDF file loaded for visualization in RVIZ; usually no need to set manually. By default it is searched for and set from the kuavo_assets package according torobot_versionprint_ik_info: Whether to print solving debug information in the terminal, defaults tofalse
Launch Examples
Robot with version number 43, with visualization enabled:
source devel/setup.bash
roslaunch motion_capture_ik ik_node.launch robot_version:=43 visualize:=1 print_ik_info:=falseSolve only the right arm without visualization (robot_version comes from the ROBOT_VERSION environment variable):
source devel/setup.bash
roslaunch motion_capture_ik ik_node.launch control_hand_side:=1ROS Interfaces
Topics
Subscribed Topics
/ik/two_arm_hand_pose_cmd
Topic description: Arm IK solving topic
Message type: motion_capture_ik/twoArmHandPoseCmd
| Field | Type | Description |
|---|---|---|
| hand_poses | twoArmHandPose | Information for both hands: end effector position, end effector quaternion, elbow position, etc. |
| use_custom_ik_param | bool | Whether to use custom IK parameters; when set to true, the ik_param value in the message is used for solving |
| joint_angles_as_q0 | bool | Whether to use joint_angles in hand_poses as q0 during solving |
| ik_param | ikSolveParam | Custom IK solving parameters |
The ik_param field is described in detail as follows:
| Field | Type | Description |
|---|---|---|
| major_optimality_tol | float64 | snopt parameter, i.e. the optimality tolerance in major iterations; this parameter determines how well the optimality conditions are satisfied |
| major_feasibility_tol | float64 | snopt parameter, i.e. the feasibility tolerance in major iterations, used to control nonlinear constraints |
| minor_feasibility_tol | float64 | snopt parameter, the feasibility tolerance in minor iterations, mainly used for the linearized model |
| major_iterations_limit | float64 | snopt parameter, the maximum number of major iterations |
| oritation_constraint_tol | float64 | Orientation constraint parameter |
| pos_constraint_tol | float64 | Position constraint parameter, this parameter only takes effect when pos_cost_weight is greater than 0.0 |
| pos_cost_weight | float64 | Position cost parameter, when set to 0.0, the solving accuracy requirement is the highest |
If you want higher-precision IK solutions, you can set pos_cost_weight to 0.0, but this also reduces the probability of a successful solution.
The hand_poses field is described in detail as follows:
| Field | Type | Description |
|---|---|---|
| pos_xyz | float64[3] | Desired end effector position, in m |
| quat_xyzw | float64[4] | Desired end effector orientation |
| elbow_pos_xyz | float64[3] | Desired elbow position; this parameter is ignored when all values are set to 0.0 |
| joint_angles | float64[7] | If joint_angles_as_q0 is true, this value is used as q0 during solving, in radians |
Published Topics
/ik/result
Topic description: Publishes the IK solving results
Message type: motion_capture_ik/twoArmHandPose
Publishes the left and right hand results in the IK results,
| Field | Type | Description |
|---|---|---|
| pos_xyz | float64[3] | End effector position, in m |
| quat_xyzw | float64[4] | End effector orientation |
| elbow_pos_xyz | float64[3] | Elbow position, in m |
| joint_angles | float64[7] | Arm joint values, in radians |
/ik/debug/time_cost
Topic description: Can be ignored; mainly debug output of solving time cost, in milliseconds
Message type: std_msgs/Float32MultiArray
data[0]: Loop time cost, in millisecondsdata[1]: Solving time cost, in milliseconds
/kuavo_arm_traj
Topic description: When invoked via the /ik/two_arm_hand_pose_cmd topic, output whenever there is a result, in radians
Message type: sensor_msgs/JointState
Services
/ik/two_arm_hand_pose_cmd_srv
Topic description: IK inverse solving service
Message type: motion_capture_ik/twoArmHandPoseCmdSrv
Request parameters:
| Field | Type | Description |
|---|---|---|
| twoArmHandPoseCmdRequest | twoArmHandPoseCmd | For details, refer to the content of the /ik/two_arm_hand_pose_cmd topic |
Returned result:
| Field | Type | Description |
|---|---|---|
| success | bool | Whether successful |
| with_torso | bool | Whether the torso is included |
| q_arm | float64[] | Arm joint values, in radians |
| q_torso | float64[] | Torso joint values |
| time_cost | float64 | Solving time cost, in ms |
| hand_poses | twoArmHandPose | IK solving results; for details, see the same message type above |
/ik/fk_srv
Topic description: FK forward solving service
Message type: motion_capture_ik/fkSrv
| Field | Type | Description |
|---|---|---|
| q | float64[] | Length 14, containing the arm joint angles, in radians |
| success | bool | Return parameter, whether successful |
| hand_poses | twoArmHandPose | Return parameter, forward kinematics results; for details, see the same message type above |
Usage Examples
- Using the IK solving service
The following code shows how to call the IK service and print the returned result. You can invoke it by running the following command:
source devel/setup.bash
rosrun motion_capture_ik example_ik_srv.py- Using the IK solving topic
The following code shows how to use the IK functionality via the IK topic and print the returned result. You can invoke it by running the following command:
source devel/setup.bash
rosrun motion_capture_ik example_ik.py- Using the FK solving service
The following code shows how to call the FK service and print the returned result. You can invoke it by running the following command:
source devel/setup.bash
rosrun motion_capture_ik example_fk_srv.py