Skip to main content
Version: Next

Stop Autonomy

Stop (cancel) all autonomy related actions.

import rclpy
from rclpy.node import Node

from std_srvs.srv import Trigger


class StopAutonomy(Node):

def __init__(self):
super().__init__('stop_autonomy_client')
self._srv_client = self.create_client(Trigger, 'autonomy/stop')
while not self._srv_client.wait_for_service(timeout_sec=1.0):
self.get_logger().info('service not available, waiting again...')
self.req = Trigger.Request()

def send_request(self):
self.future = self._srv_client.call_async(self.req)
rclpy.spin_until_future_complete(self, self.future)
return self.future.result()

if __name__ == '__main__':
rclpy.init(args=args)
stop_autonomy_client = StopAutonomy()
response = stop_autonomy_client.send_request()
if response.success:
stop_autonomy_client.get_logger().info('Autonomy stopped!'))
else:
stop_autonomy_client.get_logger().error('Autonomy failed to stop!')

stop_autonomy_client.destroy_node()
rclpy.shutdown()