What is the difference between two setup.bash files ?
In both wiki-ros tutorials and some ros programming textbooks, the first step is to add environment variables of ROS. To do this, we execute the following command: source /opt/ros/indigo/setup.bash
.
After that, we create a workspace, initialize this workspace, and create devel
and build
folders. After completion of these steps, we execute this command: source ~/catkin_ws/devel/setup.bash
.
I investigated these two setup.bash files. Both of them defines two environment variables CATKIN_SHELL
and _CATKIN_SETUP_DIR
. First one is to store the linux command bash
. The main purpose is to specify shell of catkin build tool. The second one is store directory of the file setup.sh
. Namely, it references to this file because all environment variables and hooks and some configuration operations are performed by sourcing this file, which is setup.sh
. Then, I decided to investigate setup.sh
files. They are also same.
In other words, these files contain same shell commands:
/opt/ros/indigo/setup.bash
~/catkin_ws/devel/setup.bash
/opt/ros/indigo/setup.sh
~/catkin_ws/devel/setup.sh
In this case, why do we source the files under the directory devel
?
I don't know what is different about those files, but as for your last question (maybe the most relevant one):
This sets up your environment. You can have multiple workspaces with the same packages, with different changes
Depending on which
setup.bash
you sourced, ROS picks up packages from one or the other workspace. You can also overlay/chain workspaces, and you take the packages from the first workspace in the chain, where they are found. This is what done in the end with/opt/ros
(bottom) andcatkin_ws
(top