ros2 / rclcpp

rclcpp (ROS Client Library for C++)
Apache License 2.0
552 stars 418 forks source link

Update client API to be able to remove pending requests for ROS2 foxy #2100

Open aserbremen opened 1 year ago

aserbremen commented 1 year ago

Feature request

Update client API to be able to remove pending requests for ROS2 foxy (see pull request #1734)

Feature description

I am trying implement a ROS2 service client call according to https://github.com/ros2/examples/blob/rolling/rclcpp/services/minimal_client/main.cpp which removes pending requests if rclcpp::spin_until_future_complete(node, future) != rclcpp::FutureReturnCode::SUCCESS. I realized that Client::remove_pending_request(const FutureAndRequestId &future) is not implemented in ROS2 foxy which I am using at the moment. The minimal client example does not remove pending requests (https://github.com/ros2/examples/blob/foxy/rclcpp/services/minimal_client/main.cpp). What are the implications of not removing the pending request? I am not sure how these pull requests work for older versions of ROS2 and I was wondering if the functionality will be available for ROS2 foxy in the future. Thanks

GiorMM commented 1 year ago

In the rolling version of rclcpp/include/rclcpp/client.hpp, line 695 has a comment stating that not calling a certain function will cause the client to use more memory for each request that does not receive a reply from the server.

In these two examples provided, this issue doesn't actually have any impact because both examples terminate the program directly after receiving a "service call failed" message.

It appears that this issue was not considered in foxy version, but both rolling and foxy use the private variable "pendingrequests" to control business related to requests.

If you don't mind changing the ABI, you can refer to my implementation here. #2126