Do not pass RequestId to the server callback. Use RequestId from rpc.h
This commit is contained in:
parent
3e0621a1ff
commit
e91563640e
3 changed files with 5 additions and 10 deletions
|
@ -29,8 +29,6 @@
|
||||||
#include <rclcpp/subscription.hpp>
|
#include <rclcpp/subscription.hpp>
|
||||||
#include <rclcpp/timer.hpp>
|
#include <rclcpp/timer.hpp>
|
||||||
|
|
||||||
#include <userland_msgs/RequestId.h>
|
|
||||||
|
|
||||||
namespace rclcpp
|
namespace rclcpp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -104,7 +102,6 @@ public:
|
||||||
create_service(
|
create_service(
|
||||||
std::string service_name,
|
std::string service_name,
|
||||||
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
|
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
|
||||||
const std::shared_ptr<userland_msgs::RequestId> &,
|
|
||||||
std::shared_ptr<typename ServiceT::Response>&)> callback,
|
std::shared_ptr<typename ServiceT::Response>&)> callback,
|
||||||
rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr);
|
rclcpp::callback_group::CallbackGroup::SharedPtr group=nullptr);
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,6 @@ typename service::Service<ServiceT>::SharedPtr
|
||||||
Node::create_service(
|
Node::create_service(
|
||||||
std::string service_name,
|
std::string service_name,
|
||||||
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
|
std::function<void(const std::shared_ptr<typename ServiceT::Request> &,
|
||||||
const std::shared_ptr<userland_msgs::RequestId> &,
|
|
||||||
std::shared_ptr<typename ServiceT::Response>&)> callback,
|
std::shared_ptr<typename ServiceT::Response>&)> callback,
|
||||||
rclcpp::callback_group::CallbackGroup::SharedPtr group)
|
rclcpp::callback_group::CallbackGroup::SharedPtr group)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
|
|
||||||
#include <ros_middleware_interface/functions.h>
|
#include <ros_middleware_interface/functions.h>
|
||||||
#include <ros_middleware_interface/handles.h>
|
#include <ros_middleware_interface/handles.h>
|
||||||
|
#include <ros_middleware_interface/rpc.h>
|
||||||
|
|
||||||
#include <rclcpp/macros.hpp>
|
#include <rclcpp/macros.hpp>
|
||||||
|
|
||||||
#include <userland_msgs/RequestId.h>
|
|
||||||
|
|
||||||
namespace rclcpp
|
namespace rclcpp
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,6 @@ class Service : public ServiceBase
|
||||||
public:
|
public:
|
||||||
typedef std::function<
|
typedef std::function<
|
||||||
void(const std::shared_ptr<typename ServiceT::Request> &,
|
void(const std::shared_ptr<typename ServiceT::Request> &,
|
||||||
const std::shared_ptr<userland_msgs::RequestId> &,
|
|
||||||
std::shared_ptr<typename ServiceT::Response>&)> CallbackType;
|
std::shared_ptr<typename ServiceT::Response>&)> CallbackType;
|
||||||
RCLCPP_MAKE_SHARED_DEFINITIONS(Service);
|
RCLCPP_MAKE_SHARED_DEFINITIONS(Service);
|
||||||
|
|
||||||
|
@ -92,20 +91,20 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<void> create_request_header()
|
std::shared_ptr<void> create_request_header()
|
||||||
{
|
{
|
||||||
return std::shared_ptr<void>(new userland_msgs::RequestId());
|
return std::shared_ptr<void>(new ros_middleware_interface::RequestId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_request(std::shared_ptr<void> &request, std::shared_ptr<void> &req_id)
|
void handle_request(std::shared_ptr<void> &request, std::shared_ptr<void> &req_id)
|
||||||
{
|
{
|
||||||
auto typed_request = std::static_pointer_cast<typename ServiceT::Request>(request);
|
auto typed_request = std::static_pointer_cast<typename ServiceT::Request>(request);
|
||||||
auto typed_req_id = std::static_pointer_cast<userland_msgs::RequestId>(req_id);
|
auto typed_req_id = std::static_pointer_cast<ros_middleware_interface::RequestId>(req_id);
|
||||||
auto response = std::shared_ptr<typename ServiceT::Response>(new typename ServiceT::Response);
|
auto response = std::shared_ptr<typename ServiceT::Response>(new typename ServiceT::Response);
|
||||||
callback_(typed_request, typed_req_id, response);
|
callback_(typed_request, response);
|
||||||
send_response(typed_req_id, response);
|
send_response(typed_req_id, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_response(
|
void send_response(
|
||||||
std::shared_ptr<userland_msgs::RequestId> &req_id,
|
std::shared_ptr<ros_middleware_interface::RequestId> &req_id,
|
||||||
std::shared_ptr<typename ServiceT::Response> &response)
|
std::shared_ptr<typename ServiceT::Response> &response)
|
||||||
{
|
{
|
||||||
::ros_middleware_interface::send_response(get_service_handle(), req_id.get(), response.get());
|
::ros_middleware_interface::send_response(get_service_handle(), req_id.get(), response.get());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue