Robotics StackExchange | Archived questions

ROS2 separate directory for Python nodes

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'.

Asked by martinandrovich on 2022-08-29 10:02:15 UTC

Comments

Answers