std::bind in function callback for subscription or service on ros 2
Edit:
Ok so I tried adding this request_header variable and add a std::placeholders but it's not working either. This time I get the same kind of error :
In file included from /opt/ros/crystal/include/rclcpp/node_impl.hpp:42:0,
from /opt/ros/crystal/include/rclcpp/node.hpp:524,
from /opt/ros/crystal/include/rclcpp/executors/single_threaded_executor.hpp:28,
from /opt/ros/crystal/include/rclcpp/executors.hpp:22,
from /opt/ros/crystal/include/rclcpp/rclcpp.hpp:144,
from /home/innovation/ros2_ws/src/balyo_utils_ros/src/ping.cpp:1: /opt/ros/crystal/include/rclcpp/create_service.hpp: In instantiation of ‘typename rclcpp::Service<ServiceT>::SharedPtr rclcpp::create_service(std::shared_ptr<rclcpp::node_interfaces::NodeBaseInterface>, std::shared_ptr<rclcpp::node_interfaces::NodeServicesInterface>, const string&, CallbackT&&, const rmw_qos_profile_t&, rclcpp::callback_group::CallbackGroup::SharedPtr) [with ServiceT = balyo_msgs::srv::GetBool; CallbackT = std::_Bind<bool (Ping::*(Ping*, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(std::shared_ptr<rmw_request_id_t>, balyo_msgs::srv::GetBool_Request_<std::allocator<void>
>&, balyo_msgs::srv::GetBool_Response_<std::allocator<void>
>&)>; typename rclcpp::Service<ServiceT>::SharedPtr = std::shared_ptr<rclcpp::Service<balyo_msgs::srv::GetBool>
>; std::__cxx11::string = std::__cxx11::basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_t; rclcpp::callback_group::CallbackGroup::SharedPtr
= std::shared_ptr<rclcpp::callback_group::CallbackGroup>]’: /opt/ros/crystal/include/rclcpp/node_impl.hpp:201:53: required from ‘typename rclcpp::Service<ServiceT>::SharedPtr rclcpp::Node::create_service(const string&, CallbackT&&, const rmw_qos_profile_t&, rclcpp::callback_group::CallbackGroup::SharedPtr) [with ServiceT = balyo_msgs::srv::GetBool; CallbackT = std::_Bind<bool (Ping::*(Ping*, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(std::shared_ptr<rmw_request_id_t>, balyo_msgs::srv::GetBool_Request_<std::allocator<void>
>&, balyo_msgs::srv::GetBool_Response_<std::allocator<void>
>&)>; typename rclcpp::Service<ServiceT>::SharedPtr = std::shared_ptr<rclcpp::Service<balyo_msgs::srv::GetBool>
>; std::__cxx11::string = std::__cxx11::basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_t; rclcpp::callback_group::CallbackGroup::SharedPtr
= std::shared_ptr<rclcpp::callback_group::CallbackGroup>]’ /home/innovation/ros2_ws/src/balyo_utils_ros/src/ping.cpp:97:182: required from here /opt/ros/crystal/include/rclcpp/create_service.hpp:43:3: error: no matching function for call to ‘rclcpp::AnyServiceCallback<balyo_msgs::srv::GetBool>::set(std::_Bind<bool (Ping::*(Ping*, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(std::shared_ptr<rmw_request_id_t>, balyo_msgs::srv::GetBool_Request_<std::allocator<void>
>&, balyo_msgs::srv::GetBool_Response_<std::allocator<void>
>&)>)’ any_service_callback.set(std::forward<CallbackT>(callback)); ^~~~~~~~~~~~~~~~~~~~ In file included from /opt/ros/crystal/include/rclcpp/service.hpp:27:0,
from /opt/ros/crystal/include/rclcpp/callback_group.hpp:24,
from /opt/ros/crystal/include/rclcpp/any_executable.hpp:20,
from /opt/ros/crystal/include/rclcpp/memory_strategy.hpp:24,
from /opt/ros/crystal/include/rclcpp/memory_strategies.hpp:18,
from /opt/ros/crystal/include/rclcpp/executor.hpp:32,
from /opt/ros/crystal/include/rclcpp/executors/multi_threaded_executor.hpp:24,
from /opt/ros/crystal/include/rclcpp/executors.hpp:21,
from /opt/ros/crystal/include/rclcpp/rclcpp.hpp:144,
from /home/innovation/ros2_ws/src/balyo_utils_ros/src/ping.cpp:1: /opt/ros/crystal/include/rclcpp/any_service_callback.hpp:65:8: note: candidate: template<class CallbackT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, std::function<void(std::shared_ptr<balyo_msgs::srv::GetBool_Request_<std::allocator<void>
> >, std::shared_ptr<balyo_msgs::srv::GetBool_Response_<std::allocator<void>
> >)> >::value, void>::type* <anonymous> > void rclcpp::AnyServiceCallback<ServiceT>::set(CallbackT) [with ...
@Amel--E: please don't post answers to provide more information. Only post answers to actually answer your own question. For everything else: short -> comments. More code or error messages: edit your original post (add a section).