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

Revision history [back]

click to hide/show revision 1
initial version

You can not mix the output of catkin_make and catkin build - they are incompatible. You must use one or the other, and fully remove the directories catkin_ws/build/ and catkin_ws/devel/ if you switch between them.

File "/home/-/catkin_ws/devel/lib/test/talker.py", line 15, in <module>

This file path is wrong if using catkin_make - none of the files from your ros package should be in catkin_ws/devel/lib/ for the scenario your describe.

P.S. You are asking for trouble using a ros or python package name of "test". It's theoretically legal, but the probability of an undesired name collision is very close to 1.

You can not mix the output of catkin_make and catkin build - they are incompatible. You must use one or the other, and fully remove the directories catkin_ws/build/ and catkin_ws/devel/ if you switch between them.

File "/home/-/catkin_ws/devel/lib/test/talker.py", line 15, in <module>

This file path is wrong if using catkin_make - none of the files from your ros package should be in catkin_ws/devel/lib/ for the scenario your you describe.

P.S. You are asking for trouble using a ros or python package name of "test". It's theoretically legal, but the probability of an undesired name collision is very close to 1.

  1. Take a look at the content of the files in devel/lib/test/*.py - these are not the .py files you authored, but rather they are generated by catkin_make. Execution is failing because you have the wrong catkin_install_python statement in CMakeLists. It should specify only the "main" .py file for your python ros node (so that catkin can generate a "loader script".)

  2. Do not put a __init__.py in your ros package's scripts/ directory. roslaunch and rosrun do not expect to find a python package there.

  3. You can should not mix the output of catkin_make and catkin build - they are incompatible. You must use one or the other, and fully remove the directories catkin_ws/build/ and catkin_ws/devel/ if you switch between them.

  4. File "/home/-/catkin_ws/devel/lib/test/talker.py", line 15, in <module>

  5. This file path is wrong if using catkin_make - none of the files from your ros package should be in catkin_ws/devel/lib/ for the scenario you describe.

    P.S. You are asking for trouble using a ros or python package name of "test". It's theoretically legal, but the probability of an undesired name collision is very close to 1.high.

  1. Take a look at the content of the files in devel/lib/test/*.py - these

    • In python3, for a ros node consisting of multiple .py files, it looks like there are not the two approaches you can take:

      Path 1. No python module. Do NOT use catkin_install_python in the CMakeLists.txt, and set the executable bit on your main .py file. Importing another python file from the same directory will work. The downside of this simple approach is that the ros package can not be installed to /opt/ros/, but it's fine for development purposes.

      Path 2. Use a python module. Put your .py files you authored, but rather they are generated by catkin_make. Execution is failing because you have the wrong catkin_install_python statement in CMakeLists. It should specify only the "main" .py file for your python ros node (so that catkin can generate a "loader script".)in a python module, add a setup.py to top-level to install the python module, and use catkin_install_python() and catkin_python_setup() in CMakeLists.txt. Your imports must be changed to use the dot-prefix notation (e.g. from .sum import Sum)

    • Do not put a __init__.py in your ros package's scripts/ directory. roslaunch and rosrun do not expect to find a python package there.

    • You should not mix the output of catkin_make and catkin build - they are incompatible. You must use one or the other, and fully remove the directories catkin_ws/build/ and catkin_ws/devel/ if you switch between them.

    • You are asking for trouble using a ros or python package name of "test". It's theoretically legal, but the probability of an undesired name collision is very high.