Interface Usage Documentation
SDK Overview
This SDK provides a set of interfaces for controlling the robot and retrieving its state, which fall mainly into two categories: topics and services. These interfaces are based on the ROS (Robot Operating System) framework, and Python examples are provided for development and invocation. The following is an overview of the SDK's main capabilities:
Topics
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, and image data, and can also publish control commands to control the robot's motion and posture.
- Sensor data: Obtain raw robot sensor data via topics, including IMU data, point cloud data, and image data.
- Motion control: Publish control commands via topics to specify the robot's motion trajectory, velocity, and posture.
Services
Services are used to execute specific control commands or retrieve state information. Service calls are synchronous, meaning that after the user sends a request, they wait for the service to return a response. Services are typically used for one-off operations, such as playing music, recording audio, and setting control modes.
- Control commands: Send control commands through service interfaces, such as playing music, recording audio, and setting the arm control mode.
- State retrieval: Retrieve the robot's state information through service interfaces.
Usage Guide
-
Initialize the ROS node: Before using the SDK, you need to initialize a ROS node. You can use the
rospy.init_node()method to initialize the node. -
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.
-
Create a service proxy: For services that need to be called, create a service proxy object and use it to send requests and receive responses.
-
Process data or responses: After receiving topic data or service responses, perform the corresponding processing or operations.
- Interface Usage Documentation
- SDK Overview
- Usage Guide
/get_free_buffer_sizeGet Audio Playback Buffer Size/play_musicPlay Audio/record_musicRecord Audio/livox/imuLiDAR IMU Data/livox/lidarLiDAR Point Cloud Data/camera/depth/color/pointsCamera Point Cloud Data/camera/color/image_rawCamera Color Image Data/camera/depth/image_rect_rawCamera Depth Image Data/arm_traj_change_modeSet Arm Control Mode/kuavo_arm_target_posesArm Motion Control (Reach Target Position Within a Specified Time)/kuavo_arm_trajArm Motion Control (For Custom Arm Trajectory Planning)/robot_head_motion_dataHead Joint Control/control_robot_hand_positionDexterous Hand Control/cmd_posePosition Control/cmd_velVelocity Control/humanoid_controller/real_initial_startMake the Robot Stand Up/sensors_data_rawSensor Data/ik/fk_srvRobot Arm Forward Kinematics (FK)/ik/two_arm_hand_pose_cmd_srvRobot Arm Inverse Kinematics (IK)/leju_quest_bone_posesVR Skeleton Pose Data/dexhand/stateDexterous Hand State/dexhand/commandControl the Dexterous Hand/dexhand/left/commandControl the Left Dexterous Hand/dexhand/right/commandControl the Right Dexterous Hand
/get_free_buffer_size Get Audio Playback Buffer Size
- Function Description
The /get_used_audio_buffer_size service is used to retrieve the usage of the audio playback buffer.
- Request Format
- Type:
Trigger
- Response Format
- Type:
TriggerResponse - Fields:
success(bool): Indicates whether the request succeeded.Truemeans success,Falsemeans failure.message(str): Returns the audio playback buffer usage (the number of audio chunks currently in the queue).
/play_music Play Audio
- Function Description
The /play_music service is used to control the robot to play a specified music file. Users can play music by providing the name or number of the music file along with the volume.
- Request Format
- Type:
playmusicRequest - Fields:
music_number(str): The name or number of the music file. This can be a file path or a predefined music number.volume(int): The music volume, typically ranging from 0 to 100.
- Response Format
- Type:
playmusicResponse - Fields:
success_flag(bool): Indicates whether the music playback request succeeded.Truemeans success,Falsemeans failure.
- Usage Example
import rospy
from kuavo_msgs.srv import playmusic, playmusicRequest
# 初始化 ROS 节点
rospy.init_node('music_player_client')
# 创建服务代理
robot_music_play_client = rospy.ServiceProxy("/play_music", playmusic)
# 创建请求对象
request = playmusicRequest()
request.music_number = "/home/kuavo/你好" # 音乐文件路径
request.volume = 80 # 音量
# 发送请求并接收响应
response = robot_music_play_client(request)/record_music Record Audio
- Function Description
The /record_music service is used to control the robot to record a specified music file. Users can record music by providing the number of the music file and a timeout.
- Request Format
- Type:
recordmusicRequest - Fields:
music_number(str): The number of the music file. Used to identify the music file to be recorded.time_out(int): Timeout in seconds. Specifies the maximum duration of the recording operation.
- Response Format
- Type:
recordmusicResponse - Fields:
success_flag(bool): Indicates whether the music recording request succeeded.Truemeans success,Falsemeans failure.
- 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 Starting the LiDAR to start the LiDAR node.
- Function Description
The /livox/imu topic provides the LiDAR's built-in IMU (Inertial Measurement Unit) information, including linear acceleration and angular velocity.
- Message Type
- Type:
sensor_msgs/Imu
- Message Fields
-
Header: Message header information
seq(uint32): Sequence numberstamp(time): Timestampframe_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])
- 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 Starting the LiDAR to start the LiDAR node.
- Function Description
The /livox/lidar topic provides the LiDAR's point cloud data, used for point cloud representation in three-dimensional space.
- Message Type
- Type:
sensor_msgs/PointCloud2
- Message Fields
-
Header: Message header information
seq(uint32): Sequence numberstamp(time): Timestampframe_id(string): Coordinate frame ID
-
height (uint32): The height of the point cloud (usually 1)
-
width (uint32): The width of the point cloud (the number of points)
-
fields: Point field information
name(string): Field nameoffset(uint32): Field offsetdatatype(uint8): Data typecount(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
- 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
- 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.
- Message Type
- Type:
sensor_msgs/PointCloud2
- Message Fields
-
Header: Message header information
seq(uint32): Sequence numberstamp(time): Timestampframe_id(string): Coordinate frame ID
-
height (uint32): The height of the point cloud (usually 1)
-
width (uint32): The width of the point cloud (the number of points)
-
fields: Point field information
name(string): Field nameoffset(uint32): Field offsetdatatype(uint8): Data typecount(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
- 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
- Function Description
The /camera/color/image_raw topic provides the camera's raw color image data.
- Message Type
- Type:
sensor_msgs/Image
- Message Fields
-
Header: Message header information
seq(uint32): Sequence numberstamp(time): Timestampframe_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
- 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
- Function Description
The /camera/depth/image_rect_raw topic provides the camera's depth image data, rectified to remove distortion.
- Message Type
- Type:
sensor_msgs/Image
- Message Fields
-
Header: Message header information
seq(uint32): Sequence numberstamp(time): Timestampframe_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
- 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
- Function Description
The /arm_traj_change_mode service is used to set the control mode of the OCS2 arms. Users can change how the arms operate by providing a control mode number.
Control modes include:
0: Keep pose1: Auto arm swing while walking (auto_swing_arm)2: External control (external_control)
- Request Format
-
Type:
changeArmCtrlModeRequest -
Fields:
control_mode(int): The control mode number to set. Valid values are 0, 1, or 2.
- Response Format
-
Type:
changeArmCtrlModeResponse -
Fields:
result(bool): Indicates whether the control mode change request succeeded.Truemeans success, andFalsemeans failure.message(str): A message containing detailed information about the operation result.
- 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 the Target Position Within a Specified Time)
- Function Description
The /kuavo_arm_target_poses topic is used to publish target pose information for the arms, including times and joint angles. This topic can be used to control the arms to move to specified poses.
- Message Type
- Type:
kuavo_msgs/armTargetPoses
- 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 arms at each time point.
- 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 Trajectory Planning)
- Function Description
The /kuavo_arm_traj topic is used to control robot arm motion, achieving precise arm control by publishing target joint positions for the arms.
- Message Type
- Type:
sensor_msgs/JointState
- Message Fields
- name (list of string): A list of joint names. Assume there are 14 joints, named
"arm_joint_1"through"arm_joint_14". - position (list of float): A list of current joint positions.
- header.stamp (time): The message timestamp, set to the current time.
- 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
- Function Description
The /robot_head_motion_data topic is used to publish target motion data for the robot head, including yaw and pitch angles. This topic can be used to control the robot's head motion.
- Message Type
- Type:
kuavo_msgs/robotHeadMotionData
- Message Fields
- joint_data (list of float): A list containing the head yaw and pitch angles. The yaw angle ranges from [-30, 30] degrees, and the pitch angle ranges from [-25, 25] degrees.
- 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)/control_robot_hand_position Dexterous Hand Control
- 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 only published when
EndEffectorTypeis configured asqiangnaoinkuavo.json.
- Topic Type
- Type:
kuavo_msgs/robotHandPosition
- 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.
- 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
- Function Description
The /cmd_pose topic is used to publish control commands that specify the robot's linear and angular velocities in space.
- Message Type
- Type:
geometry_msgs/Twist
- Message Fields
- linear.x (float): The x-direction value relative to the current position, in meters (m).
- linear.y (float): The y-direction value relative to 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): The rotation (yaw) angle relative to the current position, in radians (radian).
- 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
- Function Description
The /cmd_vel topic is used to publish control commands that specify the robot's linear and angular velocities in space.
- Message Type
- Type:
geometry_msgs/Twist
- 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).
- 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
- Function Description
The /humanoid_controller/real_initial_start service is used to trigger the robot initialization process: in the cali state, the robot retracts its legs once and then stands up once. The user must hold the robot by hand during standing to ensure safety. This service is only available on the real robot.
- Service Type
- Type:
std_srvs/Trigger
- Request Message
- No request parameters are required.
- Response Message
- success (bool): Service call result; returns
Trueon success andFalseon failure. - message (string): The response message of the service call, providing detailed information about success or failure.
- 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
- Function Description
The /sensors_data_raw topic is used to publish raw sensor data from the real robot or the simulator, including joint data, IMU data, and end-effector data.
- Message Type
- Type:
kuavo_msgs/sensorsData
- Message Fields
| Field | Type | Description |
|---|---|---|
| sensor_time | time | Timestamp |
| joint_data | kuavo_msgs/jointData | Joint data: position, velocity, acceleration, current |
| imu_data | kuavo_msgs/imuData | Includes gyroscope, accelerometer, free acceleration, quaternion |
| end_effector_data | kuavo_msgs/endEffectorData | End-effector data, not yet used |
- Joint Data Description
-
Array length:
NUM_JOINT -
Data order:
- The first 12 values 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 values are arm motor data:
- 12~18 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 values are head motor data: head_yaw and head_pitch
- The first 12 values are lower-limb motor data:
-
Units:
- Position: radians (radian)
- Velocity: radians per second (radian/s)
- Acceleration: radians per second squared (radian/s²)
- Current: amperes (A)
- 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
- 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
- Service Description
The /if/fk_srv service is used for robot arm FK forward kinematics.
- Request Format
- Type:
kuavo_msgs/fkSrv - Fields:
| Field | Type | Description |
|---|---|---|
| q | float64[] | Length 14, contains the arm joint angles, in radians |
- Response Format
- Type:
kuavo_msgs/fkSrv - Fields:
| Field | Type | Description |
|---|---|---|
| success | bool | Return parameter, whether the call succeeded |
| hand_poses | twoArmHandPose | Return parameter, the forward kinematics result; see the message of the same type above for details |
- 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
- Service Description
The /ik/two_arm_hand_pose_cmd_srv service is used for robot arm IK inverse kinematics.
- Request Format
- Type:
twoArmHandPoseCmd - Field:
twoArmHandPoseCmdRequest
| Field | Type | Description |
|---|---|---|
| hand_poses | twoArmHandPose | Information for both hands: end-effector position, end-effector quaternion, elbow position, etc. |
| use_custom_ik_param | bool | Whether to use custom IK parameters; when set to true, the ik_param value in the message is used for solving |
| joint_angles_as_q0 | bool | Whether to use the joint_angles in hand_poses as q0 during solving |
| ik_param | ikSolveParam | Custom IK solving parameters |
The ik_param field is described in detail below:
| Field | Type | Description |
|---|---|---|
| major_optimality_tol | float64 | snopt parameter, i.e. the optimality tolerance in major iterations; this parameter determines how well the optimality conditions are satisfied |
| major_feasibility_tol | float64 | snopt parameter, i.e. the feasibility tolerance in major iterations, used to control nonlinear constraints |
| minor_feasibility_tol | float64 | snopt parameter, the feasibility tolerance in minor iterations, mainly used for the linearized model |
| major_iterations_limit | float64 | snopt parameter, the maximum number of major iterations |
| oritation_constraint_tol | float64 | Orientation constraint parameter |
| pos_constraint_tol | float64 | Position constraint parameter; this parameter only takes effect when pos_cost_weight is greater than 0.0 |
| pos_cost_weight | float64 | Position cost parameter; when set to 0.0, the highest solving accuracy is required |
The hand_poses field is described in detail below:
| Field | Type | Description |
|---|---|---|
| pos_xyz | float64[3] | Desired position of the end effector, in m |
| quat_xyzw | float64[4] | Desired orientation of the end effector |
| elbow_pos_xyz | float64[3] | Desired elbow position; ignored when all values are set to 0.0 |
| joint_angles | float64[7] | If joint_angles_as_q0 is true, this value is used as q0 during solving, in radians |
- Response Format
| Field | Type | Description |
|---|---|---|
| success | bool | Whether the call succeeded |
| with_torso | bool | Whether the torso is included |
| q_arm | float64[] | Arm joint values, in radians |
| q_torso | float64[] | Torso joint values |
| time_cost | float64 | Solving time, in ms |
| hand_poses | twoArmHandPose | IK solving result; see the message of the same type above for details |
- 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)/leju_quest_bone_poses VR Bone Pose Data
- Function Description
The /leju_quest_bone_poses topic publishes bone pose data tracked by the Quest3 VR device, including the position and orientation of 26 bone nodes.
- Message Type
- Type:
noitom_hi5_hand_udp_python/PoseInfoList
- Message Fields
- timestamp_ms (int): Timestamp
- is_high_confidence (bool): Data confidence flag
- is_hand_tracking (bool): Hand tracking status flag
- poses (PoseInfo[]): List of pose data for all bones; each bone contains:
- position (geometry_msgs/Point): Bone position (x, y, z)
- orientation (geometry_msgs/Quaternion): Bone orientation quaternion (x, y, z, w)
- Bone List (26 bones 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" # 根部、胸部、颈部、头部
]- 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 State
- Topic Description
- Publishes the state data of the dexterous hand.
- Prerequisite: This topic is published only when
EndEffectorTypeis configured asqiangnaoorqiangnao_touchinkuavo.json.
- Message Type
- Type:
sensor_msgs/JointState
- Message Fields
| Field | Type | Description |
|---|---|---|
| header | std_msgs/Header | Message header, containing information such as the timestamp |
| name | string[] | Array of joint names, containing 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"] |
| position | float64[] | Array of joint positions, length 12; the first 6 are the left-hand joint positions and the last 6 are the right-hand joint positions |
| velocity | float64[] | Array of joint velocities, length 12; the first 6 are the left-hand joint velocities and the last 6 are the right-hand joint velocities (this field is valid only when the type is qiangnao_touch) |
| effort | float64[] | Array of joint currents, length 12; the first 6 are the left-hand joint currents and the last 6 are the right-hand joint currents (this field is valid only when the type is qiangnao_touch) |
- 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/command Control the Dexterous Hands
- Topic Description
-
This topic is used to control the dexterous hands, both hands.
-
Prerequisite: This topic can only be used when
EndEffectorTypeis configured asrevo2inkuavo.json.
- Message Type
- Type:
kuavo_msgs/dexhandCommand
- Message Fields
| Field | Type | Description |
|---|---|---|
| header | std_msgs/Header | Message header, including sequence number, timestamp, and frame ID |
| control_mode | int8 | Control mode, supporting POSITION_CONTROL and VELOCITY_CONTROL |
| data | int16[] | 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, the data range for each element is [0, 100]; 0 is fully open and 100 is fully closed.
- In velocity control mode, the data range for each element is [-100, 100]; negative values mean open and positive values mean close.
- 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 Dexterous Hand
- Topic Description
-
This topic is used to control the left dexterous hand independently.
-
Prerequisite: This topic can only be used when
EndEffectorTypeis configured asrevo2inkuavo.json.
- Message Type
- Type:
kuavo_msgs/dexhandCommand
- Message Fields
| Field | Type | Description |
|---|---|---|
| header | std_msgs/Header | Message header, including sequence number, timestamp, and frame ID |
| control_mode | int8 | Control mode, supporting POSITION_CONTROL and VELOCITY_CONTROL |
| data | int16[] | 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, the data range for each element is [0, 100]; 0 is fully open and 100 is fully closed.
- In velocity control mode, the data range for each element is [-100, 100]; negative values mean open and positive values mean close.
- 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 Dexterous Hand
- Topic Description
-
This topic is used to control the right dexterous hand independently.
-
Prerequisite: This topic can only be used when
EndEffectorTypeis configured asrevo2inkuavo.json.
- Message Type
- Type:
kuavo_msgs/dexhandCommand
- Message Fields
| Field | Type | Description |
|---|---|---|
| header | std_msgs/Header | Message header, including sequence number, timestamp, and frame ID |
| control_mode | int8 | Control mode, supporting POSITION_CONTROL and VELOCITY_CONTROL |
| data | int16[] | 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, the data range for each element is [0, 100]; 0 is fully open and 100 is fully closed.
- In velocity control mode, the data range for each element is [-100, 100]; negative values mean open and positive values mean close.
- Usage Example
- The usage example for this topic is similar to that of
/dexhand/command; refer to/dexhand/command.