Ask Your Question
0

[ROS2] colcon build not getting subfolders

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

vKuehn gravatar image

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

Hi,

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 combine_two_strings.py works fine

but the service combine_two_strings_server.py

failes with 'No module named combiner'

Thanks for any hint on that

edit retag flag offensive close merge delete

Comments

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 imagegvdhoorn ( 2019-03-29 04:58:16 -0600 )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 imagegvdhoorn ( 2019-03-29 04:59:12 -0600 )edit

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

vKuehn gravatar imagevKuehn ( 2019-03-31 14:10:23 -0600 )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 imagetfoote ( 2019-03-31 14:19:27 -0600 )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 imagevKuehn ( 2019-04-01 03:27:29 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

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 (setup.py) 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

Comments

Since you're nesting content inside the package everything needs to be caputured in your setup.py. 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 setup.py is not installing all your resources then it could give you that error.

tfoote gravatar imagetfoote ( 2019-04-01 13:11:48 -0600 )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 imagevKuehn ( 2019-04-02 04:11:28 -0600 )edit

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

vKuehn gravatar imagevKuehn ( 2019-04-03 05:44:40 -0600 )edit

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

Stats

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

Seen: 208 times

Last updated: Apr 01