ROS 2 Humble driver for controlling a Barrett WAM arm over CAN bus through
libbarrett.
This repository ports the original ROS 1 Barrett WAM interface to ROS 2 while
keeping the low-level hardware access in libbarrett. It has been validated on
a local control PC with a 7-DOF WAM, SocketCAN, ROS 2 Humble, and Ubuntu
22.04-style system dependencies.
- 🤖 ROS 2 Humble
ament_cmakebuild. - 📡 CAN-bus WAM control through patched
libbarrett. - 🧩 ROS 2 interfaces for WAM state, realtime commands, and service commands.
- 🖐️ Optional BarrettHand and force/torque sensor support when discovered by
libbarrett. - 🛡️ Conservative launch defaults for first-time hardware bring-up.
- 🧪 Helper tools for
rqtand safe single-joint motion diagnostics.
wam_node/ ROS 2 WAM hardware node
barrett_hand_node/ ROS 2 standalone BarrettHand node
wam_msgs/ ROS 2 custom messages
wam_srvs/ ROS 2 custom services
wam_teleop/ ROS 2 joystick teleoperation
scripts/ Small user-facing test utilities
libbarrett/ Patched libbarrett source, if vendored in this repo
wam_demos/ Legacy ROS 1 package, ignored by colcon
perception_palm/ Legacy ROS 1 package, ignored by colcon
Recommended target:
- 🐧 Ubuntu 22.04
- 🛰️ ROS 2 Humble
- 🔌 SocketCAN or PEAK PCAN CAN interface exposed as
can0 - 🦾 Barrett WAM with safety pendant
- 📚 Patched
libbarrettbuilt from this repository or from your patchedlibbarrettfork
Notes:
- ROS 2 Humble officially targets Ubuntu 22.04.
⚠️ The WAM is real hardware. Keep the E-stop reachable, clear the workspace, and do not run motion commands until the arm is physically safe.- The original ROS 1 demo and Perception Palm packages are not ported in this
tree and are intentionally ignored by
colcon.
Install ROS 2 Humble first by following the official ROS 2 installation guide for Ubuntu 22.04. Then install the build and runtime packages used by this driver:
sudo apt update
sudo apt install -y \
build-essential \
cmake \
git \
can-utils \
libboost-system-dev \
libboost-thread-dev \
libconfig++-dev \
libeigen3-dev \
libgsl-dev \
libncurses5-dev \
python3-colcon-common-extensions \
ros-humble-joy \
ros-humble-rqt \
ros-humble-rqt-common-plugins \
ros-humble-rqt-service-callerIf Conda is active, use the system ROS tools when building and running:
conda deactivate || true
source /opt/ros/humble/setup.bashThis ROS 2 port requires a patched libbarrett for modern Ubuntu/libconfig/C++
toolchains. The patch set includes:
- 🧭 Compatibility with stock Ubuntu
libconfig++. - 🧱 C++17-compatible public headers.
- 📡 SocketCAN build support for non-realtime Linux control.
- 🛡️ A more robust CAN receive buffer during recovery/reconnect.
- 📦
COLCON_IGNOREsocolcondoes not try to buildlibbarrettas a ROS package.
You should clone libbarrett-ROS2repo to your local PC and then build it as following instructions:
cd
git clone https://github.com/gaolongsen/libbarrett-ROS2.git
cd libbarrett-ROS2
mkdir -p build
cd build
cmake .. \
-DNON_REALTIME=true \
-DWITH_PYTHON=OFF \
-DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
sudo ldconfigVerify installation:
ldconfig -p | grep libbarrett
test -f /usr/local/share/barrett/barrett-config.cmake && echo "Barrett CMake config OK"
test -f /usr/local/include/barrett/detail/libconfig_c_setting.h && echo "Patched headers OK"Before you start this section, make sure that you have the CAN bus device. We recommend use PCAN USB Adapter as shown below to ensure you can successfully install the driver 100% to save your time for driver. (WIFI version is on the way!)
Bring up the CAN interface before starting the WAM node:
sudo modprobe can
sudo modprobe can_raw
sudo modprobe can_dev
sudo ip link set can0 down || true
sudo ip link set can0 up type can bitrate 1000000 restart-ms 100
ip -details -statistics link show can0Optional passive bus check:
candump -L can0Do not leave candump or any other CAN reader/writer running while starting
wam_node.
From the repository root:
cd ~/WAM-ROS2
source /opt/ros/humble/setup.bash
./build.sh
source install_ros2/setup.bashExpected ROS 2 packages:
ros2 pkg list | grep -E 'wam_|barrett_hand_node'
ros2 pkg executables wam_node
ros2 pkg executables wam_teleopFor first contact, run the executable directly so libbarrett can read terminal input during the zeroing prompt:
cd ~/WAM-ROS2
source /opt/ros/humble/setup.bash
source install_ros2/setup.bash
./install_ros2/wam_node/lib/wam_node/wam_nodeFollow the safety pendant sequence:
- Clear the workspace and keep E-stop reachable.
- Release E-stop.
- When prompted, press
SHIFT + IDLE. - If prompted to zero, move the WAM to its physical home/zero pose and press
Enter. - When prompted, press
SHIFT + ACTIVATE.
After startup, verify ROS discovery:
ros2 node list
ros2 topic list -t
ros2 service list -t
ros2 topic echo --once /wam/joint_statesAfter the first bring-up is working, launch through ROS 2:
ros2 launch wam_node wam_node.launch.pyLaunch arguments:
ros2 launch wam_node wam_node.launch.py --show-argsImportant defaults:
auto_gravity_comp:=true- Matches the original ROS 1 behavior.
- Required for stable joint-position control on gravity-loaded joints.
initialize_hand_on_startup:=false- Avoids automatic BarrettHand initialization during first WAM startup.
hand_clearance_move_on_startup:=false- Avoids the original automatic joint-4 clearance move.
home_velocity:=0.10home_acceleration:=0.10
For a slower home motion:
ros2 launch wam_node wam_node.launch.py home_velocity:=0.05 home_acceleration:=0.05State topics:
/wam/joint_states sensor_msgs/msg/JointState
/wam/pose geometry_msgs/msg/PoseStamped
/wam/move_is_done std_msgs/msg/Bool
/fts/fts_states geometry_msgs/msg/Wrench, if F/T sensor is present
Command topics:
/wam/cart_vel_cmd wam_msgs/msg/RTCartVel
/wam/ortn_vel_cmd wam_msgs/msg/RTOrtnVel
/wam/jnt_vel_cmd wam_msgs/msg/RTJointVel
/wam/jnt_pos_cmd wam_msgs/msg/RTJointPos
/wam/cart_pos_cmd wam_msgs/msg/RTCartPos
Realtime command topics are timeout-based. If messages stop, the node returns to holding the current joint position.
Core WAM services:
/wam/gravity_comp wam_srvs/srv/GravityComp
/wam/go_home std_srvs/srv/Empty
/wam/hold_joint_pos wam_srvs/srv/Hold
/wam/hold_cart_pos wam_srvs/srv/Hold
/wam/hold_ortn wam_srvs/srv/Hold
/wam/joint_move wam_srvs/srv/JointMove
/wam/pose_move wam_srvs/srv/PoseMove
/wam/cart_move wam_srvs/srv/CartPosMove
/wam/ortn_move wam_srvs/srv/OrtnMove
Enable gravity compensation:
ros2 service call /wam/gravity_comp wam_srvs/srv/GravityComp "{gravity: true}"Move to an absolute 7-DOF joint pose:
ros2 service call /wam/joint_move wam_srvs/srv/JointMove \
"{joints: [0.0, -1.5, 0.0, 2.0, 0.0, 0.0, 0.0]}"Move to the configured libbarrett home pose:
ros2 service call /wam/go_home std_srvs/srv/Empty "{}"Important: /wam/go_home is not all-zero joints. For a typical 7-DOF wrist WAM
the configured home pose is:
[0, -2, 0, 3.13, 0, 0, 0]
This value comes from /etc/barrett/calibration_data/wam7w/zerocal.conf or the
corresponding WAM configuration selected by libbarrett.
Use the helper script to test one joint at a time. It reads the current joint
state, adds a small delta to one joint, calls /wam/joint_move, waits for
/wam/move_is_done, and prints final error.
cd ~/WAM-ROS2
source /opt/ros/humble/setup.bash
source install_ros2/setup.bash
scripts/wam_joint_nudge.py 1 0.02
scripts/wam_joint_nudge.py 1 -0.02Test joints 1 through 7 slowly. Do not send the next command until the previous one finishes.
If Fast DDS prints shared-memory warnings such as Failed init_port, disable
Fast DDS shared memory for the current terminal:
export RMW_FASTRTPS_USE_SHM=0Launch rqt from the repository helper so it uses the same ROS 2 workspace
environment and avoids Conda/Snap/Qt library pollution:
cd ~/WAM-ROS2
./run_rqt_wam.sh --clear-config --force-discoverOpen:
Plugins -> Services -> Service Caller
For /wam/joint_move, edit the joints expression from the default empty
array to a 7-value Python list:
[0.0, -1.5, 0.0, 2.0, 0.0, 0.0, 0.0]Do not publish to /wam/joint_states; it is a feedback topic, not a command
topic.
For standalone BarrettHand control over CAN:
ros2 launch barrett_hand_node barrett_hand_node.launch.pyExample services:
ros2 service call /bhand/initialize std_srvs/srv/Empty "{}"
ros2 service call /bhand/open_grasp std_srvs/srv/Empty "{}"
ros2 service call /bhand/close_grasp std_srvs/srv/Empty "{}"
ros2 service call /bhand/grasp_pos wam_srvs/srv/BHandGraspPos "{radians: 1.0}"Start the WAM node first, then launch teleoperation:
ros2 launch wam_teleop wam_joystick_teleop.launch.pyThe teleop node subscribes to /joy and publishes WAM realtime velocity
commands.
If the WAM shakes, behaves unexpectedly, or E-stop is pressed:
-
Press E-stop.
-
Stop
wam_node. -
Reset the CAN interface:
sudo ip link set can0 down sudo ip link set can0 up type can bitrate 1000000 restart-ms 100
-
Restart
wam_node. -
Press
SHIFT + IDLE. -
Zero if prompted.
-
Press
SHIFT + ACTIVATE. -
Re-enable gravity compensation if needed:
ros2 service call /wam/gravity_comp wam_srvs/srv/GravityComp "{gravity: true}"
Do not continue sending commands after serious shaking without restarting the node and recovering the safety state.
You likely overwrote LD_LIBRARY_PATH. Source ROS 2 and prepend any local
library path instead of replacing it:
source /opt/ros/humble/setup.bash
source install_ros2/setup.bash
LD_LIBRARY_PATH=$PWD/libbarrett/build/src:$LD_LIBRARY_PATH ./install_ros2/wam_node/lib/wam_node/wam_nodeUse:
./run_rqt_wam.sh --clear-config --force-discoverIf needed, use a fresh non-Snap terminal and deactivate Conda.
Use the patched libbarrett in this repository. Rebuild and install it:
cd libbarrett/build
make -j$(nproc)
sudo make install
sudo ldconfigThen reset CAN before reconnecting:
sudo ip link set can0 down
sudo ip link set can0 up type can bitrate 1000000 restart-ms 100Ensure gravity compensation is enabled:
ros2 service call /wam/gravity_comp wam_srvs/srv/GravityComp "{gravity: true}"The default launch file enables it automatically with auto_gravity_comp:=true.
The Service Caller sent an empty array. For /wam/joint_move, the joints
field must be a 7-element list.
/wam/go_home uses the home pose from libbarrett configuration, usually in:
/etc/barrett/calibration_data/wam7w/zerocal.conf
Check that the installed Barrett calibration files match your physical WAM.
If this repository is useful for your work, please cite or acknowledge the project repository and Barrett Technology's original ROS/libbarrett software.
This repository is derived from Barrett ROS/libbarrett software. Keep the original license files and notices from upstream components when redistributing or modifying this code.

