rclpy.service module
- class rclpy.service.Service(service_impl: rpyutils.import_c_library.Service, srv_type: Type[Srv[SrvRequestT, SrvResponseT, SrvEventT]], srv_name: str, callback: Callable[[SrvRequestT, SrvResponseT], SrvResponseT], callback_group: CallbackGroup, qos_profile: rclpy.qos.QoSProfile)
Bases:
Generic
[SrvRequestT
,SrvResponseT
,SrvEventT
]Create a container for a ROS service server.
Warning
Users should not create a service server with this constructor, instead they should call
Node.create_service()
.- Parameters:
service_impl –
_rclpy.Service
wrapping the underlyingrcl_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() None
Destroy a container for a ROS service server.
Warning
Users should not destroy a service server with this destructor, instead they should call
Node.destroy_service()
.
- property handle
- send_response(response: SrvResponseT, 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.
- property service_name: str