Skip to content

Commit 3698eac

Browse files
Docs: bridge ROS 1 and ROS 2 with ros1_bridge (#226)
* Docs: bridge ROS 1 and ROS 2 with ros1_bridge A short page on building ros1_bridge in a pixi project with separate Noetic and Humble environments (Humble using Noetic as an underlay), tested on Ubuntu 22.04 aarch64 with the current builds of both. Requested in #106. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Docs: ros1_bridge on macOS Tested on osx-arm64 too: add the platform, build with C++23 (clang rejects the bridge's static_asserts in older modes) and CMAKE_INSTALL_RPATH_USE_LINK_PATH (CMake's install dropped the LDFLAGS rpath to the ROS 1 libraries on macOS), and note ROS_HOSTNAME / ROS_LOCALHOST_ONLY for a single machine. Retested on Ubuntu 22.04 aarch64 with the same flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Docs: capitalise Pixi in the ros1_bridge page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1c4c89f commit 3698eac

3 files changed

Lines changed: 88 additions & 1 deletion

File tree

‎astro.config.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default defineConfig({
7676
],
7777
},
7878
{ label: "JupyterRos", slug: "JupyterRos" },
79+
{ label: "Bridging ROS 1 and ROS 2", slug: "Ros1Bridge" },
7980
],
8081
},
8182
{

‎src/content/docs/Ros1Bridge.md‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Bridging ROS 1 and ROS 2
3+
slug: Ros1Bridge
4+
description: Connect ROS 1 Noetic and ROS 2 Humble nodes with ros1_bridge, built from source in a Pixi project.
5+
---
6+
7+
[`ros1_bridge`](https://github.com/ros2/ros1_bridge) passes topics and services between ROS 1 and ROS 2, for example between a robot running ROS 1 Noetic and a computer running ROS 2 Humble. It isn't packaged, but builds from source in a Pixi project. Tested on Linux (aarch64) and macOS (Apple silicon).
8+
9+
:::caution[Keep Noetic and Humble in separate environments]
10+
Both distributions have packages with the same names (`std_msgs`, `rosgraph_msgs`, ...). In one environment, their Python modules and CMake files overwrite each other, which breaks `roscore` and building the bridge.
11+
:::
12+
13+
## Set up
14+
15+
One Pixi project with two environments, `noetic` and `humble`. The `humble` environment uses `noetic` as an underlay, like sourcing `/opt/ros/noetic` before `/opt/ros/humble` on Ubuntu.
16+
17+
`pixi.toml`:
18+
19+
```toml
20+
[workspace]
21+
name = "ros1-bridge"
22+
channels = ["https://prefix.dev/robostack-noetic", "https://prefix.dev/robostack-humble", "https://prefix.dev/conda-forge"]
23+
platforms = ["linux-64", "linux-aarch64", { platform = "osx-arm64", macos = "14.0" }]
24+
25+
[feature.noetic.dependencies]
26+
ros-noetic-ros-base = "*"
27+
ros-noetic-rospy-tutorials = "*"
28+
29+
[feature.humble.dependencies]
30+
ros-humble-ros-base = "*"
31+
ros-humble-demo-nodes-cpp = "*"
32+
ros-humble-rmw-implementation-cmake = "*"
33+
compilers = "*"
34+
cmake = "*"
35+
ninja = "*"
36+
pkg-config = "*"
37+
colcon-common-extensions = "*"
38+
39+
[feature.humble.activation]
40+
scripts = ["noetic-underlay.sh"]
41+
42+
[environments]
43+
noetic = { features = ["noetic"], no-default-feature = true }
44+
humble = { features = ["humble"], no-default-feature = true }
45+
```
46+
47+
`noetic-underlay.sh`, next to it:
48+
49+
```sh
50+
NOETIC="$PIXI_PROJECT_ROOT/.pixi/envs/noetic"
51+
export ROS1_INSTALL_PATH="$NOETIC"
52+
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH:+$PKG_CONFIG_PATH:}$NOETIC/lib/pkgconfig"
53+
export ROS_PACKAGE_PATH="$NOETIC/share"
54+
export ROS_MASTER_URI="${ROS_MASTER_URI:-http://localhost:11311}"
55+
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$NOETIC/lib/python3.12/site-packages"
56+
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH:+$CMAKE_PREFIX_PATH:}$CONDA_PREFIX:$NOETIC"
57+
```
58+
59+
## Build
60+
61+
```sh
62+
pixi install -a
63+
git clone https://github.com/ros2/ros1_bridge.git ws/src/ros1_bridge
64+
cd ws
65+
pixi run -e humble colcon build --cmake-args -G Ninja -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DPython3_FIND_VIRTUALENV=ONLY \
66+
-DCMAKE_CXX_STANDARD=23 -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON
67+
```
68+
69+
`CMAKE_INSTALL_RPATH_USE_LINK_PATH` lets the bridge find the ROS 1 libraries without `LD_LIBRARY_PATH`, and C++23 is needed for clang on macOS.
70+
71+
The bridge supports the message types present in both environments; `ros-base` gives about 130 (`std_msgs`, `geometry_msgs`, `sensor_msgs`, `nav_msgs`, ...). For more, add the message packages to both features (e.g. `ros-noetic-tf2-msgs` and `ros-humble-tf2-msgs`) and build again.
72+
73+
## Run
74+
75+
Each command in its own terminal, in `ws`:
76+
77+
```sh
78+
pixi run -e noetic roscore
79+
pixi run -e humble bash -c "source install/setup.bash && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics"
80+
pixi run -e noetic rosrun rospy_tutorials talker
81+
pixi run -e humble ros2 run demo_nodes_cpp listener
82+
```
83+
84+
The listener prints the messages of the ROS 1 talker. To use an existing ROS 1 master, e.g. on a robot, set `ROS_MASTER_URI` instead of running `roscore`.
85+
86+
On macOS, set `ROS_HOSTNAME=localhost` for the ROS 1 nodes when everything runs on one machine, and `ROS_LOCALHOST_ONLY=1` if ROS 2 nodes on the same machine don't see each other.

‎src/data/nav.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const NAV_TABS: NavTab[] = [
1717
label: "Docs",
1818
href: "/GettingStarted.html",
1919
match:
20-
/^\/(GettingStarted|micromamba|conda|JupyterRos|FAQ|support|CommunityMeeting|Contributing|Monorepo)/,
20+
/^\/(GettingStarted|micromamba|conda|JupyterRos|Ros1Bridge|FAQ|support|CommunityMeeting|Contributing|Monorepo)/,
2121
},
2222
{
2323
label: "Packages",

0 commit comments

Comments
 (0)