Nav2 Navigation Stack - jazzy  jazzy
ROS 2 Navigation Stack
route_tool.hpp
1 // Copyright (c) 2024 John Chrosniak
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__ROUTE_TOOL_HPP_
16 #define NAV2_RVIZ_PLUGINS__ROUTE_TOOL_HPP_
17 
18 #include <ui_route_tool.h>
19 #include <limits>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 #include "geometry_msgs/msg/point_stamped.hpp"
24 #include "nav_msgs/msg/occupancy_grid.hpp"
25 #include "nav2_route/graph_loader.hpp"
26 #include "nav2_route/graph_saver.hpp"
27 #include "nav2_route/types.hpp"
28 #include "nav2_route/utils.hpp"
29 #include "rclcpp/rclcpp.hpp"
30 #include "nav2_util/lifecycle_node.hpp"
31 #include "rviz_common/panel.hpp"
32 #include "std_msgs/msg/int16.hpp"
33 #include "std_msgs/msg/string.hpp"
34 
35 
36 namespace nav2_rviz_plugins
37 {
44 class RouteTool : public rviz_common::Panel
45 {
50  Q_OBJECT
51 
52 public:
62  explicit RouteTool(QWidget * parent = nullptr);
63 
64  void onInitialize() override;
65 
70  virtual void save(rviz_common::Config config) const;
71  virtual void load(const rviz_common::Config & config);
72 
73 
78 private Q_SLOTS:
79  void on_load_button_clicked(void);
80 
81  void on_save_button_clicked(void);
82 
83  void on_create_button_clicked(void);
84 
85  void on_confirm_button_clicked(void);
86 
87  void on_delete_button_clicked(void);
88 
89  void on_add_node_button_toggled(void);
90 
91  void on_edit_node_button_toggled(void);
92 
97 protected:
98  // UI pointer
99  std::unique_ptr<Ui::route_tool> ui_;
100 
101 private:
102  void update_route_graph(void);
103  nav2_util::LifecycleNode::SharedPtr node_;
104  std::shared_ptr<nav2_route::GraphLoader> graph_loader_;
105  std::shared_ptr<nav2_route::GraphSaver> graph_saver_;
106  std::shared_ptr<tf2_ros::Buffer> tf_;
107  nav2_route::Graph graph_;
108  nav2_route::GraphToIDMap graph_to_id_map_;
109  nav2_route::GraphToIDMap edge_to_node_map_;
110  nav2_route::GraphToIncomingEdgesMap graph_to_incoming_edges_map_;
111 
112  rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr
113  graph_vis_publisher_;
114  rclcpp::Subscription<geometry_msgs::msg::PointStamped>::SharedPtr
115  clicked_point_subscription_;
116 
117  unsigned int next_node_id_ = 0;
118 };
119 } // namespace nav2_rviz_plugins
120 #endif // NAV2_RVIZ_PLUGINS__ROUTE_TOOL_HPP_
std::unique_ptr< Ui::route_tool > ui_
Definition: route_tool.hpp:99
virtual void save(rviz_common::Config config) const
Definition: route_tool.cpp:260
RouteTool(QWidget *parent=nullptr)
Definition: route_tool.cpp:25