Template Class SynchronousServiceClient

Class Documentation

template<class ServiceT>
class SynchronousServiceClient

Class for handling synchronous service clients in ROS2 without taking care about the spin() method.

Public Types

using SharedPtr = std::shared_ptr<SynchronousServiceClient<ServiceT>>

Public Functions

inline SynchronousServiceClient(std::string service_name, as2::Node *node)

Constructor.

Parameters:

service_name – Name of the service

inline bool sendRequest(const RequestT &req, ResponseT &resp, int wait_time = 0)

Send Request synchronously to the service.

Parameters:
  • request – Request to be sent to the service

  • respone – Response received from the service

  • wait_time – Time to wait for the service to be available in seconds

Returns:

True if the service was called successfully, false otherwise

inline bool sendRequest(const std::shared_ptr<RequestT> &req, std::shared_ptr<ResponseT> &resp, int wait_time = 0)

Send Request synchronously to the service.

Parameters:
  • request – Request to be sent to the service

  • respone – Response received from the service

  • wait_time – Time to wait for the service to be available in seconds

Returns:

True if the service was called successfully, false otherwise