Kuavo Docs
Development InterfacesPython SDK Guide

Head and Hand Control

The KUAVO Humanoid WebSocket SDK provides comprehensive head and hand control interfaces, supporting robot head motion control, arm motion control, and operation of different types of robotic hands (such as LejuClaw and DexterousHand). This document describes in detail how to use these control interfaces.

Interface Description

Head Control Interface

KuavoRobotHead

The KuavoRobotHead 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)
Functional OverviewControls the yaw and pitch angles of the robot head.
Parametersyaw: Head horizontal rotation angle, range [-1.396, 1.396] radians (approximately -80° to 80°)
pitch: Head pitch angle, range [-0.436, 0.436] radians (approximately -25° to 25°)
Return Valuetrue: Control succeeded
false: Control failed
RemarksThe angle unit is radians; values outside the range are automatically clamped to the valid range

Arm Control Interface

KuavoRobotArm

The KuavoRobotArm 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)
Functional OverviewControls the robot arm joint positions.
Parametersjoint_positions: List of target joint positions, in radians, with a length equal to the number of arm joints (14 joints)
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. The joint angle range must be [-π, π] radians
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)
Functional OverviewComputes the forward kinematics of the robot arm.
Parametersq: List of joint positions, in radians
Return ValueA tuple of 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)
Functional OverviewControls the robot arm joint trajectory.
Parameterstimes: List of time points, in seconds
joint_q: List of joint positions, 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. The joint angle range must be [-π, π] radians
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)
Functional 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<br/
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
RemarksThe computation 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)
Functional 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 coordinate frame
Return Valuetrue: Control succeeded
false: Control failed
Function Nameset_fixed_arm_mode
Function Prototypebool set_fixed_arm_mode()
Functional OverviewSets the arm to fixed mode.
Return Valuetrue: Set successfully
false: Failed to set
RemarksIn fixed mode, the arm stays at its current position without moving
Function Nameset_auto_swing_arm_mode
Function Prototypebool set_auto_swing_arm_mode()
Functional OverviewSets the arm to auto-swing mode.
Return Valuetrue: Set successfully
false: Failed to set
RemarksIn auto-swing mode, the arm swings automatically with the gait
Function Nameset_external_control_arm_mode
Function Prototypebool set_external_control_arm_mode()
Functional OverviewSets the arm to external control mode.
Return Valuetrue: Set successfully
false: Failed to set
RemarksIn external control mode, the arm can be controlled through interfaces such as control_arm_joint_positions
Function Namearm_reset
Function Prototypebool arm_reset()
Functional OverviewResets the arm to the default position.
Return Valuetrue: Reset succeeded
false: Reset failed
RemarksTypically used to initialize the arm position

Hand Control Interface

The KUAVO Humanoid SDK supports two types of robotic hands:

  1. LejuClaw - Simple gripper
  2. DexterousHand - Dexterous hand

LejuClaw Interface

The LejuClaw class provides the following main interfaces:

Function Nameopen
Function Prototypebool open(EndEffectorSide side = EndEffectorSide.BOTH)
Functional OverviewOpens the gripper.
Parametersside: Which side's gripper to control; options:
- LEFT: Left hand
- RIGHT: Right hand
- BOTH: Both hands (default)
Return Valuetrue: Control succeeded
false: Control failed
RemarksAfter calling, you can use wait_for_finish() to wait for the action to complete
Function Nameclose
Function Prototypebool close(EndEffectorSide side = EndEffectorSide.BOTH)
Functional OverviewCloses the gripper.
Parametersside: Which side's gripper to control; options are the same as open
Return Valuetrue: Control succeeded
false: Control failed
RemarksAfter calling, you can use wait_for_finish() to wait for the action to complete
Function Namecontrol
Function Prototypebool control(list target_positions, list target_velocities = None, list target_torques = None)
Functional OverviewControls the position, velocity, and torque of the gripper.
Parameterstarget_positions: List of target positions, length 2 (one value for each hand), range [0.0 ~ 100.0]
target_velocities: List of target velocities, length 2; if None, the default [90, 90] is used
target_torques: List of target torques, length 2; if None, the default [1.0, 1.0] is used
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. After calling, you can use wait_for_finish() to wait for the action to complete
2. If the gripper is still executing the previous action, the new request may be discarded
Function Namecontrol_left
Function Prototypebool control_left(list target_positions, list target_velocities = None, list target_torques = None)
Functional OverviewControls the position, velocity, and torque of the left gripper.
Parameterstarget_positions: List of target positions, length 1, range [0.0 ~ 100.0]
target_velocities: List of target velocities, length 1; if None, the default 90 is used
target_torques: List of target torques, length 1; if None, the default 1.0 is used
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. After calling, you can use wait_for_finish() to wait for the action to complete
2. If the gripper is still executing the previous action, the new request may be discarded
Function Namecontrol_right
Function Prototypebool control_right(list target_positions, list target_velocities = None, list target_torques = None)
Functional OverviewControls the position, velocity, and torque of the right gripper.
Parameterstarget_positions: List of target positions, length 1, range [0.0 ~ 100.0]
target_velocities: List of target velocities, length 1; if None, the default 90 is used
target_torques: List of target torques, length 1; if None, the default 1.0 is used
Return Valuetrue: Control succeeded
false: Control failed
Remarks1. After calling, you can use wait_for_finish() to wait for the action to complete
2. If the gripper is still executing the previous action, the new request may be discarded

DexterousHand Interface

The DexterousHand class provides the following main interfaces:

Function Namecontrol
Function Prototypebool control(list target_positions, list target_velocities = None, list target_torques = None)
Functional 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
RemarksOnly position control is supported
Function Namecontrol_left
--------------------
Function Prototypebool control_left(list target_positions, list target_velocities = None, list target_torques = None)
Functional 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)
Functional 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)
Functional OverviewControls the dexterous hand to make 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: /home/lab/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 through the SDK to achieve up-and-down and left-and-right head movements.

The example code demonstrates two motion modes:

  1. Head nodding up and down:

    • Starts at 0 degrees, first rotates down to -25 degrees
    • Then rotates up from -25 degrees to 25 degrees
    • Finally returns from 25 degrees to 0 degrees
    • Repeated for 2 cycles
  2. Head shaking left and right:

    • Starts at 0 degrees, first rotates left to 60 degrees
    • Then rotates right from 60 degrees to -60 degrees
    • Finally returns from -60 degrees to 0 degrees
    • Repeated for 2 cycles

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


Arm control: /home/lab/kuavo-ros-opensource/src/kuavo_humanoid_websocket_sdk/examples/atomic_skills/ctrl_arm_example.py

Shows examples of arm trajectory control and target pose control.

It covers 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

    • Starts from the initial position q0 and moves to the target position q1 through 90 interpolation steps
    • q1 defines a pose with the right arm raised 50 degrees
    • 0.02 seconds between each step for a smooth transition
    • Returns to the initial position after the motion completes
    • Finally resets the arm position
  2. control_arm_joint_trajectory(): Joint trajectory control

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

    • Directly specifies the target position and orientation of the left and right end effectors in the world coordinate system
    • Automatically computes the required joint angles via inverse kinematics
    • The robot automatically plans a trajectory to reach the target pose
    • Resets the arm position when done

Gripper control: /home/lab/kuavo-ros-opensource/src/kuavo_humanoid_websocket_sdk/examples/atomic_skills/lejuclaw_example.py

Demonstrates how to control the LejuClaw gripper end effector, including position, velocity, and torque control.

It supports various operations such as overall open/close, single-side control, and target position setting, implemented through interfaces such as claw.open(), claw.close(), claw.control_left(), claw.control_right(), and claw.control().

The example code demonstrates the following main functions:

  1. Basic open/close control:

    • claw.close() fully closes the gripper
    • claw.open() fully opens the gripper
    • After each action, use wait_for_finish() to wait for the action to complete
  2. Single-side gripper control:

    • claw.control_left([50]) controls the left gripper to the 50-degree position
    • claw.control_right([80]) controls the right gripper to the 80-degree position
    • The positions of the left and right grippers can be precisely controlled separately
  3. Dual-side synchronous control:

    • claw.control([20, 100]) controls the left and right grippers to different positions simultaneously
    • The first parameter controls the left side, the second parameter controls the right side
    • The position range is 0-100 degrees; 0 means fully closed, 100 means fully open

Notes:

  • It is recommended to call wait_for_finish() after each action to wait for completion and avoid stacking actions
  • A timeout can be set, e.g. wait_for_finish(timeout=2.0)
  • When sending commands consecutively, be sure to wait for the previous action to complete, otherwise they may be discarded

Dexterous hand control: /home/lab/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, dual-side synchronous control, preset gesture invocation, and other functions. The example code demonstrates:

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