Skip to content

Commit

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

Signed-off-by: Brad Martin <[email protected]>
  • Loading branch information
bmartin427 authored Aug 15, 2024
1 parent 974c6b7 commit 8b0b4c5
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 8b0b4c5

Please sign in to comment.