Kuavo Docs
Development Interfaces

ROS1 Interface Usage Documentation

SDK Overview

This SDK provides a series of interfaces for controlling the robot and obtaining robot status, mainly divided into two categories: topics and services. These interfaces are based on the ROS (Robot Operating System) framework and provide Python examples for development and invocation. The following is an overview of the SDK's main features:

Topic

Topics are used to publish and subscribe to robot sensor data and control commands. Through topics, users can obtain raw robot sensor data in real time, such as IMU data, point cloud data, image data, etc., and can also publish control commands to control the robot's motion and posture.

  • Sensor data: Obtain raw robot sensor data through topics, including IMU data, point cloud data, image data, etc.
  • Motion control: Publish control commands through topics to specify the robot's motion trajectory, velocity, and posture.

Service

Services are used to execute specific control commands or obtain status information. Service calls are synchronous, meaning the user sends a request and then waits for the service to return a response. Services are typically used to perform one-off operations, such as playing music, recording audio, setting control modes, etc.

  • Control commands: Send control commands through service interfaces, such as playing music, recording audio, setting arm control modes, etc.
  • Status retrieval: Obtain robot status information through service interfaces.

Usage Guide

  1. Initialize the ROS node: Before using the SDK, you need to initialize a ROS node. You can use the rospy.init_node() method to complete node initialization.

  2. Create topic subscribers or publishers: Create topic subscribers or publishers as needed. Subscribers are used to receive topic data, and publishers are used to send control commands.

  3. Create a service proxy: For services that need to be called, create a service proxy object, and send requests and receive responses through this object.

  4. Process data or responses: After receiving topic data or service responses, perform the corresponding processing or operations.

/get_used_audio_buffer_size Get the audio playback buffer size

  1. Function Description

Query the number of bytes remaining in the current audio ring buffer.

  1. Request Format
  • Type: std_srvs/Trigger
  1. Response Format
  • Type: std_srvs/TriggerResponse
  • Fields:
    • success (bool): Indicates whether the request succeeded.
    • message (str): The number of bytes remaining in the current buffer.

/play_music Play audio

  1. Function Description

Play the specified audio file, appending it to the buffer for playback in queue order without interrupting the current playback.

  1. Request Format
  • Type: kuavo_msgs/playmusic
  • Fields:
    • music_number (str): Audio file name; the file must be located in the directory specified by music_path.
    • volume (int): Volume 0–100. 100 is the original sound, 0 is near mute, and intermediate values are scaled logarithmically in dB.
  1. Response Format
  • Type: playmusicResponse
  • Fields:
    • success_flag (bool): Whether the request succeeded.
  1. Usage Example
import rospy
from kuavo_msgs.srv import playmusic, playmusicRequest

rospy.init_node('music_player_client')
client = rospy.ServiceProxy("/play_music", playmusic)

req = playmusicRequest()
req.music_number = "1_挥手.mp3"
req.volume = 80
client(req)

/play_music_immediate Interrupt and play immediately

  1. Function Description

An atomic "stop current playback + immediately play the new file": first synchronously stop all current audio, then load and play the specified file.

  1. Request Format
  • Type: kuavo_msgs/PlayMusicImmediate
  • Fields: Same as /play_music (music_number, volume).
  1. Response Format
  • Fields:
    • success_flag (bool): Whether the request succeeded.
  1. Usage Example
rosservice call /play_music_immediate "music_number: '1_挥手.mp3'
volume: 80"

/stop_music Stop playback

  1. Function Description

Immediately stop all current audio; playback is muted by the time the call returns.

  1. Request Format
  • Type: std_srvs/Trigger
  1. Response Format
  • Type: std_srvs/TriggerResponse
  • Fields:
    • success (bool): Indicates whether the request succeeded.
    • message (str): Stop result information.
  1. Usage Example
rosservice call /stop_music

Compatibility entry point: publishing to the topic /stop_music with the same name (std_msgs/Bool, True triggers the stop) can also stop playback, but it does not return a result; using the service is recommended. Note: stop requests arriving via the topic within 0.3 seconds after /play_music / /play_music_immediate plays successfully are discarded (to prevent the "stop-before-play" timing inversion); use the service for reliable stopping.


/record_music Record audio

  1. Function Description

The /record_music service is used to control the robot in recording the specified music file. Users can record audio by providing the number of the music file and a timeout.

  1. Request Format
  • Type: recordmusicRequest
  • Fields:
    • music_number (str): The number of the music file. Used to identify the music file to record.
    • time_out (int): Timeout in seconds. Specifies the maximum duration of the recording operation.
  1. Response Format
  • Type: recordmusicResponse
  • Fields:
    • success_flag (bool): Indicates whether the music recording request succeeded. True means success, False means failure.
  1. Usage Example
import rospy
from kuavo_msgs.srv import recordmusic, recordmusicRequest

# 初始化 ROS 节点
rospy.init_node('music_recorder')

# 创建服务代理
robot_record_music_client = rospy.ServiceProxy("/record_music", recordmusic)

# 创建请求对象
request = recordmusicRequest()
request.music_number = "example_music"  # 音乐文件编号
request.time_out = 30  # 超时时间

# 调用服务并获取响应
response = robot_record_music_client(request)

/livox/imu Lidar IMU data

Refer to Lidar Startup to start the lidar node.

  1. Function Description

The /livox/imu topic provides the lidar's built-in IMU (Inertial Measurement Unit) information, including linear acceleration and angular velocity.

  1. Message Type
  • Type: sensor_msgs/Imu
  1. Message Fields
  • Header: Message header information

    • seq (uint32): Sequence number
    • stamp (time): Timestamp
    • frame_id (string): Coordinate frame ID
  • orientation: Orientation quaternion

    • x, y, z, w (float64): Quaternion components
  • orientation_covariance: Orientation covariance matrix (float64[9])

  • angular_velocity: Angular velocity

    • x, y, z (float64): Angular velocity components
  • angular_velocity_covariance: Angular velocity covariance matrix (float64[9])

  • linear_acceleration: Linear acceleration

    • x, y, z (float64): Acceleration components
  • linear_acceleration_covariance: Acceleration covariance matrix (float64[9])

  1. Usage Example
import rospy
from sensor_msgs.msg import Imu

def imu_callback(data):
    rospy.loginfo("Received IMU data: %s", data)

rospy.init_node('imu_listener')
rospy.Subscriber("/livox/imu", Imu, imu_callback)
rospy.spin()

/livox/lidar Lidar point cloud data

Refer to Lidar Startup to start the lidar node.

  1. Function Description

The /livox/lidar topic provides the lidar's point cloud data, used for point cloud representation in three-dimensional space.

  1. Message Type
  • Type: sensor_msgs/PointCloud2
  1. Message Fields
  • Header: Message header information

    • seq (uint32): Sequence number
    • stamp (time): Timestamp
    • frame_id (string): Coordinate frame ID
  • height (uint32): Height of the point cloud (usually 1)

  • width (uint32): Width of the point cloud (number of points)

  • fields: Point field information

    • name (string): Field name
    • offset (uint32): Field offset
    • datatype (uint8): Data type
    • count (uint32): Field count
  • is_bigendian (bool): Whether the data is big-endian

  • point_step (uint32): Number of bytes per point

  • row_step (uint32): Number of bytes per row

  • data (uint8[]): Point cloud data

  • is_dense (bool): Whether the point cloud is dense

  1. Usage Example
import rospy
from sensor_msgs.msg import PointCloud2

def lidar_callback(data):
    rospy.loginfo("Received LIDAR data: %s", data)

rospy.init_node('lidar_listener')
rospy.Subscriber("/livox/lidar", PointCloud2, lidar_callback)
rospy.spin()

/camera/depth/color/points Camera point cloud data

  1. Function Description

The /camera/depth/color/points topic provides the camera's point cloud data, combining depth information and color information, used for point cloud representation in three-dimensional space.

  1. Message Type
  • Type: sensor_msgs/PointCloud2
  1. Message Fields
  • Header: Message header information

    • seq (uint32): Sequence number
    • stamp (time): Timestamp
    • frame_id (string): Coordinate frame ID
  • height (uint32): Height of the point cloud (usually 1)

  • width (uint32): Width of the point cloud (number of points)

  • fields: Point field information

    • name (string): Field name
    • offset (uint32): Field offset
    • datatype (uint8): Data type
    • count (uint32): Field count
  • is_bigendian (bool): Whether the data is big-endian

  • point_step (uint32): Number of bytes per point

  • row_step (uint32): Number of bytes per row

  • data (uint8[]): Point cloud data

  • is_dense (bool): Whether the point cloud is dense

  1. Usage Example
import rospy
from sensor_msgs.msg import PointCloud2

def points_callback(data):
    rospy.loginfo("Received point cloud data")

rospy.init_node('points_listener')
rospy.Subscriber("/camera/depth/color/points", PointCloud2, points_callback)
rospy.spin()

/camera/color/image_raw Camera Color Image Data

  1. Function Description

The /camera/color/image_raw topic provides the camera's raw color image data.

  1. Message Type
  • Type: sensor_msgs/Image
  1. Message Fields
  • Header: Message header information

    • seq (uint32): Sequence number
    • stamp (time): Timestamp
    • frame_id (string): Coordinate frame ID
  • height (uint32): Image height

  • width (uint32): Image width

  • encoding (string): Image encoding format (e.g., rgb8)

  • is_bigendian (uint8): Whether the data is big-endian

  • step (uint32): Number of bytes per row

  • data (uint8[]): Image data

  1. Usage Example
import rospy
from sensor_msgs.msg import Image

def image_callback(data):
    rospy.loginfo("Received raw image data")

rospy.init_node('image_listener')
rospy.Subscriber("/camera/color/image_raw", Image, image_callback)
rospy.spin()

/camera/depth/image_rect_raw Camera Depth Image Data

  1. Function Description

The /camera/depth/image_rect_raw topic provides the camera's depth image data, rectified to remove distortion.

  1. Message Type
  • Type: sensor_msgs/Image
  1. Message Fields
  • Header: Message header information

    • seq (uint32): Sequence number
    • stamp (time): Timestamp
    • frame_id (string): Coordinate frame ID
  • height (uint32): Image height

  • width (uint32): Image width

  • encoding (string): Image encoding format (e.g., 16UC1)

  • is_bigendian (uint8): Whether the data is big-endian

  • step (uint32): Number of bytes per row

  • data (uint8[]): Image data

  1. Usage Example
import rospy
from sensor_msgs.msg import Image

def depth_image_callback(data):
    rospy.loginfo("Received depth image data")

rospy.init_node('depth_image_listener')
rospy.Subscriber("/camera/depth/image_rect_raw", Image, depth_image_callback)
rospy.spin()

/arm_traj_change_mode Set Arm Control Mode

  1. Function Description

The /arm_traj_change_mode service is used to set the control mode of the OCS2 arm. Users can change how the arm operates by providing a control mode number.

Control modes include:

  • 0: keep pose
  • 1: auto_swing_arm (automatic arm swing while walking)
  • 2: external_control
  1. Request Format
  • Type: changeArmCtrlModeRequest

  • Fields:

    • control_mode (int): The control mode number to set. Valid values are 0, 1, or 2.
  1. Response Format
  • Type: changeArmCtrlModeResponse

  • Fields:

    • result (bool): Indicates whether the control mode change request succeeded. True means success, False means failure.
    • message (str): A message containing detailed information about the operation result.
  1. Usage Example
import rospy
from kuavo_msgs.srv import changeArmCtrlMode, changeArmCtrlModeRequest, changeArmCtrlModeResponse

# 初始化 ROS 节点
rospy.init_node('arm_control_mode_client')

# 创建服务代理
arm_traj_change_mode_client = rospy.ServiceProxy("/arm_traj_change_mode", changeArmCtrlMode)

# 创建请求对象
request = changeArmCtrlModeRequest()
request.control_mode = 2  # 设置控制模式

# 调用服务并获取响应
response = arm_traj_change_mode_client(request)

/kuavo_arm_target_poses Arm Motion Control (Reach Target Pose Within a Specified Time)

  1. Function Description

The /kuavo_arm_target_poses topic is used to publish arm target pose information, including time and joint angles. This topic can be used to control the arm so that it moves to a specified pose.

  1. Message Type
  • Type: kuavo_msgs/armTargetPoses
  1. Message Fields
  • times (list of float): A list of times indicating the target time point for each pose.
  • values (list of float): A list of joint angles indicating the target joint angles of the arm at each time point.
  1. Usage Example
import rospy
from kuavo_msgs.msg import armTargetPoses

# 初始化ROS节点
rospy.init_node('arm_target_poses_publisher')

# 创建发布者
pub = rospy.Publisher('kuavo_arm_target_poses', armTargetPoses, queue_size=10)

# 创建消息对象
msg = armTargetPoses()
msg.times = [3]  # 时间列表
msg.values = [-20, 0, 0, -30, 0, 0, 0, 20, 0, 0, -30, 0, 0, 0]  # 关节角度列表

# 发布消息
pub.publish(msg)

/kuavo_arm_traj Arm Motion Control (for Custom Arm Motion Trajectory Planning)

  1. Function Description

The /kuavo_arm_traj topic is used to control the robot arm's motion, achieving precise arm control by publishing target joint positions.

  1. Message Type
  • Type: sensor_msgs/JointState
  1. Message Fields
  • name (list of string): List of joint names. Assuming there are 14 joints, named "arm_joint_1" through "arm_joint_14".
  • position (list of float): List of current joint positions.
  • header.stamp (time): Timestamp of the message, set to the current time.
  1. Usage Example
import rospy
from sensor_msgs.msg import JointState
import numpy as np

# 初始化ROS节点
rospy.init_node('sim_traj')

# 创建发布者
pub = rospy.Publisher("/kuavo_arm_traj", JointState, queue_size=10)

# 等待直到有订阅者连接
while pub.get_num_connections() == 0:
    rospy.sleep(0.1)  # 适当的睡眠时间,避免 CPU 占用过高

msg = JointState()
msg.name = ["arm_joint_" + str(i) for i in range(1, 15)]  # 关节名称列表
msg.header.stamp = rospy.Time.now()  # 当前时间戳
msg.position = np.array([-30, 60, 0, -30, 0, -30, 30, 0, 0, 0, 0, 0, 0, 0])  # 关节位置列表

# 发布消息
pub.publish(msg)

/robot_head_motion_data Head Joint Control

  1. Function Description

The /robot_head_motion_data topic is used to publish the robot head's target motion data, including yaw and pitch angles. This topic can be used to control the robot's head motion.

  1. Message Type
  • Type: kuavo_msgs/robotHeadMotionData
  1. Message Fields
  • joint_data (list of float): A list containing the head yaw and pitch angles. The yaw angle range is [-88, 88] degrees, and the pitch angle range is [-25, 25] degrees.
  1. Note

This topic sends absolute target angles. The remote controller (H12/G12) has switched to the velocity interface /cmd_head_vel and no longer controls the head through this topic; this topic is retained for scenarios such as SDK/VR that require direct angle control.

Usage Example

import rospy
from kuavo_msgs.msg import robotHeadMotionData

# 初始化ROS节点
rospy.init_node('robot_head_controller')

# 创建发布者
pub_head_pose = rospy.Publisher('/robot_head_motion_data', robotHeadMotionData, queue_size=10)

# 创建消息对象
head_target_msg = robotHeadMotionData()
head_target_msg.joint_data = [0, 0]  # 偏航角和俯仰角

# 发布消息
pub_head_pose.publish(head_target_msg)

/cmd_head_vel Head Joint Angular Velocity Control

  1. Function Description

The /cmd_head_vel topic is used to control the robot's head motion by publishing an instantaneous angular velocity (deg/s). The receiving side (CDM/WBC) performs sticky integration: while non-zero velocity is continuously received, the angle accumulates; it stops when zero velocity is received or after a 0.3s timeout.

  1. Message Type
  • Type: kuavo_msgs/robotHeadMotionData
  1. Message Fields
  • joint_data (list of float): Length 2.
  • joint_data[0]: Yaw angular velocity (yaw), deg/s.
  • joint_data[1]: Pitch angular velocity (pitch), deg/s.
  1. Usage Example
import rospy
from kuavo_msgs.msg import robotHeadMotionData

pub = rospy.Publisher('/cmd_head_vel', robotHeadMotionData, queue_size=1)
msg = robotHeadMotionData()
msg.joint_data = [30.0, 0.0]  # yaw 30°/s 右转
pub.publish(msg)
# 停止:
msg.joint_data = [0.0, 0.0]
pub.publish(msg)

/cmd_head_delta Head Joint Incremental Control

  1. Function Description

The /cmd_head_delta topic is used to send a one-time relative displacement (deg). Oneshot semantics: the increment in each message is consumed once and then reset to zero.

  1. Message Type
  • Type: kuavo_msgs/robotHeadMotionData
  1. Message Fields
  • joint_data (list of float): Length 2.
  • joint_data[0]: Yaw increment (yaw), deg.
  • joint_data[1]: Pitch increment (pitch), deg.

/control_robot_hand_position Dexterous Hand Control

  1. Function Description

The /control_robot_hand_position topic is used to control the motion of the robot's hands (fingers), achieving precise hand control by publishing target finger joint positions.

  • Prerequisite: This topic is published only when EndEffectorType is configured as qiangnao in kuavo.json.
  1. Topic Type
  • Type: kuavo_msgs/robotHandPosition
  1. Message Fields
  • left_hand_position (list of float): Left hand position, containing 6 elements, each ranging from [0, 100], where 0 is open and 100 is closed.
  • right_hand_position (list of float): Right hand position, containing 6 elements, each ranging from [0, 100], where 0 is open and 100 is closed.
  1. Usage Example
import rospy
from kuavo_msgs.msg import robotHandPosition

# 初始化ROS节点
rospy.init_node('robot_hand_controller')

# 初始化话题发布者
pub = rospy.Publisher('/control_robot_hand_position', robotHandPosition, queue_size=10)

# 创建消息对象
msg = robotHandPosition()
msg.left_hand_position = [0, 0, 0, 0, 0, 0]  # 左手位置
msg.right_hand_position = [20, 20, 20, 20, 20, 20]  # 右手位置

# 发布消息
pub.publish(msg)

/cmd_pose Position Control

  1. Function Description

The /cmd_pose topic is used to publish control commands that specify the robot's linear and angular velocities in space.

  1. Message Type
  • Type: geometry_msgs/Twist
  1. Message Fields
  • linear.x (float): x-direction value based on the current position, in meters (m).
  • linear.y (float): y-direction value based on the current position, in meters (m).
  • linear.z (float): Incremental height (m).
  • angular.x (float): Not used, set to 0.
  • angular.y (float): Not used, set to 0.
  • angular.z (float): Rotation (yaw) angle based on the current position, in radians (radian).
  1. Usage Example
import rospy
from geometry_msgs.msg import Twist

# 初始化ROS节点
rospy.init_node('cmd_pose_publisher')

# 创建发布者
cmd_pose_pub = rospy.Publisher('/cmd_pose', Twist, queue_size=10)

# 创建Twist消息对象
cmd_pose_msg = Twist()
cmd_pose_msg.linear.x = 0.5  # 基于当前位置的 x 方向值 (m)
cmd_pose_msg.linear.y = 0.0  # 基于当前位置的 y 方向值 (m)
cmd_pose_msg.linear.z = 0.0  # 增量高度
cmd_pose_msg.angular.z = 0.0  # # 基于当前位置旋转(偏航)的角度,单位为弧度 (radian)

# 发布消息
cmd_pose_pub.publish(cmd_pose_msg)

/cmd_vel Velocity Control

  1. Function Description

The /cmd_vel topic is used to publish control commands that specify the robot's linear and angular velocities in space.

  1. Message Type
  • Type: geometry_msgs/Twist
  1. Message Fields
  • linear.x (float): Linear velocity in the x direction (m/s).
  • linear.y (float): Linear velocity in the y direction (m/s).
  • linear.z (float): Incremental height (m).
  • angular.x (float): Not used, set to 0.
  • angular.y (float): Not used, set to 0.
  • angular.z (float): Angular velocity in the yaw direction (radian/s).
  1. Usage Example
import rospy
from geometry_msgs.msg import Twist

# 初始化ROS节点
rospy.init_node('cmd_vel_publisher')

# 创建发布者
cmd_vel_pub = rospy.Publisher('/cmd_vel', Twist, queue_size=10)

# 设置发布频率
rate = rospy.Rate(10)  # 10 Hz

# 创建Twist消息对象
cmd_vel_msg = Twist()
cmd_vel_msg.linear.x = 0.2  # x 方向速度
cmd_vel_msg.linear.y = 0.0  # y 方向速度
cmd_vel_msg.linear.z = 0.0  # 增量高度
cmd_vel_msg.angular.z = 0.0  # yaw 方向角速度

while not rospy.is_shutdown():
    # 发布消息
    cmd_vel_pub.publish(cmd_vel_msg)
    # 等待下一个发布周期
    rate.sleep()

/humanoid_controller/real_initial_start Make the Robot Stand Up

  1. Function Description

The /humanoid_controller/real_initial_start service is used to trigger the robot's initialization process: while the robot is in the cali state, the robot retracts its legs once and then stands up once. During the standing process, the user must hold the robot with their hands to ensure safety. This service is available only on the physical robot.

VR Teleoperation Note (QuestControlFSM): Before the MPC observation has been subscribed, the controller side triggers this service by long-pressing the right-hand A button for about 0.35 seconds, which is equivalent to pressing o in the lower-level controller terminal. A short press easily triggers it accidentally when VR has just connected; see kuavodevlab#2995. Once observation data is received, this long-press logic no longer occupies the rising edge of the A button.

  1. Service Type
  • Type: std_srvs/Trigger
  1. Request Message
  • No request parameters are required.
  1. Response Message
  • success (bool): Result of the service call; returns True on success and False on failure.
  • message (string): Response message of the service call, providing detailed information about the success or failure.
  1. Usage Example
import rospy
from std_srvs.srv import Trigger

# 初始化ROS节点
rospy.init_node('init_trigger_service_caller')

# 创建服务代理
trigger_init_service = rospy.ServiceProxy('/humanoid_controller/real_initial_start', Trigger)

# 调用服务并获取响应
response = trigger_init_service()

/sensors_data_raw Sensor Data

  1. Function Description

The /sensors_data_raw topic publishes raw sensor data from the physical robot or the simulator, including joint data, IMU data, and end-effector data.

  1. Message Type
  • Type: kuavo_msgs/sensorsData
  1. Message Fields
FieldTypeDescription
sensor_timetimeTimestamp
joint_datakuavo_msgs/jointDataJoint data: position, velocity, acceleration, current
imu_datakuavo_msgs/imuDataContains gyroscope, accelerometer, free acceleration, and quaternion
end_effector_datakuavo_msgs/endEffectorDataEnd-effector data, not used yet
  1. Joint Data Description
  • Array length: NUM_JOINT

  • Data order:

    • The first 12 entries are lower-limb motor data:
      • 0~5 are left lower-limb data (l_leg_roll, l_leg_yaw, l_leg_pitch, l_knee, l_foot_pitch, l_foot_roll)
      • 6~11 are right lower-limb data (r_leg_roll, r_leg_yaw, r_leg_pitch, r_knee, r_foot_pitch, r_foot_roll)
    • The next 14 entries are arm motor data:
      • 12~18 are left arm motor data ("l_arm_pitch", "l_arm_roll", "l_arm_yaw", "l_forearm_pitch", "l_hand_yaw", "l_hand_pitch", "l_hand_roll")
      • 19~25 are right arm motor data ("r_arm_pitch", "r_arm_roll", "r_arm_yaw", "r_forearm_pitch", "r_hand_yaw", "r_hand_pitch", "r_hand_roll")
    • The last 2 entries are head motor data: head_yaw and head_pitch
  • Units:

    • Position: radians (radian)
    • Velocity: radians per second (radian/s)
    • Acceleration: radians per second squared (radian/s²)
    • Current: amperes (A)
  1. IMU Data Description
  • gyro: Angular velocity of the gyroscope, in radians per second (rad/s)
  • acc: Acceleration of the accelerometer, in meters per second squared (m/s²)
  • quat: IMU orientation

  1. Usage Example
import rospy
from kuavo_msgs.msg import sensorsData

def callback(data):
    rospy.loginfo(f"Received sensor data at time: {data.sensor_time}")

# 初始化ROS节点
rospy.init_node('sensor_data_listener')

# 订阅传感器数据话题
rospy.Subscriber('/sensors_data_raw', sensorsData, callback)

# 保持节点运行
rospy.spin()

/ik/fk_srv Robot Arm FK (Forward Kinematics)

  1. Service Description

The /if/fk_srv service is used for robot arm FK (forward kinematics).

  1. Request Format
  • Type: kuavo_msgs/fkSrv
  • Fields:
FieldTypeDescription
qfloat64[]Length 14; contains the arm joint angles, in radians
  1. Response Format
  • Type: kuavo_msgs/fkSrv
  • Fields:
FieldTypeDescription
successboolReturn parameter, whether the operation succeeded
hand_posestwoArmHandPoseReturn parameter, the FK result; see the message of the same type above for details
  1. Usage Example
import rospy
from kuavo_msgs.srv import fkSrv

# 初始化 ROS 节点
rospy.init_node('example_fk_srv_node')

# 创建服务代理
fk_srv = rospy.ServiceProxy('/ik/fk_srv', fkSrv)

# 创建请求对象(单位:弧度)
joint_angles = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.38, -1.39, -0.29, -0.43, 0.0, -0.17, 0.0]

# 发送请求并接收响应
response = fk_srv(joint_angles)

/ik/two_arm_hand_pose_cmd_srv Robot Arm IK (Inverse Kinematics)

  1. Service Description

The /ik/two_arm_hand_pose_cmd_srv service is used for robot arm IK (inverse kinematics).

  1. Request Format
  • Type: twoArmHandPoseCmd
  • Fields: twoArmHandPoseCmdRequest
FieldTypeDescription
hand_posestwoArmHandPoseBoth-hand 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 the joint_angles in hand_poses as the q0 for solving
ik_paramikSolveParamCustom IK solving parameters

The ik_param field is described in detail below:

FieldTypeDescription
major_optimality_tolfloat64snopt parameter, i.e., the optimality tolerance in the major iterations; this parameter determines how well the optimality conditions are satisfied
major_feasibility_tolfloat64snopt parameter, i.e., the feasibility tolerance in the major iterations, used to control nonlinear constraints
minor_feasibility_tolfloat64snopt parameter, the feasibility tolerance in the 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 takes effect only 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
constraint_modeuint8Solving mode bitmask (2-bit + extensible): bit1=position hard(1)/soft(0), bit0=orientation hard(1)/soft(0), bit2=three-point position mode(1)/traditional pose mode(0). Note: in the current implementation, 00/01 in traditional mode are swapped internally: external 0(00) -> internally treated as "position soft + orientation hard"; external 1(01) -> internally treated as "position soft + orientation soft"; external 2/3 are unchanged.

The hand_poses field is described in detail below:

FieldTypeDescription
pos_xyzfloat64[3]Desired end-effector position, in 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 the q0 for solving, in radians
  1. Response Format
FieldTypeDescription
successboolWhether the operation succeeded
with_torsoboolWhether the torso is included
q_armfloat64[]Arm joint values, in radians
q_torsofloat64[]Torso joint values
time_costfloat64Solving time, in ms
error_reasonstringError reason description (usually an empty string on success; contains the failure reason/debug information on failure)
hand_posestwoArmHandPoseIK solving result; see the message of the same type above for details
  1. Usage Example
import rospy
from kuavo_msgs.msg import twoArmHandPoseCmd, ikSolveParam
from kuavo_msgs.srv import twoArmHandPoseCmdSrv

# 初始化 ROS 节点
rospy.init_node('example_ik_srv_node')

# 创建服务代理
ik_srv = rospy.ServiceProxy('two_arm_hand_pose_cmd_srv', twoArmHandPoseCmdSrv)

# 使用默认参数
use_custom_ik_param = False
joint_angles_as_q0 = False

# 创建请求对象
request = twoArmHandPoseCmd()
request.use_custom_ik_param = use_custom_ik_param
request.joint_angles_as_q0 = joint_angles_as_q0

# 设置左手末端执行器的位置和姿态
request.hand_poses.left_pose.pos_xyz =  np.array([0.45,0.25,0.11988012])
request.hand_poses.left_pose.quat_xyzw = [0.0,-0.70682518,0.0,0.70738827] # 四元数
request.hand_poses.left_pose.elbow_pos_xyz = np.zeros(3) # 设置成 0.0 时,不会被使用

# 设置右手末端执行器的位置和姿态
request.hand_poses.right_pose.pos_xyz =  np.array([0.45,-0.25,0.11988012])
request.hand_poses.right_pose.quat_xyzw = [0.0,-0.70682518,0.0,0.70738827] # 四元数
request.hand_poses.right_pose.elbow_pos_xyz = np.zeros(3)  # 设置成 0.0 时,不会被使用

# 发送请求并接收响应
response = ik_srv(request)

/ik/two_arm_hand_pose_cmd_srv_muli_refer Robot Arm IK (Multi-Reference / Multi-Seed)

  1. Service Description

The /ik/two_arm_hand_pose_cmd_srv_muli_refer service is used for robot arm IK. Its request format is exactly the same as that of /ik/two_arm_hand_pose_cmd_srv, but internally it uses multiple reference q0 values (seeds) to improve the success rate and stability (especially when the orientation/position requirements are strict, or when the current joint pose is far from the target).

  1. Request Format
  • Type: twoArmHandPoseCmd
  • Fields: twoArmHandPoseCmdRequest
  • The field descriptions are the same as those of /ik/two_arm_hand_pose_cmd_srv (including hand_poses / use_custom_ik_param / joint_angles_as_q0 / ik_param).
  1. Response Format
  • Type: kuavo_msgs/twoArmHandPoseCmdSrv
  • The field descriptions are the same as those of /ik/two_arm_hand_pose_cmd_srv.
  • Additional note: On success, error_reason usually contains the name of the reference seed used for this successful solve (e.g., pinv / analytic / midpoint / user_q0 / last_valid), which facilitates troubleshooting and parameter tuning.
  1. Usage Recommendations
  • More robust but possibly slower: Compared with the single-seed service, this service tries multiple seeds, so it may take slightly longer, but the success rate is usually better.
  • Recommended usage: When you find that /ik/two_arm_hand_pose_cmd_srv occasionally fails in certain poses, prefer switching to this service for troubleshooting and deployment.

/control_robot_leju_claw Control the Robot Gripper (Two-Finger Claw) Movement

  1. Service Description

The /control_robot_leju_claw service is used to control the robot gripper (two-finger claw).

  • Prerequisite: This service is only started when EndEffectorType is configured as lejuclaw in kuavo.json. The path of the configuration file kuavo.json is kuavo-ros-control/src/kuavo_assets/config/kuavo_v$ROBOT_VERSION/kuavo.json. Note that you must modify the configuration file corresponding to the robot model.
  1. Service Message Type
  • kuavo_msgs/controlLejuClaw
  1. Request Format
FieldTypeDescription
datakuavo_msgs/endEffectorDataRequest data, gripper-related message

Regarding the data field, the message definition of kuavo_msgs/endEffectorData is as follows:

FieldTypeDescription
namestring[]Required, array length is 2, the data is "left_claw", "right_claw"
positionfloat64[]Required, array length is 2, target position value of the gripper, range 0 ~ 100, representing the percentage of travel, 0 is open, 100 is closed
velocityfloat64[]Optional, array length is 2, target velocity value of the gripper, 0 ~ 100, defaults to 50 when not specified
effortfloat64[]Optional, array length is 2, target current of the gripper, unit A, defaults to 1.0A when not specified
  • name: Note that the name can only be set to "left_claw" or "right_claw"

  • position: range 0 ~ 100, representing the percentage of travel, 0 is open, 100 is closed

  • velocity : velocity, default 50,

  • effort : torque, the motor will not output a current greater than this value; if it is set too small, the motion performance may be limited, 1A~2A is recommended), default 1.0 A.

  1. Response Format
FieldTypeDescription
successboolReturned data, whether the call succeeded
messagestringReturned data, message
  1. Usage Example
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import rospy
from kuavo_msgs.srv import controlLejuClaw, controlLejuClawRequest, controlLejuClawResponse

if __name__ == '__main__':
    # 初始化ROS节点
    rospy.init_node('leju_claw_client_node')
    
    # 创建请求对象
    req = controlLejuClawRequest()
    req.data.name = ['left_claw', 'right_claw']
    req.data.position = [90, 90]
    req.data.velocity = [50, 50]
    req.data.effort = [1.0, 1.0]
    
    #确保服务启动
    rospy.wait_for_service('/control_robot_leju_claw')
    #调用服务并获取响应
    control_leju_claw = rospy.ServiceProxy('/control_robot_leju_claw', controlLejuClaw)
    res = control_leju_claw(req)

/leju_claw_state Get the Robot Gripper (Two-Finger Claw) Status

  1. Service Description

The /leju_claw_state topic is used to publish the status, position, velocity, torque, and other information of the robot gripper (two-finger claw). Prerequisite: This topic is only published when EndEffectorType is configured as lejuclaw in kuavo.json. The modification method is described in the /control_robot_leju_claw section.

  1. Service Message Type
  • kuavo_msgs/lejuClawState
  1. Message Fields
FieldTypeDescription
stateint8[]Status of the two-finger gripper, array length is 2, the first is the left gripper and the second is the right gripper
datakuavo_msgs/endEffectorDataPosition, velocity, torque, and other information of the two-finger gripper

Meanings of the state values:

  • -1 : Error, indicates an error occurred during execution,
  • 0 : Unknown, the default state at initialization,
  • 1 : Moving, indicates the gripper is executing and moving,
  • 2 : Reached, indicates the gripper has reached the expected position,
  • 3 : Grabbed, indicates the gripper has grabbed an object.

The kuavo_msgs/endEffectorData message in the data field is described in the /control_robot_leju_claw section.

  1. Usage Example:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import rospy
from kuavo_msgs.msg import lejuClawState

# 定义回调函数
def leju_calw_state_callback(msg):
    claw_state = msg.state
    # 打印当前夹爪状态
    rospy.loginfo(f"Current claw state: left={claw_state[0]}, right={claw_state[1]}")

if __name__ == '__main__':
    # 初始化ROS节点
    rospy.init_node('leju_claw_state_node')

    # 创建订阅者,监听 /leju_claw_state 话题
    claw_state_sub = rospy.Subscriber('/leju_claw_state', lejuClawState, leju_calw_state_callback)

    # 保持节点运行
    rospy.spin()

/leju_quest_bone_poses VR Skeleton Pose Data

  1. Function Description

The /leju_quest_bone_poses topic is used to publish the skeleton pose data tracked by the Quest3 VR device, including the position and orientation information of 26 skeleton nodes.

  1. Message Type
  • Type: noitom_hi5_hand_udp_python/PoseInfoList
  1. Message Fields
  • timestamp_ms (int): timestamp
  • is_high_confidence (bool): data confidence flag
  • is_hand_tracking (bool): hand tracking status flag
  • poses (PoseInfo[]): list containing the pose data of all skeletons; each skeleton contains:
    • position (geometry_msgs/Point): skeleton position (x, y, z)
    • orientation (geometry_msgs/Quaternion): skeleton orientation quaternion (x, y, z, w)
  1. Skeleton List (26 Skeletons in Total)
[
    # 手臂
    "LeftArmUpper", "LeftArmLower",      # 左臂上部和下部
    "RightArmUpper", "RightArmLower",    # 右臂上部和下部
    
    # 手掌
    "LeftHandPalm", "RightHandPalm",     # 左右手掌
    
    # 左手指
    "LeftHandThumbMetacarpal",           # 左拇指掌骨
    "LeftHandThumbProximal",             # 左拇指近节
    "LeftHandThumbDistal",               # 左拇指远节
    "LeftHandThumbTip",                  # 左拇指指尖
    "LeftHandIndexTip",                  # 左食指指尖
    "LeftHandMiddleTip",                 # 左中指指尖
    "LeftHandRingTip",                   # 左无名指指尖
    "LeftHandLittleTip",                 # 左小指指尖
    
    # 右手指
    "RightHandThumbMetacarpal",          # 右拇指掌骨
    "RightHandThumbProximal",            # 右拇指近节
    "RightHandThumbDistal",              # 右拇指远节
    "RightHandThumbTip",                 # 右拇指指尖
    "RightHandIndexTip",                 # 右食指指尖
    "RightHandMiddleTip",                # 右中指指尖
    "RightHandRingTip",                  # 右无名指指尖
    "RightHandLittleTip",                # 右小指指尖
    
    # 躯干
    "Root", "Chest", "Neck", "Head"      # 根部、胸部、颈部、头部
]
  1. Usage Example
import rospy
from noitom_hi5_hand_udp_python.msg import PoseInfoList

def bone_poses_callback(data):
    # 处理接收到的骨骼位姿数据
    print(f"Timestamp: {data.timestamp_ms}")
    print(f"High confidence: {data.is_high_confidence}")
    print(f"Hand tracking: {data.is_hand_tracking}")
    print(f"Number of poses: {len(data.poses)}")

# 初始化ROS节点
rospy.init_node('bone_poses_listener')

# 订阅骨骼位姿数据话题
rospy.Subscriber('/leju_quest_bone_poses', PoseInfoList, bone_poses_callback)

# 保持节点运行
rospy.spin()

/dexhand/state Dexterous Hand Status

  1. Topic Description
  • Publishes the status data of the dexterous hand.
  • Prerequisite: This topic is only published when EndEffectorType is configured as qiangnao or qiangnao_touch in kuavo.json.
  1. Message Type
  • Type: sensor_msgs/JointState
  1. Message Fields
FieldTypeDescription
headerstd_msgs/HeaderMessage header, contains information such as the timestamp
namestring[]Joint name array, contains 12 joint names: ["l_thumb", "l_thumb_aux", "l_index", "l_middle", "l_ring", "l_pinky", "r_thumb", "r_thumb_aux", "r_index", "r_middle", "r_ring", "r_pinky"]
positionfloat64[]Joint position array, length 12, the first 6 are left-hand joint positions, the last 6 are right-hand joint positions
velocityfloat64[]Joint velocity array, length 12, the first 6 are left-hand joint velocities, the last 6 are right-hand joint velocities (this field is only valid when the type is qiangnao_touch)
effortfloat64[]Joint current array, length 12, the first 6 are left-hand joint currents, the last 6 are right-hand joint currents (this field is only valid when the type is qiangnao_touch)
  1. Usage Example
import rospy
from sensor_msgs.msg import JointState

# 定义回调函数
def dexhand_state_callback(msg):
    dexhand_position = msg.position
    # 打印当前灵巧手状态
    rospy.loginfo(f"Current dexhand_position: left_position={dexhand_position[:6]}, right_position={dexhand_position[-6:]}")

if __name__ == '__main__':
    # 初始化ROS节点
    rospy.init_node('dexhand_state_listener')

    # 创建订阅者,监听 /leju_claw_state 话题
    rospy.Subscriber('/dexhand/state', JointState, dexhand_state_callback)

    # 保持节点运行
    rospy.spin()

/dexhand/touch_state Tactile Status of the Tactile Dexterous Hand

  1. Topic Description
  • Topic description: Publishes the tactile status data of the tactile dexterous hand.
  • Prerequisite: This topic is only published when EndEffectorType is configured as qiangnao_touch in kuavo.json.
  1. Message Type
  • Type: kuavo_msgs/dexhandTouchState
  1. Message Fields
FieldTypeDescription
headerstd_msgs/HeaderMessage header, contains information such as the timestamp
left_handkuavo_msgs/touchSensorStatus[5]Left-hand tactile sensor data, 5 in total, one for each finger
right_handkuavo_msgs/touchSensorStatus[5]Right-hand tactile sensor data, 5 in total, one for each finger

The specific fields of kuavo_msgs/touchSensorStatus are as follows:

FieldTypeDescription
headerstd_msgs/HeaderMessage header, contains information such as the timestamp
normal_force1uint16Normal force of tactile sensor 1
normal_force2uint16Normal force of tactile sensor 2
normal_force3uint16Normal force of tactile sensor 3
tangential_force1uint16Tangential force of tactile sensor 1
tangential_force2uint16Tangential force of tactile sensor 2
tangential_force3uint16Tangential force of tactile sensor 3
tangential_direction1uint16Tangential force direction of tactile sensor 1
tangential_direction2uint16Tangential force direction of tactile sensor 2
tangential_direction3uint16Tangential force direction of tactile sensor 3
self_proximity1uint32Self-proximity of tactile sensor 1
self_proximity2uint32Self-proximity of tactile sensor 2
mutual_proximityuint32Mutual proximity of the tactile sensor
statusuint16Tactile sensor status

Among them,

  • The values of normal force and tangential force are in units of 100 * N; for example, a tangential force of 1000 means 1000 / 100 N, that is, 10 N. The measurement range of normal force and tangential force is 0 ~ 25 N.
  • The tangential force direction is in degrees, with a value range of 0 ~ 359 degrees. The direction toward the fingertip is 0 degrees, rotating clockwise up to a maximum of 359 degrees. When the value is 65535 (0xFFFF), it indicates that the tangential force direction is invalid.
  • Both self-proximity and mutual proximity are 32-bit unsigned data; self-proximity means self-capacitance proximity, and mutual proximity means mutual-capacitance proximity.
  1. Usage Example
import rospy
from kuavo_msgs.msg import dexhandTouchState

# 定义回调函数
def dexhand_touch_state_callback(msg):
    left_hand_normal_force1 = msg.left_hand.normal_force1
    # 打印当前触觉传感器1的法向力状态
    print(left_hand_normal_force1)


if __name__ == '__main__':
    # 初始化ROS节点
    rospy.init_node('dexhand_touch_state_listener')

    # 创建订阅者,监听 /leju_claw_state 话题
    rospy.Subscriber('/dexhand/touch_state', dexhandTouchState, dexhand_touch_state_callback)

    # 保持节点运行
    rospy.spin()

/dexhand/command Control the Tactile Dexterous Hands

  1. Topic Description
  • This topic is used to control the tactile dexterous hands, both hands.

  • Prerequisite: This topic can be used only when EndEffectorType is configured as qiangnao_touch in kuavo.json.

  1. Message Type
  • Type: kuavo_msgs/dexhandCommand
  1. Message Fields
FieldTypeDescription
headerstd_msgs/HeaderMessage header, including sequence number, timestamp, and frame ID
control_modeint8Control mode; supports POSITION_CONTROL and VELOCITY_CONTROL
dataint16[]Data corresponding to the control mode; the length must be 12, where the first 6 elements control the left hand and the last 6 elements control the right hand
  • The data order is: "l_thumb", "l_thumb_aux", "l_index", "l_middle", "l_ring", "l_pinky", "r_thumb", "r_thumb_aux", "r_index", "r_middle", "r_ring", "r_pinky"
  • In position control mode, each element's data ranges from [0, 100]; 0 means fully open and 100 means fully closed
  • In velocity control mode, each element's data ranges from [-100, 100]; negative values mean open and positive values mean close
  1. Usage Example
import rospy
from kuavo_msgs.msg import dexhandCommand

def dexhand_publisher():
    # 初始化 ROS 节点
    rospy.init_node('dexhand_command_publisher', anonymous=True)
    # 创建一个发布者,向 /dexhand/command 话题发送 dexhandCommand 类型消息
    pub = rospy.Publisher('/dexhand/command', dexhandCommand, queue_size=10)

    rate = rospy.Rate(10)

    # 这里举例:control_mode=0 表示 POSITION_CONTROL,1 表示 VELOCITY_CONTROL
    # data 数组长度必须 12,前 6 控制左手,后 6 控制右手
    # 位置控制时,0 完全打开,100 完全关闭
    # 速度控制时,-100 全开,+100 全关

    while not rospy.is_shutdown():
        msg = dexhandCommand()

        # 示例:位置控制,各指关节中等关闭
        msg.control_mode = 0  # POSITION_CONTROL

        # 左手:thumb, thumb_aux, index, middle, ring, pinky
        left = [50, 0, 50, 50, 50, 50]
        # 右手顺序同上
        right = [50, 0, 50, 50, 50, 50]

        msg.data = left + right  # 一共 12 个元素

        rospy.loginfo(f"Publishing dexhandCommand: mode={msg.control_mode}, data={msg.data}")
        pub.publish(msg)

        rate.sleep()

if __name__ == '__main__':
    try:
        dexhand_publisher()
    except rospy.ROSInterruptException:
        pass

/dexhand/left/command Control the Left Tactile Dexterous Hand

  1. Topic Description
  • This topic is used to control the left tactile dexterous hand individually.

  • Prerequisite: This topic can be used only when EndEffectorType is configured as qiangnao_touch in kuavo.json.

  1. Message Type
  • Type: kuavo_msgs/dexhandCommand
  1. Message Fields
FieldTypeDescription
headerstd_msgs/HeaderMessage header, including sequence number, timestamp, and frame ID
control_modeint8Control mode; supports POSITION_CONTROL and VELOCITY_CONTROL
dataint16[]Data corresponding to the control mode; the length must be 6
  • The data order is: "l_thumb", "l_thumb_aux", "l_index", "l_middle", "l_ring", "l_pinky"
  • In position control mode, each element's data ranges from [0, 100]; 0 means fully open and 100 means fully closed
  • In velocity control mode, each element's data ranges from [-100, 100]; negative values mean open and positive values mean close
  1. Usage Example
  • The usage example for this topic is similar to that of /dexhand/command; refer to /dexhand/command.

/dexhand/right/command Control the Right Tactile Dexterous Hand

  1. Topic Description
  • This topic is used to control the right tactile dexterous hand individually.

  • Prerequisite: This topic can be used only when EndEffectorType is configured as qiangnao_touch in kuavo.json.

  1. Message Type
  • Type: kuavo_msgs/dexhandCommand
  1. Message Fields
FieldTypeDescription
headerstd_msgs/HeaderMessage header, including sequence number, timestamp, and frame ID
control_modeint8Control mode; supports POSITION_CONTROL and VELOCITY_CONTROL
dataint16[]Data corresponding to the control mode; the length must be 6
  • "r_thumb", "r_thumb_aux", "r_index", "r_middle", "r_ring", "r_pinky"
  • In position control mode, each element's data ranges from [0, 100]; 0 means fully open and 100 means fully closed
  • In velocity control mode, each element's data ranges from [-100, 100]; negative values mean open and positive values mean close
  1. Usage Example
  • The usage example for this topic is similar to that of /dexhand/command; refer to /dexhand/command.

/control_led Control the LED Strip

  1. Service Description

    • This service is used to control the LED strip on the robot's head and supports multiple display modes, including steady on, breathing, blinking, and rhythm effects.
  2. Message Type

    • Type: kuavo_led_controller/SetLEDMode
  3. Request Fields

FieldTypeDescription
modeuint8Mode used to control the LED strip: 0 steady on, 1 breathing, 2 blinking, 3 rhythm (the LED strip color is fixed in this mode)
color1uint8[3]Color of the first LED [r,g,b]--->[(0255),(0255),(0~255)]; the LED closest to the FPC connector is the first LED
color2uint8[3]Color of the second LED [r,g,b]
color3uint8[3]Color of the third LED [r,g,b]
color4uint8[3]Color of the fourth LED [r,g,b]
color5uint8[3]Color of the fifth LED [r,g,b]
color6uint8[3]Color of the sixth LED [r,g,b]
color7uint8[3]Color of the seventh LED [r,g,b]
color8uint8[3]Color of the eighth LED [r,g,b]
color9uint8[3]Color of the ninth LED [r,g,b]
color10uint8[3]Color of the tenth LED [r,g,b]
  1. Response Fields
FieldTypeDescription
successboolIndicates whether the request succeeded. True means success, False means failure
  1. Usage Example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import rospy
from kuavo_led_controller.srv import SetLEDMode, SetLEDModeRequest

def set_led_color():
    """
    调用LED控制服务设置LED颜色
    """
    # 等待服务可用
    rospy.wait_for_service('control_led')
    
    try:
        # 创建服务客户端
        led_service = rospy.ServiceProxy('control_led', SetLEDMode)
        
        # 创建请求
        request = SetLEDModeRequest()
        request.mode = 0  # 设置模式为0(常亮模式)
        
        # 设置每个LED灯的颜色
        request.color1 = [255, 0, 0]    # 红色
        request.color2 = [255, 127, 0]  # 橙色
        request.color3 = [255, 255, 0]  # 黄色
        request.color4 = [0, 255, 0]    # 绿色
        request.color5 = [0, 0, 255]    # 蓝色
        request.color6 = [75, 0, 130]   # 靛色
        request.color7 = [148, 0, 211]  # 紫色
        request.color8 = [255, 0, 127]  # 粉色
        request.color9 = [255, 255, 255]# 白色
        request.color10 = [0, 255, 255] # 青色
        
        # 调用服务
        response = led_service(request)
        
        # 输出结果
        if response.success:
            rospy.loginfo("LED设置成功")
        else:
            rospy.logerr("LED设置失败")
            
    except rospy.ServiceException as e:
        rospy.logerr("服务调用失败: %s", e)

if __name__ == '__main__':
    rospy.init_node('led_client', anonymous=True)
    set_led_color()

/close_led Turn Off the LED Strip

  1. Service Description

    • This service is used to turn off the LED strip on the robot's head.
  2. Message Type

    • Type: std_srvs/Trigger
  3. Request Fields

    • No request fields
  4. Response Fields

FieldTypeDescription
successboolIndicates whether the request succeeded. True means success, False means failure
messagestringReturn message
  1. Usage Example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import rospy
from std_srvs.srv import Trigger

def close_led():
    """
    调用关闭LED服务
    """
    # 等待服务可用
    rospy.wait_for_service('close_led')
    
    try:
        # 创建服务客户端
        close_led_service = rospy.ServiceProxy('close_led', Trigger)
        
        # 调用服务
        response = close_led_service()
        
        # 输出结果
        if response.success:
            rospy.loginfo("LED关闭成功")
        else:
            rospy.logerr("LED关闭失败")
            
    except rospy.ServiceException as e:
        rospy.logerr("服务调用失败: %s", e)

if __name__ == '__main__':
    rospy.init_node('led_client', anonymous=True)
    close_led()

/humanoid/mpc/enable_slope_planning Slope Planning Mode

  1. Function Description

The /humanoid/mpc/enable_slope_planning topic is used to enable or disable the robot's slope planning mode. This mode is designed specifically for the robot to walk on slopes and can automatically adjust the gait and speed according to the normal vector of the plantar contact surface. Slope planning mode is disabled by default when the robot is started.

Important Notes:

  • Protective measures are required for testing: During testing, measures must be taken to prevent the robot from falling, such as installing a gantry or an overhead track.
  • When going uphill: It is recommended to enable slope mode (data: true). The system automatically calculates the foot lift height, projects the velocity onto the slope direction, and compensates the center-of-mass height to ensure stable uphill walking.
  • When going downhill: It is recommended to use flat-ground mode (data: false). Gravity naturally assists the robot's descent, and flat-ground mode is actually more stable and safer.
  1. Message Type
  • Type: std_msgs/Bool
  1. Message Fields
FieldTypeDescription
databoolWhether to enable slope planning mode. True enables it, False disables it
  1. Features

After slope mode is enabled, the system automatically performs the following operations:

  • Adaptive foot height: Calculates the height difference of the next foothold based on the slope normal vector (threshold > 4cm) and actively raises the foot to avoid kicking the slope
  • Velocity projection: Projects velocity commands onto the slope direction to avoid "sinking into the ground" or "slipping"
  • Center-of-mass height compensation: Dynamically adjusts the robot's center-of-mass height to keep the torso posture stable
  • Normal vector tracking: Calculates the normal vectors of the left and right plantar planes in real time and adapts to the slope angle
  1. Applicable Scenarios

Enable slope mode (data: true):

  • Slope <= 5°
  1. Usage Example

Enable slope planning mode (for uphill use):

import rospy
from std_msgs.msg import Bool

# 初始化ROS节点
rospy.init_node('slope_planning_controller')

# 创建发布者
slope_planning_pub = rospy.Publisher('/humanoid/mpc/enable_slope_planning', Bool, queue_size=10)

# 等待发布者连接
rospy.sleep(0.5)

# 创建消息对象
enable_msg = Bool()
enable_msg.data = True  # 启用斜坡规划模式

# 发布消息
slope_planning_pub.publish(enable_msg)
rospy.loginfo("斜坡规划模式已启用(适用于上坡)")

Disable slope mode (for downhill or flat-ground use):

import rospy
from std_msgs.msg import Bool

# 初始化ROS节点
rospy.init_node('slope_planning_controller')

# 创建发布者
slope_planning_pub = rospy.Publisher('/humanoid/mpc/enable_slope_planning', Bool, queue_size=10)

# 等待发布者连接
rospy.sleep(0.5)

# 创建消息对象
disable_msg = Bool()
disable_msg.data = False  # 禁用斜坡规划模式

# 发布消息
slope_planning_pub.publish(disable_msg)
rospy.loginfo("斜坡规划模式已禁用(适用于下坡或平地)")
  1. Quick Command-Line Test

You can also publish the topic directly from the command line for testing:

# 启用斜坡模式(上坡)
rostopic pub /humanoid/mpc/enable_slope_planning std_msgs/Bool "data: true"

# 禁用斜坡模式(下坡或平地)
rostopic pub /humanoid/mpc/enable_slope_planning std_msgs/Bool "data: false"

On this page

SDK OverviewTopicServiceUsage Guide/get_used_audio_buffer_size Get the audio playback buffer size/play_music Play audio/play_music_immediate Interrupt and play immediately/stop_music Stop playback/record_music Record audio/livox/imu Lidar IMU data/livox/lidar Lidar point cloud data/camera/depth/color/points Camera point cloud data/camera/color/image_raw Camera Color Image Data/camera/depth/image_rect_raw Camera Depth Image Data/arm_traj_change_mode Set Arm Control Mode/kuavo_arm_target_poses Arm Motion Control (Reach Target Pose Within a Specified Time)/kuavo_arm_traj Arm Motion Control (for Custom Arm Motion Trajectory Planning)/robot_head_motion_data Head Joint Control/cmd_head_vel Head Joint Angular Velocity Control/cmd_head_delta Head Joint Incremental Control/control_robot_hand_position Dexterous Hand Control/cmd_pose Position Control/cmd_vel Velocity Control/humanoid_controller/real_initial_start Make the Robot Stand Up/sensors_data_raw Sensor Data/ik/fk_srv Robot Arm FK (Forward Kinematics)/ik/two_arm_hand_pose_cmd_srv Robot Arm IK (Inverse Kinematics)/ik/two_arm_hand_pose_cmd_srv_muli_refer Robot Arm IK (Multi-Reference / Multi-Seed)/control_robot_leju_claw Control the Robot Gripper (Two-Finger Claw) Movement/leju_claw_state Get the Robot Gripper (Two-Finger Claw) Status/leju_quest_bone_poses VR Skeleton Pose Data/dexhand/state Dexterous Hand Status/dexhand/touch_state Tactile Status of the Tactile Dexterous Hand/dexhand/command Control the Tactile Dexterous Hands/dexhand/left/command Control the Left Tactile Dexterous Hand/dexhand/right/command Control the Right Tactile Dexterous Hand/control_led Control the LED Strip/close_led Turn Off the LED Strip/humanoid/mpc/enable_slope_planning Slope Planning Mode