Kuavo Docs
Feature ExamplesGeneral Examples

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_ik

Launch

Launch Parameters

The following are optional parameters when launching the IK module:

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

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

Solve 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:=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_posestwoArmHandPoseInformation for both hands: 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 during solving
ik_paramikSolveParamCustom IK solving parameters

The ik_param field is described in detail as follows:

FieldTypeDescription
major_optimality_tolfloat64snopt parameter, i.e. the optimality tolerance in major iterations; this parameter determines how well the optimality conditions are 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 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:

FieldTypeDescription
pos_xyzfloat64[3]Desired end effector position, in m
quat_xyzwfloat64[4]Desired end effector orientation
elbow_pos_xyzfloat64[3]Desired elbow position; this parameter is 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 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,

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

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

Returned result:

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

FieldTypeDescription
qfloat64[]Length 14, containing the arm joint angles, in radians
successboolReturn parameter, whether successful
hand_posestwoArmHandPoseReturn 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