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

Build a package within another package.

asked 2021-06-21 20:45:07 -0500

bscout2011 gravatar image

I am developing a robot controller that depends on several source code repositories. My folder structure looks like this

/catkin_ws
 - /src
  - /robot_controller
   - CMakeLists.txt
   - package.xml
   - /my_source_code
   - /package_from_github_A
   - /package_from_github_B

Running catkin build will only detect the /robot_controller package and it will not detect the source files from github_A or B. For example, I cannot run rosrun package_from_github_A node1.

Is there a way to reveal these packages to the build system without reorganizing my folders?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2021-06-22 03:09:01 -0500

gvdhoorn gravatar image

updated 2021-06-23 03:00:13 -0500

You could see whether using symlinks to get package_from_github_A up to catkin_ws/src level, but tbh I would not recommend you do that.

Nesting packages like this is expressly not supported. Not in ROS 1, nor in ROS 2 (or to be more precise: not by Catkin, nor Colcon/Ament).

From #q319867:

A ROS package is defined as a directory with a package.xml file. Similar to how a CMake package (CMakeLists.txt) and Python package (setup.py) file is defined. Everything recursively under that directory is part of that package. As a consequence packages can't be nested.

Another related Q&A: #q259586.

I'm guessing the nested structure comes from using git sub modules?


Edit:

Yes, these are submodules. My idea is to make it easy to download our source code by having the necessary includes as nested within the package. I’m guessing the standard way to structure these packages is to keep all root package folders just below src?

That would be one option.

More commonly people use something like vcstool to populate their workspace.

See also #q347421 and the linked Q&As in the accepted answer there.

Creating, populating and building a ROS workspace can be done in about 4 to 5 commands. That's a very good compromise which gets you a lot of flexibility without encoding the structure of your workspace in a VCS.

edit flag offensive delete link more

Comments

Yes, these are submodules. My idea is to make it easy to download our source code by having the necessary includes as nested within the package. I’m guessing the standard way to structure these packages is to keep all root package folders just below src?

bscout2011 gravatar image bscout2011  ( 2021-06-22 10:30:38 -0500 )edit
0

answered 2021-06-22 15:42:20 -0500

Mike Scheutzow gravatar image

updated 2021-06-22 15:47:33 -0500

I am 99% sure you can not nest one catkin package within another, but you can have 3 packages under the robot_controller directory. The robot_controller dir must not have a CMakeLists.txt or package.xml. Each catkin package gets their own subtree, and each will have a distinct CMakeLists.txt and package.xml file.

edit flag offensive delete link more

Comments

To be a bit pedantic, you can nest a catkin package within another catkin package if the root package is a metapackage

jayess gravatar image jayess  ( 2021-06-22 18:17:25 -0500 )edit
1

No, even then you can't and you shouldn't.

Metapackages do not do anything special.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-23 02:54:55 -0500 )edit
1

@gvdhoorn touché. Thanks for reminding me

jayess gravatar image jayess  ( 2021-06-23 14:28:09 -0500 )edit

Question Tools

Stats

Asked: 2021-06-21 20:45:07 -0500

Seen: 1,847 times

Last updated: Jun 23 '21