ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Service call back function can be overloaded like this

  void handleSrv(
      const std::shared_ptr<rmw_request_id_t> requestHeader,
      const std::shared_ptr<example_interfaces::srv::AddTwoInts::Request> request,
      std::shared_ptr<example_interfaces::srv::AddTwoInts::Response> response);

requestHeader variable has all the information needed. Similarly for subscriber

  void handleSub(const std_msgs::msg::String::SharedPtr msg,
                                 const rclcpp::MessageInfo& message_info);

message_info variable has all the information needed.