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