Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
selector.hpp
1 // Copyright (c) 2024 Neobotix GmbH
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__SELECTOR_HPP_
16 #define NAV2_RVIZ_PLUGINS__SELECTOR_HPP_
17 
18 #include <QtWidgets>
19 #include <QFrame>
20 #include <QGridLayout>
21 #include <QScrollArea>
22 #include <QToolButton>
23 #include <QWidget>
24 
25 #include "rclcpp/node.hpp"
26 #include "rclcpp/publisher.hpp"
27 #include "rviz_common/panel.hpp"
28 #include "vector"
29 #include "memory"
30 #include "string"
31 #include "std_msgs/msg/string.hpp"
32 
33 class QPushButton;
34 
35 namespace nav2_rviz_plugins
36 {
37 class Selector : public rviz_common::Panel
38 {
39  Q_OBJECT
40 
41 public:
42  explicit Selector(QWidget * parent = 0);
43  ~Selector();
44 
45 private:
46  void loadPlugins();
47 
48  rclcpp::Node::SharedPtr client_node_; // nosemgrep
49  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_controller_; // nosemgrep
50  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_planner_; // nosemgrep
51  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_goal_checker_; // nosemgrep
52  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_smoother_; // nosemgrep
53  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_progress_checker_; // nosemgrep
54  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr pub_path_handler_; // nosemgrep
55 
56  bool plugins_loaded_ = false;
57  bool server_failed_ = false;
58 
59  std::thread load_plugins_thread_;
60 
61  QVBoxLayout * main_layout_;
62  QHBoxLayout * row_1_layout_;
63  QHBoxLayout * row_2_layout_;
64  QHBoxLayout * row_3_layout_;
65  QHBoxLayout * row_1_label_layout_;
66  QHBoxLayout * row_2_label_layout_;
67  QHBoxLayout * row_3_label_layout_;
68  QComboBox * controller_;
69  QComboBox * planner_;
70  QComboBox * goal_checker_;
71  QComboBox * smoother_;
72  QComboBox * progress_checker_;
73  QComboBox * path_handler_;
74 
75  void setController();
76  void setPlanner();
77  void setGoalChecker();
78  void setSmoother();
79  void setProgressChecker();
80  void setPathHandler();
81 
82  /*
83  * @brief Set the selection from the combo box
84  * @param combo_box The combo box to set the selection for
85  * @param publisher Publish the selected plugin
86  */
87  void setSelection(
88  QComboBox * combo_box,
89  rclcpp::Publisher<std_msgs::msg::String>::SharedPtr publisher); // nosemgrep
90 
91 protected:
92  QVBoxLayout * layout1 = new QVBoxLayout;
93 };
94 
95 } // namespace nav2_rviz_plugins
96 
97 #endif // NAV2_RVIZ_PLUGINS__SELECTOR_HPP_