ROS 2 custom message build error "abc" package
Hello,
I am testing creation of custom message packages in ROS 2 with colcon tools.
I have 2 test packages:
- abc/MyMsg.msg - custom message package named "abc" that contains a message "MyMsg.msg"
- useabcmsg/UseMyMsg.msg - custom message package named "useabcmsgs" contains a message "UseMyMsg.msg" that refers to "abc/MyMsg".
I get strange python errors when building this simple hierarchy of custom message packages. Errors are shown below:
Starting >>> abc [Processing: abc] Finished <<< abc [38.7s] Starting >>> use_abc_msgs --- stderr: use_abc_msgs Fatal Python error: init_sys_streams: can't initialize sys standard streams Traceback (most recent call last): File "C:\Python37\lib\io.py", line 72, in**AttributeError: module 'abc' has no attribute 'ABCMeta'** CMake Error at C:/dev/ros2/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message): execute_process(C:/Python37/python.exe C:/dev/ros2/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py C:/test/build/use_abc_msgs/ament_cmake_package_templates/templates.cmake) **returned error code Exit code 0xc0000409** Call Stack (most recent call first): C:/dev/ros2/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:38 (include) C:/dev/ros2/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package) C:/dev/ros2/share/ament_cmake/cmake/ament_cmakeConfig.cmake:38 (include) CMakeLists.txt:19 (find_package)
I don't understand how Python Abstract Base Classes are invoked.
I found a similar posting related to ROS 1 Catkin, but did not see a satisfactory solution.
System environment
Operating System: Windows 10
ROS 2 version: Dashing (built from sources)
CMake version: 3.14.7
Python version: 3.7.2
I have attached the zip archive testcustommsg.zip that shows this issue:
Reproduction steps:
- Extract the zip-archive.
- Change folder to the extracted archive.
- Run local_setup.bat or setup.bash for ROS 2 (I'm sure this is platform independent).
- Run "colcon build --merge-install".
Any guidance will be greatly appreciated.
Thanks.
Asked by A.G. on 2019-11-18 12:02:22 UTC
Answers
Your package name is abc
and the Python code generated for the message will end up in the abc
namespace. Python already contains a package named abc which it needs to find. Your package collides with that and therefore prevents Python from working.
Hence you should rename your package to something not colliding with Python names (if it contains Python code / messages).
Asked by Dirk Thomas on 2019-11-18 16:02:14 UTC
Comments
@Dirk Thomas: would it be possible to check for these sort of collisions ahead of time, so as to avoid late user-facing errors such as the one reported by OP? Python has a list available of builtins
and keywords
. Same for C++ and other languages.
Checking whether something can be loaded as a module (in Python specifically) should also be possible.
It would enhance the user experience significantly.
Asked by gvdhoorn on 2019-11-18 16:18:59 UTC
abc
is neither a builtin
not a keyword
. It is just a Python package distributed with Python as part of the core libraries. It would be great if that case could be catched - any proposals where and how that should happen are very welcome.
Asked by Dirk Thomas on 2019-11-18 16:21:39 UTC
abc
is neither abuiltin
not akeyword
. It is just a Python package distributed with Python as part of the core libraries.
I know. But it would be equally beneficial to check for builtin
s and keyword
s.
Especially novice users are easily confused by these sorts of errors.
Asked by gvdhoorn on 2019-11-18 16:29:40 UTC
Comments