ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A answers.ros.org

# How to chain three catkin workspaces? edit

How do you chain three catkin workspaces so that their setup.bash files don't conflict?

I tried following the instructions in the wiki, but they're a bit confusing and don't seem to be correct.

My workspaces are:

1. the base Kinetic workspace installed into the standard /opt/ros/kinetic location
2. a workspace containing third-party packages not available in kinetic (such as robot_upstart), at /usr/local/mybot/overlay
3. a workspace containing my custom application and packages at /usr/local/mybot/ros

Each workspace builds fine when I run catkin_make inside them. However, I can't source their setup.bash scripts to expose all their packages to ROS.

I'm using:

1. rospack list|grep -i actionlib to determine if the base Kinetic workspace is accessible, called check A.
2. rospack list|grep -i upstart to determine if the second workspace is accessible, called check B.
3. rospack list|grep -i mybot to determine if the third workspace is accessible, called check C.

If I run source /opt/ros/kinetic/setup.bash, then A passes, B fails, and C fails, as expected.

If I then run source /usr/local/mybot/overlay/devel/setup.bash, then A passes, B passes, and C fails, as expected.

If I then run source /usr/local/mybot/ros/devel/setup.bash, then A passes, B fails unexpectedly, but C passes.

So it seems that my third workspace is overwriting the environment set by the second workspace. How do I fix this?

edit retag close merge delete

Sort by » oldest newest most voted

Yes, it is possible to source multiple workspaces and use the combined environment of them. You can source a setup file and pass --extend which will extend the current environment (set by another workspace before) instead of "resetting" the environment.

more

Workspaces don't extend the environment; they set it.

The first time you build a workspace, it captures the existing ROS environment and creates a setup file that overlays the new workspace on the existing environment variables. When you source the setup file from this workspace, it sets the environment variables to overlay this workspace on your previous environment.

This means that you only need to source one setup.bash for the workspace at the top of your set of overlays, and that it will always produce the same environment.

To build your overlay, you should:

1. remove the build and devel directories from your workspaces, to reset them to a clean state
2. source /opt/ros/kinetic/setup.bash and build workspace B
3. source workspace B and build workspace C

To use your overlay, you just need to source the setup file in workspace C

If you need to make minor changes in workspace B, you can rebuild it with any environment, but if you need to to a complete rebuild of workspace B, you should source /opt/ros/kinetic/setup.bash before you do, so that you don't overlay it on your other workspaces.

more

It is possible to extend the environment rather then (re)setting it. Please see other answer.

( 2016-07-04 11:05:40 -0600 )edit
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.41079261898994446, "perplexity": 6892.205403308679}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-47/segments/1542039741764.35/warc/CC-MAIN-20181114082713-20181114104713-00205.warc.gz"}