Template Class BasicService

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

  • public std::enable_shared_from_this< BasicService< ServiceT, BridgeRequestPolicy > >

Class Documentation

template<typename ServiceT, typename BridgeRequestPolicy>
class BasicService : public std::enable_shared_from_this<BasicService<ServiceT, BridgeRequestPolicy>>

Public Types

using SharedPtr = std::shared_ptr<BasicService<ServiceT, BridgeRequestPolicy>>

Public Functions

template<typename Func>
inline BasicService(rclcpp::Node *node, const std::string &service_name, Func &&callback, const rclcpp::QoS &qos, rclcpp::CallbackGroup::SharedPtr group)
template<typename Func>
inline BasicService(agnocast::Node *node, const std::string &service_name, Func &&callback, const rclcpp::QoS &qos, rclcpp::CallbackGroup::SharedPtr group)
inline AGNOCAST_PUBLIC void send_response (ipc_shared_ptr< typename ServiceT::Request > &&request, ipc_shared_ptr< typename ServiceT::Response > &&response)

Sends a response to the client that initiated the service call. This function is expected to be used in deferred response callbacks.

response must be the object returned by borrow_loaned_response(). The entire borrow_loaned_response() -> populate -> send_response() sequence must run on the same thread (typically in a single callback).

Parameters:
  • request – The request that initiated the service call.

  • response – The response to send. Must be acquired by calling borrow_loaned_response().

inline AGNOCAST_PUBLIC ipc_shared_ptr< typename ServiceT::Response > borrow_loaned_response (const ipc_shared_ptr< typename ServiceT::Request > &request)

Allocate a service response message in shared memory. This function is expected to be used in deferred response callbacks.

This function does not consume request. In deferred callbacks, keep request and pass it to send_response() after populating the returned response.

Parameters:

request – The request that initiated the service call.

Returns:

Owned pointer to the response message in shared memory.