# Is there only one catkin_ws can be active ?

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.

Thanks!

edit retag close merge delete

Sort by » oldest newest most voted

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
$<PUT PACKAGE A IN HERE>$ source /opt/ros/<ROSDISTRO>/setup.bash
$catkin_make  2. create another workspace for package $ mkdir ~/catkin_ws_B
$cd ~/catkin_ws_B$ <PUT PACKAGE B IN HERE>
$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.

EDIT

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.

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 ?

( 2018-04-04 09:07:16 -0500 )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!

( 2018-04-04 09:11:01 -0500 )edit

see edit above.

( 2018-04-04 09:55:32 -0500 )edit

It works! Thank you very much!

( 2018-04-04 11:35:52 -0500 )edit