Ask Your Question

What is the difference between two setup.bash files ?

asked 2019-01-20 12:45:38 -0600

gktg1514 gravatar image

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 Namely, it references to this file because all environment variables and hooks and some configuration operations are performed by sourcing this file, which is Then, I decided to investigate 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/ ~/catkin_ws/devel/

In this case, why do we source the files under the directory devel ?

edit retag flag offensive close merge delete


I don't know what is different about those files, but as for your last question (maybe the most relevant one):

In this case, why do we source the files under the directory devel ?

This sets up your environment. You can have multiple workspaces with the same packages, with different changes

mgruhler gravatar image mgruhler  ( 2019-01-21 01:20:26 -0600 )edit

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) and catkin_ws (top

mgruhler gravatar image mgruhler  ( 2019-01-21 01:22:12 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-21 02:00:44 -0600

jotator gravatar image

updated 2019-01-21 02:05:21 -0600

The purpose of the setup files is to provide a means to add workspaces to the environment so the packages and tools they contain are available for use.

The setup file contained in /opt/ros/$DISTRO is associated to the corresponding ROS distro (in your case, Indigo Igloo). By sourcing it, the tools and packages included in the distro become available in the current environment and you can, for example:

-> Call any ROS tool included in the distro directly ("rostopic", for example) -> You can know build packages not included in your base distro because all the build tools and variables are part of the environment -> Any ROS tool you want to use (like rostopic) now can be used -> Some of the variables set are required for your node executables to work, including the essential "roscore"

The additional setup files are exactly the same, but each one is associated to its own workspace, which can contain any packages you want. This means that, after sourcing your base distro, you can then decide to add more workspaces to your current environment: if you source the setup.bash inside your catkin_ws directory, all packages contained in it become available in the current environment on top of any other you had before.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-01-20 12:45:38 -0600

Seen: 542 times

Last updated: Jan 21 '19