Skip to content

ROS 2 ​

发行版是 Ubuntu 22.04 与 ROS 2 Humble。每个新终端先回到 W6E/,再执行:

bash
source /opt/ros/humble/setup.bash
source ros2/install/setup.bash

开 ROS 前如果提示符里有 (.venv),先 deactivate。不要和 SDK 面板或网页控制同时占用 CANable。

安装依赖并编译 ​

先按官方方式装好 ROS 2 Humble,然后:

bash
sudo apt-get install -y \
  ros-humble-ros2-control \
  ros-humble-ros2-controllers \
  ros-humble-joint-state-broadcaster \
  ros-humble-forward-command-controller \
  ros-humble-controller-manager \
  ros-humble-rviz2 \
  ros-humble-xacro \
  ros-humble-joint-state-publisher \
  ros-humble-joint-state-publisher-gui \
  ros-humble-robot-state-publisher \
  ros-humble-moveit

deactivate 2>/dev/null || true
source /opt/ros/humble/setup.bash
cd ros2
colcon build --symlink-install
source install/setup.bash
包作用
w6e_hand_description当前左右手在 urdf/both/
w6e_hand_moveit_config规划组 hand。左手 demo_left,右手 demo_right
w6e_hand_hardwareC++ ros2_control
w6e_driver_pyPython 驱动,接口与 C++ 对齐
w6e_hand_bringuphand.launch.py、python_driver.launch.py。仍是旧右手模型
w6e_hand_interfaces开合度、手势和状态的消息与服务

当前左右手用 demo_left / demo_right。hand.launch.py 仍加载旧右手,不要拿它当现在的左右手模型。

只看模型 ​

先关掉正在跑的 MoveIt。窗口里拖关节只动 RViz,真机不动。

bash
ros2 launch w6e_hand_description view_model.launch.py hand:=right
ros2 launch w6e_hand_description view_model.launch.py hand:=left

不写 hand 时默认右手。

MoveIt ​

一次只开下面一条。不写 transport 是模拟,手指不会动。带 slcan 才连接真手。

bash
ros2 launch w6e_hand_moveit_config demo_left.launch.py
ros2 launch w6e_hand_moveit_config demo_left.launch.py \
  transport:=slcan serial_port:=/dev/ttyACM0
ros2 launch w6e_hand_moveit_config demo_right.launch.py
ros2 launch w6e_hand_moveit_config demo_right.launch.py \
  transport:=slcan serial_port:=/dev/ttyACM0

can0 已经挂好时,把传输换成 transport:=socketcan can_interface:=can0。

启动后打开 RViz。在 MotionPlanning → Joints 里拖动某一路,橙色是目标,松手停在松开的位置。Planning Group 选 hand,点 Plan,再点 Execute,真机才按编码器走到这个开合度。灰色是真机当前姿态。Goal State 里的 open、half、close 是三个现成姿势。没有逆解,不要拖手上的交互标记。

只发开合度 ​

这个终端留着不要关。它使用旧右手模型:

bash
ros2 launch w6e_hand_bringup hand.launch.py \
  transport:=slcan serial_port:=/dev/ttyACM0 use_rviz:=false

另开一个终端,同样 source 两次:

bash
ros2 topic pub --once /w6e_hand/open_pct_cmd \
  std_msgs/msg/Float32MultiArray "{data: [0,0,0,0,0,0]}"

Python 驱动把 hand.launch.py 换成 python_driver.launch.py,并带上 sdk_path:=sdk/python。两套驱动不要一起开。

话题与服务 ​

/w6e_hand/open_pct_cmd 的类型是 std_msgs/msg/Float32MultiArray,长度 6,顺序与 SDK 相同。0 是全合,100 是全开。负数表示该指保持。

名称类型说明
/w6e_hand/open_pct_cmdFloat32MultiArray下发开合度
/w6e_hand/open_pctFloat32MultiArray读回开合度
/joint_statesJointState模型关节角度
/w6e_hand/open_all、/close_all、/stopstd_srvs/Trigger开、合不含虎口
/w6e_hand/play_gesturePlayGesturename 或 fixed_id
bash
ros2 service call /w6e_hand/play_gesture \
  w6e_hand_interfaces/srv/PlayGesture "{name: 'ok', fixed_id: -1}"

左右手角度 ​

Joints 表显示的是角度,从 0° 起,不是开合度百分比。开合度仍是 0 全合、100 全开,由映射文件换算后发给板子。

左手虎口:0° 是合拢,约 92°(1.6 rad)是张开。右手虎口相反:0° 是张开,约 92° 是对掌。

LQ手指左手关节右手关节
0拇damu4damu4
1虎口damu2damu2
2食shizhi2shizhi2
3中zhongzhi2zhongzhi2
4无名wuming2wumingzhi2
5小xiaomu2xiaozhi2

左手映射是 ros2/w6e_hand_description/config/joint_map_both_left.yaml,右手是 joint_map_both_right.yaml。

峦启机器人(天津)有限公司