Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
costmap_cost_tool.hpp
1 // Copyright (c) 2024 Jatin Patil
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef NAV2_RVIZ_PLUGINS__COSTMAP_COST_TOOL_HPP_
16 #define NAV2_RVIZ_PLUGINS__COSTMAP_COST_TOOL_HPP_
17 
18 #include <nav2_msgs/srv/get_cost.hpp>
19 #include <rviz_common/tool.hpp>
20 #include <rviz_default_plugins/tools/point/point_tool.hpp>
21 #include <rclcpp/rclcpp.hpp>
22 
23 namespace nav2_rviz_plugins
24 {
25 class CostmapCostTool : public rviz_common::Tool
26 {
27  Q_OBJECT
28 
29 public:
31  virtual ~CostmapCostTool();
32 
33  void onInitialize() override;
34  void activate() override;
35  void deactivate() override;
36 
37  int processMouseEvent(rviz_common::ViewportMouseEvent & event) override;
38 
39  void callCostService(float x, float y);
40 
41  void handleLocalCostResponse(rclcpp::Client<nav2_msgs::srv::GetCost>::SharedFuture);
42  void handleGlobalCostResponse(rclcpp::Client<nav2_msgs::srv::GetCost>::SharedFuture);
43 
44 private Q_SLOTS:
45  void updateAutoDeactivate();
46 
47 private:
48  rclcpp::Client<nav2_msgs::srv::GetCost>::SharedPtr local_cost_client_;
49  rclcpp::Client<nav2_msgs::srv::GetCost>::SharedPtr global_cost_client_;
50  rclcpp::Node::SharedPtr node_;
51 
52  QCursor std_cursor_;
53  QCursor hit_cursor_;
54  rviz_common::properties::BoolProperty * auto_deactivate_property_;
55  rviz_common::properties::QosProfileProperty * qos_profile_property_;
56 
57  rclcpp::QoS qos_profile_;
58 };
59 
60 } // namespace nav2_rviz_plugins
61 
62 #endif // NAV2_RVIZ_PLUGINS__COSTMAP_COST_TOOL_HPP_