[ROS2 Q&A] 224 – How to source ROS1 & ROS2 side by side

Written by Ruben Alves

22/12/2021

What we are going to learn

  1. How to only source one ROS distro at a time
  2. How to create new ROS2 workspaces

List of resources used in this post

  1. The Construct: https://app.theconstructsim.com/
  2. ROS Development Studio (ROSDS) —▸ http://rosds.online
  3. Robot Ignite Academy –▸ https://www.robotigniteacademy.com
  4. ROS2 Tutorials –▸
    1. https://app.theconstructsim.com/#/Course/61
    2. https://app.theconstructsim.com/#/Course/50
  5. This video answers the following question asked on ROS Answers: https://answers.ros.org/question/389464/why-does-ros2-installsetupbash-source-ros1-and-ros2/

Creating a rosject

In order to learn how to create conditional publishers, let’s start by creating a publisher and a subscriber in Python. We are going to use The Construct (https://www.theconstruct.ai/) for this tutorial, but if you have ROS2 installed on your own computer, you should be able to do ~everything on your own computer, except this creating a rosject part.

Let’s start by opening The Construct (https://www.theconstruct.ai/) and logging in. You can easily create a free account if you still don’t have one.

Once inside, let’s create My Rosjects and then, Create a new rosject:

My Rosjects

My Rosjects

 

Create a new rosject

Create a new rosject

For the rosject, let’s select ROS2 Foxy for the ROS Distro, let’s name the rosject as ROS Q&A 224. You can leave the rosject public.

If you mouse over the recently created rosject, you should see a Run button. Just click that button to launch the rosject.

Checking enviroment configuration

Open a webshell and go to the installation folder of ROS, like shown below:

You can see there are installed two ROS distros, ROS 1 Noetic and ROS 2 Foxy

That means both systems are installed, like the user shown his workspace. Now, open the code editor and check the workspaces:

There are two main workspaces, catkin_ws (for ROS noetic) and ros2_ws (for ROS 2 foxy)

Configuring an environment with both setups

The quickest way to have a ROS environment with both ROS and ROS2 is by creating a new workspace. In the webshell, execute the following:

Open in the IDE the file ~/new_ros2_ws/install/setup.bash. This is a fresh new ROS2 workspace, it does not have ROS noetic attached to it. It is shown in the image below, no ROS commands (e.g: roscore) are available:

You can have as many ROS 2 workspaces as you want and the fresh new workspace built does not have the setup to attache ROS 1 to it, unless you configure to do so.

 

Youtube video

So this is the post for today. Remember that we have the live version of this post on YouTube. If you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.

Keep pushing your ROS Learning.

Topics:
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This