Arm Forward and Inverse Kinematics Example
Description
- Path:
~/kuavo-ros-opensource/src/manipulation_nodes/motion_capture_ik
Build
cd ~/kuavo-ros-opensource #仓库目录
sudo su
catkin build kuavo_sdk
catkin build motion_capture_ikLaunch
Launch Parameters
The following are the optional parameters when launching the IK module:
visualize: Whether to visualize in Rviz; the default value isfalserobot_version: Robot version number; the default value is theROBOT_VERSIONenvironment variablecontrol_hand_side: Sets which arm(s) to control; 0 means left arm only, 1 means right arm only, 2 means both arms; the default value is 2eef_z_bias: Offset of the end effector z coordinate; the default value is-0.17, unit mmodel_path: Path to the URDF file loaded for IK solving; usually no need to set manually; by default it is searched 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 and set from the kuavo_assets package according torobot_versionprint_ik_info: Whether to print solver debug information in the terminal; the default value isfalse
Launch Examples
For a robot with version number 43, with visualization enabled:
source devel/setup.bash
roslaunch motion_capture_ik ik_node.launch robot_version:=14 visualize:=1 print_ik_info:=falseSolve the right arm only without visualization (robot_version 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 | Both hands information: 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 for solving |
| ik_param | ikSolveParam | Custom IK solving parameters |
Detailed description of the ik_param field:
| Field | Type | Description |
|---|---|---|
| major_optimality_tol | float64 | snopt parameter, i.e. the optimality tolerance in major iterations; this parameter determines how well the optimality condition is 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 solution accuracy requirement is the highest |
If you want higher-accuracy IK solutions, you can set pos_cost_weight to 0.0, but this also reduces the probability of a successful solve.
Detailed description of the hand_poses field:
| Field | Type | Description |
|---|---|---|
| pos_xyz | float64[3] | Desired end-effector position, unit m |
| quat_xyzw | float64[4] | Desired end-effector orientation |
| elbow_pos_xyz | float64[3] | Desired elbow position; 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 for solving, unit rad |
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 result.
| Field | Type | Description |
|---|---|---|
| pos_xyz | float64[3] | End-effector position, unit m |
| quat_xyzw | float64[4] | End-effector orientation |
| elbow_pos_xyz | float64[3] | Elbow position, unit m |
| joint_angles | float64[7] | Arm joint values, unit rad |
/ik/debug/time_cost
Topic description: Can be ignored; mainly outputs solving time cost for debugging, unit ms
Message type: std_msgs/Float32MultiArray
data[0]: Loop time cost, unit msdata[1]: Solving time cost, unit ms
/kuavo_arm_traj
Topic description: When invoked through the /ik/two_arm_hand_pose_cmd topic, output whenever there is a result, unit rad
Message type: sensor_msgs/JointState
Services
/ik/two_arm_hand_pose_cmd_srv
Topic description: IK inverse kinematics 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 |
Return result:
| Field | Type | Description |
|---|---|---|
| success | bool | Whether successful |
| with_torso | bool | Whether the torso is included |
| q_arm | float64[] | Arm joint values, unit rad |
| q_torso | float64[] | Torso joint values |
| time_cost | float64 | Solving time cost, unit ms |
| hand_poses | twoArmHandPose | IK solving result; for details, see the message of the same type above |
/ik/fk_srv
Topic description: FK forward kinematics service
Message type: motion_capture_ik/fkSrv
| Field | Type | Description |
|---|---|---|
| q | float64[] | Length is 14; contains the arm joint angles, unit rad |
| success | bool | Return parameter, whether successful |
| hand_poses | twoArmHandPose | Return parameter, forward kinematics result; for details, see the message of the same 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 run it with 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 feature through the IK topic and print the returned result. You can run it with 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 run it with the following command:
source devel/setup.bash
rosrun motion_capture_ik example_fk_srv.py