Pass request header to callbacks
This commit is contained in:
parent
0c0bb8a186
commit
b938bd691a
3 changed files with 6 additions and 8 deletions
|
@ -113,9 +113,7 @@ public:
|
|||
typename rclcpp::service::Service<ServiceT>::SharedPtr
|
||||
create_service(
|
||||
std::string service_name,
|
||||
std::function<void(
|
||||
const std::shared_ptr<typename ServiceT::Request> &,
|
||||
std::shared_ptr<typename ServiceT::Response> &)> callback,
|
||||
typename rclcpp::service::Service<ServiceT>::CallbackType callback,
|
||||
rclcpp::callback_group::CallbackGroup::SharedPtr group = nullptr);
|
||||
|
||||
private:
|
||||
|
|
|
@ -186,8 +186,7 @@ template<typename ServiceT>
|
|||
typename service::Service<ServiceT>::SharedPtr
|
||||
Node::create_service(
|
||||
std::string service_name,
|
||||
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
|
||||
std::shared_ptr<typename ServiceT::Response> &)> callback,
|
||||
typename rclcpp::service::Service<ServiceT>::CallbackType callback,
|
||||
rclcpp::callback_group::CallbackGroup::SharedPtr group)
|
||||
{
|
||||
using rosidl_generator_cpp::get_service_type_support_handle;
|
||||
|
|
|
@ -86,8 +86,9 @@ class Service : public ServiceBase
|
|||
{
|
||||
public:
|
||||
typedef std::function<
|
||||
void (const std::shared_ptr<typename ServiceT::Request> &,
|
||||
std::shared_ptr<typename ServiceT::Response> &)> CallbackType;
|
||||
void (const std::shared_ptr<rmw_request_id_t> &,
|
||||
const std::shared_ptr<typename ServiceT::Request> &,
|
||||
std::shared_ptr<typename ServiceT::Response> &)> CallbackType;
|
||||
RCLCPP_MAKE_SHARED_DEFINITIONS(Service);
|
||||
|
||||
Service(
|
||||
|
@ -114,7 +115,7 @@ public:
|
|||
auto typed_request = std::static_pointer_cast<typename ServiceT::Request>(request);
|
||||
auto typed_request_header = std::static_pointer_cast<rmw_request_id_t>(request_header);
|
||||
auto response = std::shared_ptr<typename ServiceT::Response>(new typename ServiceT::Response);
|
||||
callback_(typed_request, response);
|
||||
callback_(typed_request_header, typed_request, response);
|
||||
send_response(typed_request_header, response);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue