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 Name | control_head |
|---|---|
| Function Prototype | bool control_head(float yaw, float pitch) |
| Overview | Controls the yaw and pitch angles of the robot head. |
| Parameters | yaw: 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 Value | true: Control succeeded false: Control failed |
| Remarks | Angles 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 Name | control_arm_joint_positions |
|---|---|
| Function Prototype | bool control_arm_joint_positions(list joint_positions) |
| Overview | Controls the joint positions of the robot arm. |
| Parameters | joint_positions: List of target joint positions, in radians, with a length equal to the number of arm joints (8 joints) |
| Return Value | true: Control succeeded false: Control failed |
| Remarks | 1. 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 Name | arm_fk |
|---|---|
| Function Prototype | Tuple[KuavoPose, KuavoPose] arm_fk(list q) |
| Overview | Computes the forward kinematics of the robot arm. |
| Parameters | q: List of joint positions, in radians |
| Return Value | Tuple of the poses of the left and right arm end effectors; returns (None, None) if the computation fails |
| Remarks | The returned KuavoPose contains position and orientation information |
| Function Name | control_arm_joint_trajectory |
|---|---|
| Function Prototype | bool control_arm_joint_trajectory(list times, list joint_q) |
| Overview | Controls the joint trajectory of the robot arm. |
| Parameters | times: List of time points, in seconds joint_q: List of joint positions, with one set of joint positions per time point, in radians |
| Return Value | true: Control succeeded false: Control failed |
| Remarks | 1. 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 Name | arm_ik |
|---|---|
| Function Prototype | list 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) |
| Overview | Computes the inverse kinematics of the robot arm. |
| Parameters | left_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 Value | List of joint positions; returns None if the computation fails |
| Remarks | Computation accuracy and constraints can be adjusted via the params parameter |
| Function Name | control_robot_end_effector_pose |
|---|---|
| Function Prototype | bool control_robot_end_effector_pose(KuavoPose left_pose, KuavoPose right_pose, KuavoManipulationMpcFrame frame) |
| Overview | Controls the pose of the robot arm end effectors. |
| Parameters | left_pose: Target pose of the left arm right_pose: Target pose of the right arm frame: Control reference frame |
| Return Value | true: Control succeeded false: Control failed |
| Function Name | set_fixed_arm_mode |
|---|---|
| Function Prototype | bool set_fixed_arm_mode() |
| Overview | Sets the arms to fixed mode. |
| Return Value | true: Set successfully false: Set failed |
| Remarks | In fixed mode, the arms stay at their current positions |
| Function Name | set_auto_swing_arm_mode |
|---|---|
| Function Prototype | bool set_auto_swing_arm_mode() |
| Overview | Sets the arms to auto-swing mode. |
| Return Value | true: Set successfully false: Set failed |
| Remarks | In auto-swing mode, the arms swing automatically with the gait |
| Function Name | set_external_control_arm_mode |
|---|---|
| Function Prototype | bool set_external_control_arm_mode() |
| Overview | Sets the arms to external control mode. |
| Return Value | true: Set successfully false: Set failed |
| Remarks | In external control mode, the arms can be controlled via interfaces such as control_arm_joint_positions |
| Function Name | arm_reset |
|---|---|
| Function Prototype | bool arm_reset() |
| Overview | Resets the arms to the default position. |
| Return Value | true: Reset succeeded false: Reset failed |
| Remarks | Typically 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 Name | control |
|---|---|
| Function Prototype | bool control(list target_positions, list target_velocities = None, list target_torques = None) |
| Overview | Controls the joint positions of the dexterous hand. |
| Parameters | target_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 Value | true: Control succeeded false: Control failed |
| Remarks | Position control only |
| Function Name | control_left |
| ------- | ------------- |
| Function Prototype | bool control_left(list target_positions, list target_velocities = None, list target_torques = None) |
| Overview | Controls the joint positions of the left dexterous hand |
| Parameters | target_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 Value | true: Control succeeded false: Control failed |
| Function Name | control_right |
|---|---|
| Function Prototype | bool control_right(list target_positions, list target_velocities = None, list target_torques = None) |
| Overview | Controls the joint positions of the right dexterous hand |
| Parameters | target_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 Value | true: Control succeeded false: Control failed |
| Function Name | make_gesture |
|---|---|
| Function Prototype | bool make_gesture(str l_gesture_name, str r_gesture_name) |
| Overview | Controls the dexterous hand to perform predefined gestures. |
| Parameters | l_gesture_name: Name of the left-hand gesture r_gesture_name: Name of the right-hand gesture |
| Return Value | true: Control succeeded false: Control failed |
| Remarks | Supported 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:
-
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
-
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:
-
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
-
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
-
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:
- Single-side finger control:
- Left hand makes a "thumbs up" gesture
- Right hand makes a "666" gesture
- Preset gesture invocation:
- Retrieve the names of all supported gestures
- Invoke preset gestures (such as "thumbs up" and "OK" gestures)