Roban2 Docs
Roban2 (ROS1) Legacy VersionsFeature ExamplesGeneral Examples

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_ik

Launch

Launch Parameters

The following are the optional parameters when launching the IK module:

  • visualize : Whether to visualize in Rviz; the default value is false
  • robot_version : Robot version number; the default value is the ROBOT_VERSION environment variable
  • control_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 2
  • eef_z_bias : Offset of the end effector z coordinate; the default value is -0.17, unit m
  • model_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 to robot_version
  • model_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 to robot_version
  • print_ik_info : Whether to print solver debug information in the terminal; the default value is false

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:=false

Solve 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:=1

ROS Interfaces

Topics

Subscribed Topics

/ik/two_arm_hand_pose_cmd

Topic description: Arm IK solving topic

Message type: motion_capture_ik/twoArmHandPoseCmd

FieldTypeDescription
hand_posestwoArmHandPoseBoth hands information: end-effector position, end-effector quaternion, elbow position, etc.
use_custom_ik_paramboolWhether to use custom IK parameters; when set to true, the ik_param value in the message is used for solving
joint_angles_as_q0boolWhether to use joint_angles in hand_poses as q0 for solving
ik_paramikSolveParamCustom IK solving parameters

Detailed description of the ik_param field:

FieldTypeDescription
major_optimality_tolfloat64snopt parameter, i.e. the optimality tolerance in major iterations; this parameter determines how well the optimality condition is satisfied
major_feasibility_tolfloat64snopt parameter, i.e. the feasibility tolerance in major iterations, used to control nonlinear constraints
minor_feasibility_tolfloat64snopt parameter, the feasibility tolerance in minor iterations, mainly used for the linearized model
major_iterations_limitfloat64snopt parameter, the maximum number of major iterations
oritation_constraint_tolfloat64Orientation constraint parameter
pos_constraint_tolfloat64Position constraint parameter; this parameter only takes effect when pos_cost_weight is greater than 0.0
pos_cost_weightfloat64Position 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:

FieldTypeDescription
pos_xyzfloat64[3]Desired end-effector position, unit m
quat_xyzwfloat64[4]Desired end-effector orientation
elbow_pos_xyzfloat64[3]Desired elbow position; ignored when all values are set to 0.0
joint_anglesfloat64[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.

FieldTypeDescription
pos_xyzfloat64[3]End-effector position, unit m
quat_xyzwfloat64[4]End-effector orientation
elbow_pos_xyzfloat64[3]Elbow position, unit m
joint_anglesfloat64[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 ms
  • data[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:

FieldTypeDescription
twoArmHandPoseCmdRequesttwoArmHandPoseCmdFor details, refer to the content of the /ik/two_arm_hand_pose_cmd topic

Return result:

FieldTypeDescription
successboolWhether successful
with_torsoboolWhether the torso is included
q_armfloat64[]Arm joint values, unit rad
q_torsofloat64[]Torso joint values
time_costfloat64Solving time cost, unit ms
hand_posestwoArmHandPoseIK 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

FieldTypeDescription
qfloat64[]Length is 14; contains the arm joint angles, unit rad
successboolReturn parameter, whether successful
hand_posestwoArmHandPoseReturn 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