ROS2-foxy msg interface builds but package has TypeError when run

asked 2021-07-09 16:30:05 -0500

Clark_Clark gravatar image

I am taking an online course "ROS2 for Beginners by Edourd Renard". Almost the same procedure for making custom message interfaces is at this site: [https://roboticsbackend.com/ros2-crea...]

I am able to build my interface called "clark_interfaces" using colcon and I verify my three data fields using interface show.

mnclark@ubuntu-clark:~$ ros2 interface show clark_interfaces/msg/HardwareStatus int64 temperature bool are_motors_ready string debug_message

My python file that uses my simple custom message is "hw_status_publisher.py" . Auto-complete finds it because I added the extension in my "settings.json" file. I add the line below to hw_statuspublisher.py file .

from clark_interfaces.msg import HardwareStatus

Both my CMakeLists,txt and package.xml files have the changes the tutorial and on-line class require.

The following command fails

* ros2 run my_py_pkg hw_status_publisher *

The result is:

Traceback (most recent call last): File "/home/mnclark/ros2_ws/install/my_py_pkg/lib/my_py_pkg/hw_status_publisher", line 11, in <module> load_entry_point('my-py-pkg', 'console_scripts', 'hw_status_publisher')()

File "/home/mnclark/ros2_ws/build/my_py_pkg/my_py_pkg/hw_status_publisher.py", line 25, in main node = HardwareStatusPublisherNode()

File "/home/mnclark/ros2_ws/build/my_py_pkg/my_py_pkg/hw_status_publisher.py", line 10, in __init__ super().__init__("hardware_status_publisher")

TypeError: object.__init__() takes exactly one argument (the instance to initialize)

//----- I am using Ubuntu 20 with the foxy distro and visual code for my IDE within VMware Fusion. The error appears to be with how the interface was built because the reference points to artifacts in the build and install folders. The TypeError might be a clue but I've repeated several times through out the day. I can only think to try Ubuntu 18 although I did a recent udate/upgrade on my Ubuntu 20. Could this be a python issue and not ROS?

edit retag flag offensive close merge delete