How to structure python ros package to include python packages


I’m trying to build a python3 ros2 foxy package with my own custom python package inside, but when I’m not sure how to reference it in code.

for example I have the following folder structure

      - ros_package_name
        -> python_package_name

In my I have

import ros_package_name.python_package_name.helper

but if I try to run things it says ModuleNotFoundError

Looking into the install path, colcon hasn’t copied python_package_name

I could probably modify PYTHONPATH, but is there a way to tell colcon to just copy things properly instead?

Try this statement instead:

import python_package_name.helper

since you are running from the directory ros_package_name.