ROS2 separate directory for Python nodes

asked 2022-08-29 10:02:15 -0500

martinandrovich gravatar image

updated 2022-08-30 10:13:29 -0500

Is it possible to have a separate directory for Python nodes in ROS2 (foxy)?

python_pkg/
│
├─ python_pkg/
│  ├─ __init__.py
│  ├─ my_module.py
│  └─ hello_world.py
|
├─ nodes/
│  ├─ __init__.py
│  └─ simple_node.py
|
└─ ...

In setup.py I have tried adding:

setup(
    name="python_pkg",
    ...
    entry_points={
        'console_scripts': [
                'hello_world = python_pkg.hello_world:main',
                'simple_node = nodes.simple_node:main',
        ],
},
)

If I source the workspace and run ros2 run python_pkg simple_node I get the error ModuleNotFoundError: No module named 'nodes'.

edit retag flag offensive close merge delete