rclpy.service module

class rclpy.service.Service(service_impl: rpyutils.import_c_library.Service, srv_type: SrvType, srv_name: str, callback: Callable[[SrvTypeRequest, SrvTypeResponse], SrvTypeResponse], callback_group: CallbackGroup, qos_profile: rclpy.qos.QoSProfile)

Bases: object

Create a container for a ROS service server.

Warning

Users should not create a service server with this constuctor, instead they should call Node.create_service().

Parameters:
  • service_impl_rclpy.Service wrapping the underlying rcl_service_t object.

  • srv_type – The service type.

  • srv_name – The name of the service.

  • callback – The callback that should be called to handle the request.

  • callback_group – The callback group for the service server. If None, then the nodes default callback group is used.

  • qos_profile – The quality of service profile to apply the service server.

configure_introspection(clock: rclpy.clock.Clock, service_event_qos_profile: rclpy.qos.QoSProfile, introspection_state: rpyutils.import_c_library.service_introspection.ServiceIntrospectionState) None

Configure service introspection.

Parameters:
  • clock – Clock to use for generating timestamps.

  • service_event_qos_profile – QoSProfile to use when creating service event publisher.

  • introspection_state – ServiceIntrospectionState to set introspection.

destroy()
property handle
send_response(response: SrvTypeResponse, header) None

Send a service response.

Parameters:
  • response – The service response.

  • header – Service header from the original request.

Raises:

TypeError if the type of the passed response isn’t an instance of the Response type of the provided service when the service was constructed.