Skip to content

Running ROS 1 Noetic and ROS 2 Foxy From Source on Ubuntu 20.04

Running both ROS 1 (Noetic) and ROS 2 (Foxy) on the same machine can be a rewarding yet challenging experience. The differences in dependencies, environment variables, and message-passing architectures make dual installations tricky to manage. However, Ubuntu 20.04 remains the ideal operating system for this setup — it is the native LTS release for both distributions: ROS 1 Noetic (the final ROS 1 release) and ROS 2 Foxy (an LTS version supported until 2025).

This guide will walk you through the process of building both distributions from source, managing your environments cleanly, and establishing a ROS 1–ROS 2 bridge for interoperability between the two ecosystems.


🧠 Key Topics Covered

  • Installing ROS 1 Noetic from source
  • Installing ROS 2 Foxy from source
  • Managing environment variables and avoiding conflicts
  • Running a ROS 1–ROS 2 bridge for hybrid communication

1. Installing ROS 1 Noetic From Source

Step 1: Install Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y python3-rosdep python3-rosinstall-generator \
python3-vcstool build-essential

Initialize rosdep:

sudo rosdep init
rosdep update

Step 2: Create a Workspace and Clone ROS 1

mkdir -p ~/ros1_noetic/src
cd ~/ros1_noetic
rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic.rosinstall
vcs import --input noetic.rosinstall src
rosdep install --from-paths src --ignore-src -r -y

Step 3: Build ROS 1

cd ~/ros1_noetic
colcon build --symlink-install

Step 4: Source ROS 1

echo 'source ~/ros1_noetic/install/setup.bash' >> ~/.bashrc
source ~/.bashrc

Verify:

echo $ROS_DISTRO
# Output: noetic

2. Installing ROS 2 Foxy From Source

ROS 2 uses a completely different middleware (DDS), so we install it in a separate workspace.

Step 1: Install Dependencies

sudo apt install -y python3-colcon-common-extensions \
python3-vcstool git wget

Step 2: Create a Workspace and Clone ROS 2

mkdir -p ~/ros2_foxy/src
cd ~/ros2_foxy
vcs import src < https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos
rosdep install --from-paths src --ignore-src -r -y

Step 3: Build ROS 2

cd ~/ros2_foxy
colcon build --symlink-install

Step 4: Source ROS 2

echo 'source ~/ros2_foxy/install/setup.bash' >> ~/.bashrc
source ~/.bashrc

Verify:

echo $ROS_DISTRO
# Output: foxy

3. Managing ROS 1 and ROS 2 Environments

Since both ROS versions define overlapping environment variables, sourcing them simultaneously will cause conflicts. There are two main ways to handle this.

Option 1: Use Aliases

Add the following to your ~/.bashrc:

alias source_ros1="source ~/ros1_noetic/install/setup.bash"
alias source_ros2="source ~/ros2_foxy/install/setup.bash"

Then simply switch between versions:

source_ros1  # Activates ROS Noetic
source_ros2  # Activates ROS 2 Foxy

Option 2: Use Separate Terminals

For simultaneous development:

  • Terminal 1 (ROS 1 Noetic):
source ~/ros1_noetic/install/setup.bash
roscore
  • Terminal 2 (ROS 2 Foxy):
source ~/ros2_foxy/install/setup.bash
ros2 run demo_nodes_cpp talker

This method keeps each ROS environment isolated and prevents variable overlap.


4. Running the ROS 1–ROS 2 Bridge

The ros1_bridge package allows ROS 1 and ROS 2 nodes to communicate seamlessly.

Step 1: Install the Bridge

source_ros1
source_ros2
sudo apt install -y ros-foxy-ros1-bridge

Step 2: Run the Dynamic Bridge

ros2 run ros1_bridge dynamic_bridge

Now, any topic published in ROS 1 will be visible in ROS 2, and vice versa. You can verify this using:

rostopic list   # In ROS 1 terminal
ros2 topic list # In ROS 2 terminal

5. Debugging Common Issues

❌ Problem: ROS 1 and ROS 2 Variables Overlapping

Fix: Only source one at a time, or use separate terminals.

⚙️ Problem: colcon build Fails

Fix: Ensure all dependencies are installed:

rosdep update
rosdep install --from-paths src --ignore-src -r -y

🔄 Problem: ROS 1–ROS 2 Bridge Fails to Start

Fix:

  • Confirm both source_ros1 and source_ros2 have been sourced.
  • Restart the bridge with:
ros2 run ros1_bridge dynamic_bridge

🚀 Conclusion

By carefully isolating environments and using aliases or separate terminals, you can run ROS 1 Noetic and ROS 2 Foxy side-by-side without conflicts. Building both distributions from source ensures full control over your workspace, and the ros1_bridge enables cross-version communication for hybrid development.

Whether you’re maintaining legacy ROS 1 systems or transitioning to ROS 2, this dual setup keeps your workflow future-proof and flexible.

Happy Coding and Exploring ROS! 🤖

Comments