File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed
nav2_behavior_tree/test/utils
nav2_system_tests/src/behavior_tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,22 @@ class TestService : public rclcpp::Node
4848 const std::shared_ptr<typename ServiceT::Response> response)
4949 {
5050 (void )request_header;
51- (void )response;
5251 current_request_ = request;
52+ setSuccessIfExists (response);
5353 }
5454
5555private:
56+ template <typename T>
57+ auto setSuccessIfExists (std::shared_ptr<T> response) -> decltype(response->success, void ())
58+ {
59+ response->success = true ;
60+ }
61+
62+ template <typename T>
63+ void setSuccessIfExists (T)
64+ {
65+ }
66+
5667 typename rclcpp::Service<ServiceT>::SharedPtr server_;
5768 std::shared_ptr<typename ServiceT::Request> current_request_;
5869};
Original file line number Diff line number Diff line change @@ -31,9 +31,9 @@ ServerHandler::ServerHandler()
3131{
3232 node_ = rclcpp::Node::make_shared (" behavior_tree_tester" );
3333
34- clear_local_costmap_server = std::make_unique<DummyService<nav2_msgs::srv::ClearEntireCostmap> >(
34+ clear_local_costmap_server = std::make_unique<DummyClearCostmapService >(
3535 node_, " local_costmap/clear_entirely_local_costmap" );
36- clear_global_costmap_server = std::make_unique<DummyService<nav2_msgs::srv::ClearEntireCostmap> >(
36+ clear_global_costmap_server = std::make_unique<DummyClearCostmapService >(
3737 node_, " global_costmap/clear_entirely_global_costmap" );
3838 compute_path_to_pose_server = std::make_unique<DummyComputePathToPoseActionServer>(node_);
3939 follow_path_server = std::make_unique<DummyFollowPathActionServer>(node_);
Original file line number Diff line number Diff line change @@ -95,6 +95,22 @@ class DummyFollowPathActionServer : public DummyActionServer<nav2_msgs::action::
9595 }
9696};
9797
98+ class DummyClearCostmapService : public DummyService <nav2_msgs::srv::ClearEntireCostmap>
99+ {
100+ public:
101+ explicit DummyClearCostmapService (
102+ const rclcpp::Node::SharedPtr & node,
103+ std::string service_name)
104+ : DummyService(node, service_name) {}
105+
106+ protected:
107+ void fillResponse (
108+ const std::shared_ptr<nav2_msgs::srv::ClearEntireCostmap::Request>/* request*/ ,
109+ const std::shared_ptr<nav2_msgs::srv::ClearEntireCostmap::Response> response) override
110+ {
111+ response->success = true ;
112+ }
113+ };
98114
99115class ServerHandler
100116{
@@ -114,8 +130,8 @@ class ServerHandler
114130 void reset () const ;
115131
116132public:
117- std::unique_ptr<DummyService<nav2_msgs::srv::ClearEntireCostmap> > clear_local_costmap_server;
118- std::unique_ptr<DummyService<nav2_msgs::srv::ClearEntireCostmap> > clear_global_costmap_server;
133+ std::unique_ptr<DummyClearCostmapService > clear_local_costmap_server;
134+ std::unique_ptr<DummyClearCostmapService > clear_global_costmap_server;
119135 std::unique_ptr<DummyComputePathToPoseActionServer> compute_path_to_pose_server;
120136 std::unique_ptr<DummyFollowPathActionServer> follow_path_server;
121137 std::unique_ptr<DummyActionServer<nav2_msgs::action::Spin>> spin_server;
You can’t perform that action at this time.
0 commit comments