-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add service introspection #4955
base: main
Are you sure you want to change the base?
Add service introspection #4955
Conversation
Signed-off-by: mini-1235 <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great first stab! For each server that has one of these service clients, we should add into the configuration guide docs the parameter so that our param guides remain up to date!
@@ -54,14 +54,15 @@ PlannerServer::PlannerServer(const rclcpp::NodeOptions & options) | |||
declare_parameter("expected_planner_frequency", 1.0); | |||
declare_parameter("action_server_result_timeout", 10.0); | |||
declare_parameter("costmap_update_timeout", 1.0); | |||
declare_parameter("service_introspection_mode", "disabled"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should make this a part of the service client itself to declare / get the service introspection mode. Then it can be removed from all of these nodes. Within the ServiceClient / ServiceServer you can use the node
to find these parameters.
That would remove a good chunk of the line changes in this PR by removing the declare/get/pass in the parameter in each server. That would help readability and separation of concerns
@@ -106,34 +116,11 @@ void CostmapCostTool::callCostService(float x, float y) | |||
request->use_footprint = false; | |||
|
|||
// Call local costmap service | |||
if (local_cost_client_->wait_for_service(std::chrono::seconds(1))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be reverted, the invoke shared would block the thread which would make all of rviz seize up until the service client got a response.
@@ -48,6 +49,18 @@ class ServiceClient | |||
service_name, | |||
rclcpp::SystemDefaultsQoS(), | |||
callback_group_); | |||
rcl_service_introspection_state_t introspection_state = RCL_SERVICE_INTROSPECTION_OFF; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where you can declare and get the service introspection value internally to the class!
* @class nav2_util::ServiceServer | ||
* @brief A simple wrapper on ROS2 services for invoke() and block-style calling | ||
*/ | ||
template<class ServiceT, typename NodeT = rclcpp::Node::SharedPtr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look over the annotations, there's some pretty big testing gaps in this and the service client file from these changes. I think a few more unit tests in the various introspection modes are necessary
* @param request The request object to call the service using | ||
* @return std::shared_future<typename ResponseType::SharedPtr> The shared future of the service response | ||
*/ | ||
std::shared_future<typename ResponseType::SharedPtr> invoke_shared( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the value of this if we can return the response instead? Why return the shared future?
|
||
explicit ServiceServer( | ||
const std::string & service_name, | ||
std::string service_introspection_mode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could/should be removed and done in the constructor as well using the node
input
@@ -148,7 +151,7 @@ class BtServiceNode : public BT::ActionNodeBase | |||
return BT::NodeStatus::FAILURE; | |||
} | |||
|
|||
future_result_ = service_client_->async_send_request(request_).share(); | |||
future_result_ = service_client_->invoke_shared(request_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only necessary use of invoke_shared? If so, maybe we should have this remain a raw create_client
and pass in the service introspection params into it
This pull request is in conflict. Could you fix it @mini-1235? |
Basic Info
Description of contribution in a few bullet points
nav2_util
as not all service servers are derived from the LifecycleNode class)Description of documentation updates required from your changes
Documents related to
nav2_params
would require a change, will raise a PR in the docs repo when this PR is readyDescription of how this change was tested
I add a simple unit test, and the changes were mostly tested in my sim env (using cli to make sure service introspection works)
Future work that may be required in bullet points
For Maintainers: