Skip to content

Commit

Permalink
rosbridge_websocket: Stop websocket server if ROS shuts down (backport
Browse files Browse the repository at this point in the history
…#946)

Signed-off-by: Brad Martin <[email protected]>
  • Loading branch information
bmartin427 authored and sea-bass committed Oct 3, 2024
1 parent 9f45b8e commit dc835f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rosbridge_server/scripts/rosbridge_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,13 @@ def main(args=None):

executor = rclpy.executors.SingleThreadedExecutor()
executor.add_node(node)
spin_callback = PeriodicCallback(lambda: executor.spin_once(timeout_sec=0.01), 1)

def spin_ros():
executor.spin_once(timeout_sec=0.01)
if not rclpy.ok():
shutdown_hook()

spin_callback = PeriodicCallback(spin_ros, 1)
spin_callback.start()
try:
start_hook()
Expand Down

0 comments on commit dc835f9

Please sign in to comment.