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

install python node with colcon

asked 2020-07-31 11:13:00 -0500

luca.fancellu gravatar image

Hi everybody,

I'm developing a simple python node for autoware.ai, so during development I had my catkin workspace folder and to install everything I just used catkin_make command.

Here the folder structure of the node:

node_name/
├── CMakeLists.txt
├── README.md
├── launch
│   └── node_launchfile.launch
├── nodes
│   └── node_name_node.py
├── package.xml
├── setup.py
└── src
    └── node_name
        ├── __init__.py
        ├── package_1
        ├── package_2
        ├── package_3
        └── package_n

The content of setup.py is:

from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup

d = generate_distutils_setup(packages=['node_name'],
                             package_dir={'': 'src'})

CMakeLists.txt contains the python stuff:

find_package(catkin REQUIRED COMPONENTS
    rospy
    std_msgs
    autoware_msgs
)
catkin_python_setup()
...
catkin_install_python(PROGRAMS
    nodes/node_name_node.py
    DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

Now I'm trying to use colcon to build/install the node using:

colcon build --cmake-clean-cache --packages-up-to node_name

But when I run the node then I get:

[ERROR] [1596211499.485229]: Error loading the module package_1:
No module named node_name.package_1

So it seems like that the packages are not installed. Anyone can give me some help?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-07-31 11:23:02 -0500

Dirk Thomas gravatar image

Your setup file explicitly only installs the module node_name - but not any of the submodules.

Instead of explicitly enumerating all submodules you probably want to use setuptools.find_packages() to discover all Python modules automatically and pass them to the packages keyword argument.

edit flag offensive delete link more

Comments

I'm sure that it works, but I end up listing the packages and package dirs by hand and it worked. Thank you for your support

luca.fancellu gravatar image luca.fancellu  ( 2020-08-03 05:43:21 -0500 )edit

Please mark the answer with the check mark on the left of it as answered if it did answer your question.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-08-03 09:50:13 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-31 11:13:00 -0500

Seen: 478 times

Last updated: Jul 31 '20