Skip to content

Sending Commands from ROS 2 to RoboClaw in ROS 1 with a ROS Bridge

Introduction

With ROS 1 Noetic and ROS 2 Foxy running on the same system, it’s possible to bridge topics between them. This allows controlling a RoboClaw motor controller (running on ROS 1) using ROS 2 commands. This guide walks you through setting up the ros1_bridge and sending commands to the RoboClaw-controlled robot from ROS 2.


Key Topics Covered

  • Running the RoboClaw node in ROS 1
  • Setting up the ROS 1-ROS 2 bridge
  • Sending velocity commands from ROS 2
  • Debugging issues

1. Launching the RoboClaw Node in ROS 1

Make sure ROS 1 Noetic is sourced and start the RoboClaw node:

source /opt/ros/noetic/setup.bash
roslaunch roboclaw_node roboclaw.launch

Check if the /cmd_vel topic is available in ROS 1:

rostopic list

You should see /cmd_vel in the list.

To verify if the node is working, try publishing a command directly from ROS 1:

rostopic pub /cmd_vel geometry_msgs/Twist '{linear: {x: 0.5}, angular: {z: 0.1}}'

If the robot moves, the RoboClaw node is working correctly.


2. Setting Up the ROS 1-ROS 2 Bridge

Since ROS 1 and ROS 2 use different communication protocols, we need to bridge them.

Step 1: Install the Bridge

Ensure both ROS 1 and ROS 2 are sourced:

source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash

Install ros1_bridge:

sudo apt install ros-foxy-ros1-bridge

Step 2: Run the Bridge

ros2 run ros1_bridge dynamic_bridge

This will automatically bridge compatible topics between ROS 1 and ROS 2.


3. Sending Commands from ROS 2 to RoboClaw

Now that the bridge is running, switch to a new terminal and source ROS 2:

source /opt/ros/foxy/setup.bash

Check if the /cmd_vel topic is being bridged in ROS 2:

ros2 topic list

If /cmd_vel appears, you can publish a movement command from ROS 2:

ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5}, angular: {z: 0.1}}"

This should move the robot as if the command came from ROS 1.


4. Debugging Common Issues

Issue 1: ROS 1 and ROS 2 Variables Overlapping

Solution: Open separate terminals for ROS 1 and ROS 2, and source them separately.

Issue 2: The Bridge Doesn’t Forward /cmd_vel

Solution: Restart the bridge and verify that both ROS versions are sourced properly.

Issue 3: RoboClaw Doesn’t Respond to Commands

Solution: Ensure the RoboClaw node is running, and check /cmd_vel in ROS 1 using:

rostopic echo /cmd_vel

Conclusion

By following this guide, you can successfully control your RoboClaw-powered robot from ROS 2 while it runs on ROS 1 Noetic. The ros1_bridge ensures seamless communication, allowing hybrid ROS applications.

With this setup, you can integrate ROS 2-based navigation stacks with older ROS 1 hardware.


Created 2025-01-30, Updated 2025-01-30
Authors: Harminder Singh Nijjar (1)

Comments