15 #include "rclcpp/service.hpp"
23 #include "rclcpp/any_service_callback.hpp"
24 #include "rclcpp/macros.hpp"
25 #include "rclcpp/qos.hpp"
26 #include "rmw/error_handling.h"
31 ServiceBase::ServiceBase(std::shared_ptr<rcl_node_t> node_handle)
32 : node_handle_(node_handle),
38 ServiceBase::take_type_erased_request(
void * request_out, rmw_request_id_t & request_id_out)
47 rclcpp::exceptions::throw_from_rcl_error(ret);
58 std::shared_ptr<rcl_service_t>
61 return service_handle_;
64 std::shared_ptr<const rcl_service_t>
67 return service_handle_;
71 ServiceBase::get_rcl_node_handle()
73 return node_handle_.get();
77 ServiceBase::get_rcl_node_handle()
const
79 return node_handle_.get();
85 return in_use_by_wait_set_.exchange(in_use_state);
91 const rmw_qos_profile_t * qos =
95 std::string(
"failed to get service's response publisher qos settings: ") +
96 rcl_get_error_string().str;
98 throw std::runtime_error(msg);
104 return response_publisher_qos;
110 const rmw_qos_profile_t * qos =
114 std::string(
"failed to get service's request subscription qos settings: ") +
115 rcl_get_error_string().str;
117 throw std::runtime_error(msg);
123 return request_subscription_qos;
130 service_handle_.get(),
135 rclcpp::exceptions::throw_from_rcl_error(
136 ret,
"failed to set the on new request callback for service");
Encapsulation of Quality of Service settings.
RCLCPP_PUBLIC bool exchange_in_use_by_wait_set_state(bool in_use_state)
Exchange the "in use by wait set" state for this service.
RCLCPP_PUBLIC rclcpp::QoS get_request_subscription_actual_qos() const
Get the actual request subscription QoS settings, after the defaults have been determined.
RCLCPP_PUBLIC rclcpp::QoS get_response_publisher_actual_qos() const
Get the actual response publisher QoS settings, after the defaults have been determined.
void set_on_new_request_callback(std::function< void(size_t)> callback)
Set a callback to be called when each new request is received.
RCLCPP_PUBLIC std::shared_ptr< rcl_service_t > get_service_handle()
Return the rcl_service_t service handle in a std::shared_ptr.
RCLCPP_PUBLIC const char * get_service_name()
Return the name of the service.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC Logger get_node_logger(const rcl_node_t *node)
Return a named logger using an rcl_node_t.
RCL_PUBLIC RCL_WARN_UNUSED const rmw_qos_profile_t * rcl_service_request_subscription_get_actual_qos(const rcl_service_t *service)
Get the actual qos settings of the service's request subscription.
RCL_PUBLIC RCL_WARN_UNUSED const char * rcl_service_get_service_name(const rcl_service_t *service)
Get the topic name for the service.
RCL_PUBLIC RCL_WARN_UNUSED const rmw_qos_profile_t * rcl_service_response_publisher_get_actual_qos(const rcl_service_t *service)
Get the actual qos settings of the service's response publisher.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_service_set_on_new_request_callback(const rcl_service_t *service, rcl_event_callback_t callback, const void *user_data)
Set the on new request callback function for the service.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_take_request(const rcl_service_t *service, rmw_request_id_t *request_header, void *ros_request)
Backwards compatibility function to take a pending ROS request using a rcl service.
Structure which encapsulates a ROS Node.
static QoSInitialization from_rmw(const rmw_qos_profile_t &rmw_qos)
Create a QoSInitialization from an existing rmw_qos_profile_t, using its history and depth.
#define RCL_RET_OK
Success return code.
#define RCL_RET_SERVICE_TAKE_FAILED
Failed to take a request from the service return code.
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.