ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Trouble installing ROS2 alongside ROS1

asked 2020-04-25 01:56:33 -0600

I have ROS Melodic on my Ubuntu 18.04, I installed ROS2 Eloquent and I get the following mistake//warning:

r4t@R4T:~$ source /opt/ros/eloquent/setup.bash 
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.

Then I do eng |grep ROS as mentioned on another thread, and I get

   ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=2
ROS_LOCALHOST_ONLY=0
ROS_PYTHON_VERSION=3
ROS_PACKAGE_PATH=/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=
ROS_DISTRO=eloquent

I don't know if the environment is configured correctly since everything it's kind of pointing out to Melodic version

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2020-04-25 04:46:53 -0600

gvdhoorn gravatar image

It's likely you have source /opt/ros/melodic/setup.bash at the end of your .bashrc (which is added at the end of the Environment Setup section of the ROS 1 installation instructions).

With just a single ROS version installed, that will be convenient (as it prevents you from having to type source /opt/ros/melodic/setup.bash in every new terminal).

However, with multiple ROS versions installed (and this goes for both multiple ROS 1 and ROS 2 versions and a mix of those), it will cause issues such as the one you encountered.

I would recommend to remove the auto-source-ing from your .bashrc, and manually source the setup file of the ROS version you want to work with instead.

edit flag offensive delete link more

Comments

I've removed the .bashrc autocompletion and it still keeps on telling me that the distro was set to eloquent, I've even deleted eloquent from my computer and the same keeps occurring.

blancoys gravatar image blancoys  ( 2020-08-18 03:07:20 -0600 )edit
1

I've removed the .bashrc autocompletion [..]

Bash auto-completion is an integral part of the Ubuntu UX in the shell. I would not remove it.

If you've actually removed the source /opt/ros/melodic/setup.bash line, that should have helped.

gvdhoorn gravatar image gvdhoorn  ( 2020-08-18 03:17:47 -0600 )edit

To make sourcing the right distro process easier for me, I've added

function sr1 {                                                                  
        source /opt/ros/melodic/setup.bash                                      
}                                                                               

function sr2 {                                                                  
        source /opt/ros/eloquent/local_setup.bash
}

to my .bashrc file. Now I just need to sr1 to source melodic, and sr2 to source eloquent.

ChuiV gravatar image ChuiV  ( 2021-06-21 09:08:26 -0600 )edit

Hi @ChuiV, how do you set the default call? Because, bashrc would be sourced every time I open a terminal right, so there needs to be a default option unless otherwise specified...

androadi gravatar image androadi  ( 2022-02-25 01:34:41 -0600 )edit

I don't actually set a "default" ros distro in my bashrc. I'm typically switching between them frequently that it makes sense for me to not source anything by default. When I need a terminal to use ros1, I just have to run sr1 or if I need ros2, I just need to do sr2. My goal with those bash functions was to make it as easy as possible to source the ros version I need.

ChuiV gravatar image ChuiV  ( 2022-02-25 10:01:04 -0600 )edit
0

answered 2021-03-10 07:04:03 -0600

Ogunniran gravatar image

I had the same problem with Foxy and Neotic. To solve it;

  • Remove Neotic and Foxy source from bash
  • In Foxy worskspace install/setup.bash (line22) COLCON_CURRENT_PREFIX="/opt/ros/noetic" change noetic to foxy
  • Delete and reinstall neotic

sudo apt-get remove ros-noetic-*

  • Source the workspace correctly.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-04-25 01:56:33 -0600

Seen: 2,400 times

Last updated: Mar 10 '21