splintered-reality / py_trees_ros

ROS extensions and implementations for py_trees
Other
143 stars 40 forks source link

Blackboard watcher crashes on CTRL-C #185

Closed stonier closed 1 year ago

stonier commented 1 year ago

Distro: Jammy/Humble To Reproduce

# First Shell
$ ros2 launch py_trees_ros_tutorials tutorial_one_data_gathering_launch.py

# Second Shell
$ py-trees-blackboard-watcher
CTRL-C
^CTraceback (most recent call last):
  File "/workspace/install/py_trees_ros/bin/py-trees-blackboard-watcher", line 33, in <module>
    sys.exit(load_entry_point('py-trees-ros', 'console_scripts', 'py-trees-blackboard-watcher')())
  File "/workspace/build/py_trees_ros/py_trees_ros/programs/blackboard_watcher.py", line 196, in main
    request, client = blackboard_watcher.create_service_client('close')
  File "/workspace/build/py_trees_ros/py_trees_ros/blackboard.py", line 482, in create_service_client
    client = self.node.create_client(
  File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/node.py", line 1417, in create_client
    client_impl = _rclpy.Client(
rclpy._rclpy_pybind11.RCLError: failed to create client: rcl node's context is invalid, at ./src/rcl/node.c:428

Haven't checked to see if this also happens in Foxy.

stonier commented 1 year ago

Humble doesn't give you space between a KeyboardInterrupt and rclpy.shutdown for this kind of operation any longer.

Workaround - get the blackboard to eliminate publishers and views if the number of subscribers goes to zero.

Probably worth noting that I didn't like this solution before. I think it was something to do with unstable wifi connectivity (no way of the watcher knowing it's been brutally disconnected)?