Ask Your Question

How to source multiple workspaces from the same terminal?

asked 2019-07-06 04:46:41 -0600

khansaadbinhasan gravatar image

I am trying to launch two different nodes from two different workspaces from the same terminal. But once I source my terminal with one of the workspaces, I am not able to use the other packages since the other workspace directory is not sourced anymore.

Even though I saw this answer, it doesn't work for me, maybe since I am using catkin build. Also, I don't want to keep deleting my build, devel spaces.

I have noticed that it may be possible to assign priority of search to ros as two setup.zsh are already sourced source /opt/ros/kinetic/setup.zsh and one of my workspaces. ROS seems to be assigning priority to these while searching for packages.

Can anyone please explain me how sourcing of setup.zsh files work? And how can I find a workaround to my problem or preferably use the method used by ROS itself

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-08 01:33:23 -0600

mgruhler gravatar image

With catkin, the last sourced setup.(z/ba)sh wins. Thus, there is no assignment of priorities or something similar, other than way how you build your workspace.

As explained in detail in #q64702, you can "extend" one workspace with another. But this is a rather unusual usage, from my experience.

More typical is to use "workspace chaining", which is specifying the order of the search path for ROS packages. The answer you linked does explain this behavior, and this is the link to the respective tutorial.

Using catkin_tools this is also doable, though you can/need to be more explicit! The chaining (you also chain the /opt/ros and your source ws, let's call it ~/catkin_ws when working with only one ws) happens implicitely when you have sourced /opt/ros/DISTRO/setup.zsh and call catkin init for the first time. This is what you see in the output of catkin config under the "Extending" listing in catkin_ws.

To change which ws you are extending, simply call catkin config --extend /path/to/new/ws in the workspace that you want to overlay/extend over the others. I.e. if you want to overlay ~/overlay_ws over ~/catkin_ws, call

cd ~/overlay_ws
catkin config --extend ~/catkin_ws/devel
catkin clean # there is no way around deleting your build/devel folders when changing chaining
catkin b

Note that deleting devel and build is required for this to work, but only when changing the chaining.

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

1 follower


Asked: 2019-07-06 04:46:41 -0600

Seen: 202 times

Last updated: Jul 08 '19