Python simROS2 subscriber not working

Report crashes, strange behaviour, or apparent bugs
Post Reply
JevJefferson
Posts: 5
Joined: 12 Feb 2024, 20:52

Python simROS2 subscriber not working

Post by JevJefferson »

Hello!

While following this tutorial https://manual.coppeliarobotics.com/en/ros2Tutorial.htm I encountered a problem with a Python subscriber/publisher code (for the reference, the same code but in lua works fine).

Publisher works as supposed, but there is problem with subscriber - as soon as something is published to a subscribed topic I get following error in Coppeliasim terminal:

[CoppeliaSim:error] External call to simCallScriptFunction failed ('_S.reifiedFunctions._f7f9915f82cf0'): error in script function.

What could be the reason for this?

PS I tried to change the subscription topic and send messages there manually (e.g. running in terminal ros2 topic pub -r 10 /simulationTime2 std_msgs/msg/Float32 "{data: '55'}" and variations) - error appears for each time message is published to the topic.

fferri
Posts: 1230
Joined: 09 Sep 2013, 19:28

Re: Python simROS2 subscriber not working

Post by fferri »

There is indeed a problem with Python and simROS2.

As a workaround, you can pass the callback by name (i.e. "subscriber_callback" and not subscriber_callback) and additionally you will need to comment out line 160 of lua/functional.lua.

However, since you are using Python, the best option is to use official python bindings for ROS2, i.e. rclpy.

Post Reply