Sourcing from multiple workspaces
I am just running through the ROS tutorials for Indigo (running on Ubuntu 14.04). In my .bashrc file, I have added the line source ~/catkin_ws/devel/setup.bash
, to source the setup file. If I then run echo $ROS_PACKAGE_PATH
, it gives me /home/karnivaurus/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks
.
However, I also have downloaded another package, located in ~/ROS/src
. I now want to source the setup file for this new package, so that ROS knows to search there if I reference this package. Therefore, I add another line to .bashrc, source ~/ROS/devel/setup.bash
.
The problem is that if I now run echo $ROS_PACKAGE_PATH
again, it gives me /home/karnivaurus/ROS/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks
. So, it seems that the second of the two lines in .bashrc overrides the first, and the package created in the tutorial can no longer be found by ROS.
So the only solution I have come up with is to have all my packages in the same workspace. But this means that I cannot run the tutorial whilst also playing around with some other packages I've downloaded. Is it normal to just have one workspace which contains all packages you have built / downloaded (i.e. other than the ones that come with ROS by default)? Or is there another solution to this?
I have inspected the setup.bash files for both these workspace, and they are identical:
#!/usr/bin/env bash
# generated from catkin/cmake/templates/setup.bash.in
CATKIN_SHELL=bash
# source setup.sh from same directory as this file
_CATKIN_SETUP_DIR=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" > /dev/null && pwd)
. "$_CATKIN_SETUP_DIR/setup.sh"
@jarvisschultz's answer is correct, but you can also pass the
--extend
argument to the setup.bash file and it will only add to the environment rather than set the environment. This can be dangerous though, and I highly recommend you do proper workspace chaining.