ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Is there only one catkin_ws can be active ?

asked 2018-04-03 22:33:09 -0600

zcm gravatar image

Hi, everyone! Suppose I have two ros projects to develop at the same time, A and B. B use some exported files of A. But I can't source A and B devel/setup.bash at the same time... And I don't want to put A and B in one catkin_ws.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-04-04 01:02:51 -0600

mgruhler gravatar image

updated 2018-04-04 09:55:26 -0600

This is where you create multiple workspace overlays (i.e. catkin_wss) and use workspace chaining.

Depending on wether you use catkin_make or catkin tools, the workflow is a bit different. I'll demonstrate this with catkin_make.

  1. create your first workspace, i.e. where you put your package A, as you normally would:

    $ mkdir ~/catkin_ws_A
    $ cd ~/catkin_ws_A
    $ source /opt/ros/<ROSDISTRO>/setup.bash
    $ catkin_make
  2. create another workspace for package

    $ mkdir ~/catkin_ws_B
    $ cd ~/catkin_ws_B
    $ source ~/catkin_ws_A/devel/setup.bash   <----- This is the important difference!
    $ catkin_make

Now, you can compile both workspaces independently and B has Access to A (but not the other way around!). Also note that you have to compile first catkin_ws_A and then catkin_ws_B if you change something in package A, thus that it takes effect.

Note that you have to source ~/catkin_ws_B/devel/setup.bash to accomplish this. Just sourcing caktin_ws_A will be your regular one workspace layout.

There are some side-effects regarding build artifacts, thus I'd recommend you read the wiki page linked above (section 4) carefully. But all in all, this works pretty well.


When you already have two workspaces, make sure to delete any build/devel/install/logs folders in caktin_ws_B, as well as the top-Level CMakeLists.txt. You need to create the chaining from a clean workspace. And don't to forget to source ~/catkin_ws_A/devel/setup.bash before calling catkin_make in caktin_ws_B in the same terminal.

edit flag offensive delete link more


Thanks for your reply! When I first source ~/catkin_ws_A/devel/setup.bash, $ROS_PACKAGE_PATH shows ~/catkin_ws_A/src : /opt/ros/kinetic/share, so I can rosrun nodes in A. But when I later source ~/catkin_ws_B/devel/setup.bash, $ROS_PACKAGE_PATH shows ~/catkin_ws_B/src : /opt/ros/kinetic/share ?

zcm gravatar image zcm  ( 2018-04-04 09:07:16 -0600 )edit

I can rosrun nodes in B after source ~/catkin_ws_B/devel/setup.bash, but these nodes import modules from A, the $ROS_PACKAGE_PATH doesn't include ~/catkin_ws_A/src then, so can't find these modules... I don't know what I did wrong. Thanks!

zcm gravatar image zcm  ( 2018-04-04 09:11:01 -0600 )edit

see edit above.

mgruhler gravatar image mgruhler  ( 2018-04-04 09:55:32 -0600 )edit

It works! Thank you very much!

zcm gravatar image zcm  ( 2018-04-04 11:35:52 -0600 )edit

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: 2018-04-03 22:33:09 -0600

Seen: 1,254 times

Last updated: Apr 04 '18