ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Are you actually using rclpy.spin()
in the spawned thread?
If I'm getting this right, in the spawned thread you're trying to spin()
once again the same node calling this function (as for the argument self
). With the info provided, I'm not sure that will work.
I could be wrong, given I don't have the full picture, but... I don't actually see the point of using an explicit thread here. Even if the node you're coding can be both the subscriber and the publisher to the /var_values
thread (in two different configurations), using the MultiThreadExecutor
you can just add two nodes before spinning. Something like:
executor = MultiThreadedExecutor()
executor.add_node(sub_node)
executor.add_node(pub_node)
rclpy.spin()
Some useful stuff about executors and callback groups:
An open class by The Construct
ROS2 documentation (humble only because that's what I'm using now)
As an additional information judging by the log print, the join()
does not terminate the thread, it actually waits for its termination before going on.