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

Get ros2 Service Client ID

asked 2021-03-10 06:48:23 -0500

BhanuKiran.Chaluvadi gravatar image

Hi,

To give some back ground , I have multiple Service Client like this in the picture - 2nd gif. These clients will modify some variables stored in the server. Based on some unique id of the client I would like to maintain some access control to modification the variables in ros2 Service Server.

Is it possible to obtain the ros2 Service Client ID (unique_id) from ros2 Service Server once it receives the service request ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-16 13:27:59 -0500

BhanuKiran.Chaluvadi gravatar image

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.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2021-03-10 06:48:23 -0500

Seen: 290 times

Last updated: May 16 '21