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

[ROS2] colcon build not getting subfolders

asked 2019-03-29 04:16:52 -0500

vKuehn gravatar image

updated 2019-04-01 03:24:59 -0500


once a python package grows I would like to get files in module subfolders below the package. Also maybe other ressources as config or picture files would be good

How could I develop modules below the ros2 package make available to the ros2 package ?

To verify I have created that example package try_srv

where the test script works fine

but the service

failes with 'No module named combiner'

Thanks for any hint on that

edit retag flag offensive close merge delete


Please do not post screenshots of terminal text. It's all text, so just copy-paste it into your question.

As-is, your question now violates the Support Guidelines.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-29 04:58:16 -0500 )edit

Also please note: SUBPACKAGE in your screenshot is typically called module in Python. If you really meant "sub package", then nested packages are not supported.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-29 04:59:12 -0500 )edit

ok will remember the no screen shot policy next time. Is there a possibility to write my own modules ?

vKuehn gravatar image vKuehn  ( 2019-03-31 14:10:23 -0500 )edit

@vKuehn please edit your post so we can help you better. You can definitely write your own modules and embed them in the packages. It works like any other python package.

tfoote gravatar image tfoote  ( 2019-03-31 14:19:27 -0500 )edit

@tfoote edited the post for clarification. I have also linked a very simple example to github where the failure can be reproduced / understood better. thanks for any review /hint

vKuehn gravatar image vKuehn  ( 2019-04-01 03:27:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-04-01 11:16:24 -0500

Dirk Thomas gravatar image

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

Either you place multiple packages beside each other into sibling directories (see e.g. the ament_lint repository which contains numerous packages in sibling directories on the top level) or you keep adding content (like additional Python modules) to an existing package (see e.g. the launch package which contains many Python module below the launch subdirectory).

edit flag offensive delete link more


Since you're nesting content inside the package everything needs to be caputured in your I suspect that your different behavior is related to whether your PYTHON_PATH of your invocation and whether you're using the source space (ala the script) or the install space (ala the service) and if your is not installing all your resources then it could give you that error.

tfoote gravatar image tfoote  ( 2019-04-01 13:11:48 -0500 )edit

thanks a lot to both of you guys ! Still not completetly sure why I saw that problem in a rospackage as I called the module as always (import from subfolders classes) Will look at the launch approach as it looks similiar

vKuehn gravatar image vKuehn  ( 2019-04-02 04:11:28 -0500 )edit

made it work now so thanks again. For those interested the github in my question is now the working example

vKuehn gravatar image vKuehn  ( 2019-04-03 05:44:40 -0500 )edit

Question Tools

1 follower


Asked: 2019-03-29 04:16:52 -0500

Seen: 4,885 times

Last updated: Apr 01 '19