Roban2 Docs
Roban2 (ROS1) Legacy VersionsDevelopment InterfacesHumanoid SDK Interfaces

Head and Hand Control

The Humanoid SDK provides comprehensive head and hand control interfaces, supporting robot head motion control, arm motion control, and dexterous hand operation. This document describes in detail how to use these control interfaces.

Interface Description

Head Control Interfaces

RobotHead

The RobotHead class provides interfaces for controlling robot head motion.

The main interfaces are described below:

Function Namecontrol_head
Function Prototypebool control_head(float yaw, float pitch)
OverviewControls the yaw and pitch angles of the robot head.
Parametersyaw: Horizontal rotation angle of the head, range [-1.396, 1.396] rad (approximately -80° to 80°)
pitch: Pitch angle of the head, range [-0.436, 0.436] rad (approximately -25° to 25°)
Return Valuetrue: Control succeeded
false: Control failed
RemarksAngles are in radians; values outside the range are automatically clamped to the valid range

Arm Control Interfaces

RobotArm

The RobotArm class provides interfaces for controlling the robot arm.

The main interfaces are described below:

Function Namecontrol_arm_joint_positions
Function Prototypebool control_arm_joint_positions(list joint_positions)
OverviewControls the joint positions of the robot arm.
Parametersjoint_positions: List of target joint positions, in radians, with a length equal to the number of arm joints (8 joints)
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. Joint angle range must be [-π, π] rad
2. The robot must be in a standing state
3. The arm must be in external control mode
Function Namearm_fk
Function PrototypeTuple[KuavoPose, KuavoPose] arm_fk(list q)
OverviewComputes the forward kinematics of the robot arm.
Parametersq: List of joint positions, in radians
Return ValueTuple of the poses of the left and right arm end effectors; returns (None, None) if the computation fails
RemarksThe returned KuavoPose contains position and orientation information
Function Namecontrol_arm_joint_trajectory
Function Prototypebool control_arm_joint_trajectory(list times, list joint_q)
OverviewControls the joint trajectory of the robot arm.
Parameterstimes: List of time points, in seconds
joint_q: List of joint positions, with one set of joint positions per time point, in radians
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. times and joint_q must have the same length
2. Joint angle range must be [-π, π] rad
3. The robot must be in a standing state
4. The arm must be in external control mode
Function Namearm_ik
Function Prototypelist arm_ik(KuavoPose left_pose, KuavoPose right_pose, list left_elbow_pos_xyz=[0.0,0.0, 0.0], list right_elbow_pos_xyz=[0.0, 0.0, 0.0], list arm_q0=None, KuavoIKParams params=None)
OverviewComputes the inverse kinematics of the robot arm.
Parametersleft_pose: Target pose of the left arm
right_pose: Target pose of the right arm
left_elbow_pos_xyz: Left elbow position
right_elbow_pos_xyz: Right elbow position
arm_q0: Initial joint positions
params: Inverse kinematics parameters
Return ValueList of joint positions; returns None if the computation fails
RemarksComputation accuracy and constraints can be adjusted via the params parameter
Function Namecontrol_robot_end_effector_pose
Function Prototypebool control_robot_end_effector_pose(KuavoPose left_pose, KuavoPose right_pose, KuavoManipulationMpcFrame frame)
OverviewControls the pose of the robot arm end effectors.
Parametersleft_pose: Target pose of the left arm
right_pose: Target pose of the right arm
frame: Control reference frame
Return Valuetrue: Control succeeded
false: Control failed
Function Nameset_fixed_arm_mode
Function Prototypebool set_fixed_arm_mode()
OverviewSets the arms to fixed mode.
Return Valuetrue: Set successfully
false: Set failed
RemarksIn fixed mode, the arms stay at their current positions
Function Nameset_auto_swing_arm_mode
Function Prototypebool set_auto_swing_arm_mode()
OverviewSets the arms to auto-swing mode.
Return Valuetrue: Set successfully
false: Set failed
RemarksIn auto-swing mode, the arms swing automatically with the gait
Function Nameset_external_control_arm_mode
Function Prototypebool set_external_control_arm_mode()
OverviewSets the arms to external control mode.
Return Valuetrue: Set successfully
false: Set failed
RemarksIn external control mode, the arms can be controlled via interfaces such as control_arm_joint_positions
Function Namearm_reset
Function Prototypebool arm_reset()
OverviewResets the arms to the default position.
Return Valuetrue: Reset succeeded
false: Reset failed
RemarksTypically used to initialize the arm positions

Hand Control Interfaces

The Humanoid SDK supports: DexterousHand - dexterous hand

DexterousHand Interfaces

The DexterousHand class provides the following main interfaces:

Function Namecontrol
Function Prototypebool control(list target_positions, list target_velocities = None, list target_torques = None)
OverviewControls the joint positions of the dexterous hand.
Parameterstarget_positions: List of target positions, length 12 (6 joints per hand), range [0.0 ~ 100.0]
target_velocities: Not supported yet
target_torques: Not supported yet
Return Valuetrue: Control succeeded
false: Control failed
RemarksPosition control only
Function Namecontrol_left
--------------------
Function Prototypebool control_left(list target_positions, list target_velocities = None, list target_torques = None)
OverviewControls the joint positions of the left dexterous hand
Parameterstarget_positions: List of target positions, length 6 (6 joints of the left hand), range [0.0 ~ 100.0]
target_velocities: Not supported yet
target_torques: Not supported yet
Return Valuetrue: Control succeeded
false: Control failed
Function Namecontrol_right
Function Prototypebool control_right(list target_positions, list target_velocities = None, list target_torques = None)
OverviewControls the joint positions of the right dexterous hand
Parameterstarget_positions: List of target positions, length 6 (6 joints of the right hand), range [0.0 ~ 100.0]
target_velocities: Not supported yet
target_torques: Not supported yet
Return Valuetrue: Control succeeded
false: Control failed
Function Namemake_gesture
Function Prototypebool make_gesture(str l_gesture_name, str r_gesture_name)
OverviewControls the dexterous hand to perform predefined gestures.
Parametersl_gesture_name: Name of the left-hand gesture
r_gesture_name: Name of the right-hand gesture
Return Valuetrue: Control succeeded
false: Control failed
RemarksSupported gestures include: 'fist', 'ok', 'thumbs_up', '666', 'number_1', etc.

Examples

Refer to the SDK example code:

Head control: <kuavo-ros-opensource>/src/kuavo_humanoid_websocket_sdk/examples/atomic_skills/ctrl_head_example.py

Demonstrates how to control the pitch and yaw angles of the robot head via the SDK to achieve up-and-down and left-and-right head motion.

The example code demonstrates two motion modes:

  1. Head nodding motion (up and down):

    • Starting from 0 degrees, first rotate down to -25 degrees
    • Then rotate up from -25 degrees to 25 degrees
    • Finally return from 25 degrees to 0 degrees
    • Repeat for 2 cycles
  2. Head shaking motion (left and right):

    • Starting from 0 degrees, first rotate left to 60 degrees
    • Then rotate right from 60 degrees to -60 degrees
    • Finally return from -60 degrees to 0 degrees
    • Repeat for 2 cycles

Each motion changes in small angular increments (2 degrees) with a 0.1-second interval to achieve smooth motion.


Arm control: <kuavo-ros-opensource>/src/kuavo_humanoid_websocket_sdk/examples/atomic_skills/ctrl_arm_example.py

Demonstrates arm trajectory control and target pose control.

It includes various arm operation methods such as joint angle interpolation motion, joint trajectory control, and end effector pose control, and is suitable for testing the arm's basic motions, trajectory tracking, and end effector control capabilities.

The example code contains three main control functions:

  1. control_arm_traj(): Joint angle interpolation motion

    • Starting from the initial position q0, interpolate over 90 steps to the target position q1
    • q1 sets a pose with the right arm raised 50 degrees
    • Each step is separated by 0.02 seconds to achieve a smooth transition
    • After the motion completes, return to the initial position
    • Finally, reset the arm positions
  2. control_arm_joint_trajectory(): Joint trajectory control

    • Defines target poses at 7 key time points
    • The robot automatically performs trajectory planning between keyframes
    • Reset the arm positions after execution
  3. control_arm_end_effector_pose(): End effector pose control

    • Directly specifies the target positions and orientations of the left and right end effectors in the world coordinate frame
    • Required joint angles are automatically computed via inverse kinematics
    • The robot automatically plans a trajectory to reach the target pose
    • Reset the arm positions when finished

Dexterous hand control: <kuavo-ros-opensource>/src/kuavo_humanoid_websocket_sdk/examples/atomic_skills/dexhand_example.py

Demonstrates how to control the basic motions and preset gestures of the Dexterous Hand.

It supports single-side control, bilateral synchronized control, preset gesture invocation, and other functions. The example code demonstrates:

  1. Single-side finger control:
    • Left hand makes a "thumbs up" gesture
    • Right hand makes a "666" gesture
  2. Preset gesture invocation:
    • Retrieve the names of all supported gestures
    • Invoke preset gestures (such as "thumbs up" and "OK" gestures)