机械臂末端执行器(夹爪)
手部系统 ROS2 Topic API 参考文档
底层 ROS2 Topic 通信 — /fd_robot/manipulator/* 和 /fd_robot/fd_hand_controller/*
支持 Inspire(左手/右手独立 Topic)和 RoHand(JointState)两种灵巧手后端。
1. 手部运动控制(Inspire)— hand_move
Publisher left_Setmovetgt / right_Setmovetgt
Topic 左手:
Topic 右手:
类型:
/fd_robot/manipulator/left_SetmovetgtTopic 右手:
/fd_robot/manipulator/right_Setmovetgt类型:
std_msgs/msg/Int32| 字段 | 类型 | 说明 |
|---|---|---|
data |
int32 | 控制值,取首值作为开合控制 |
使用示例
ROS2 (Python)
import rclpy from std_msgs.msg import Int32 rclpy.init() node = rclpy.create_node("hand_inspire_pub") left_pub = node.create_publisher(Int32, "/fd_robot/manipulator/left_Setmovetgt", 10) right_pub = node.create_publisher(Int32, "/fd_robot/manipulator/right_Setmovetgt", 10) msg = Int32() # 控制左手开合 msg.data = 500 left_pub.publish(msg) # 控制右手开合 msg.data = 500 right_pub.publish(msg)
2. 手部运动控制(RoHand)— hand_move
Publisher joint_command
Topic:
类型:
/fd_robot/fd_hand_controller/joint_command类型:
sensor_msgs/msg/JointState| 字段 | 类型 | 说明 |
|---|---|---|
name |
string[] | 关节名称列表(6个) |
position |
float64[] | 目标位置列表,传入 6 个值 |
使用示例
ROS2 (Python)
import rclpy from sensor_msgs.msg import JointState rclpy.init() node = rclpy.create_node("hand_rohand_pub") pub = node.create_publisher(JointState, "/fd_robot/fd_hand_controller/joint_command", 10) msg = JointState() msg.name = ["joint1", "joint2", "joint3", "joint4", "joint5", "joint6"] msg.position = [0.0, 0.5, 0.3, 0.0, 0.0, 0.0] pub.publish(msg)
3. 手部停止(Inspire)— hand_stop
Publisher left_Setestop / right_Setestop
Topic 左手:
Topic 右手:
类型:
/fd_robot/manipulator/left_SetestopTopic 右手:
/fd_robot/manipulator/right_Setestop类型:
Setestop(自定义消息)使用示例
ROS2 (Python)
import rclpy from fd_api_interfaces.msg import Setestop rclpy.init() node = rclpy.create_node("hand_stop_pub") left_pub = node.create_publisher(Setestop, "/fd_robot/manipulator/left_Setestop", 10) right_pub = node.create_publisher(Setestop, "/fd_robot/manipulator/right_Setestop", 10) msg = Setestop() # 停止左手 left_pub.publish(msg) # 停止右手 right_pub.publish(msg)
4. 手部位置读取/订阅(Inspire)— hand_get_current_pos / hand_sub_current_pos
Subscriber left_Getcopen / right_Getcopen
Topic 左手:
Topic 右手:
类型:
更新频率:1Hz 轮询
/fd_robot/manipulator/left_GetcopenTopic 右手:
/fd_robot/manipulator/right_Getcopen类型:
Getcopen(自定义消息)更新频率:1Hz 轮询
使用示例
ROS2 (Python)
import rclpy from fd_api_interfaces.msg import Getcopen rclpy.init() node = rclpy.create_node("hand_inspire_pose_sub") def left_callback(msg): node.get_logger().info( f"左手位置:{msg.position}") def right_callback(msg): node.get_logger().info( f"右手位置:{msg.position}") # 订阅左右手位置(1Hz 轮询) left_sub = node.create_subscription(Getcopen, "/fd_robot/manipulator/left_Getcopen", left_callback, 10) right_sub = node.create_subscription(Getcopen, "/fd_robot/manipulator/right_Getcopen", right_callback, 10) rclpy.spin(node)
5. 手部位置读取/订阅(RoHand)— hand_get_current_pos / hand_sub_current_pos
Subscriber joint_states
Topic:
类型:
/fd_robot/fd_hand_controller/joint_states类型:
sensor_msgs/msg/JointState| 字段 | 类型 | 说明 |
|---|---|---|
name |
string[] | 关节名称列表 |
position |
float64[] | 各关节当前位置值列表 |
使用示例
ROS2 (Python)
import rclpy from sensor_msgs.msg import JointState rclpy.init() node = rclpy.create_node("hand_rohand_pose_sub") def state_callback(msg): for i, name in enumerate(msg.name): node.get_logger().info( f"{name}:{msg.position[i]}") sub = node.create_subscription( JointState, "/fd_robot/fd_hand_controller/joint_states", state_callback, 10) rclpy.spin(node)
建议:
- Inspire 灵巧手的位置数据以 1Hz 频率轮询更新,注意实时性限制
- RoHand 灵巧手通过 JointState 发布,不区分左右手,需从关节名称区分
- C++/Python API 已封装底层 Topic 通信,直接使用 API 更便捷
手部系统 ROS2 Topic API 文档 Ver1.0.0
