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

What is the difference between two setup.bash files ?

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

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 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 ?

edit retag flag offensive close merge delete

Comments

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 -0500 )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 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

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

jotator gravatar image

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

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

Question Tools

2 followers

Stats

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

Seen: 1,469 times

Last updated: Jan 21 '19