Skip to content

Commit 4841e12

Browse files
authored
Merge pull request #381 from naturerobots/feature/rviz-set-planner-controller
RViz MBF Plugin Update
2 parents 9f2f165 + ced5614 commit 4841e12

2 files changed

Lines changed: 665 additions & 138 deletions

File tree

rviz_mbf_plugins/include/rviz_mbf_plugins/mbf_goal_actions_panel.hpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@
5454
#include <QLabel>
5555
#include <QGroupBox>
5656
#include <QVBoxLayout>
57+
#include <QPushButton>
5758

5859
#include <memory>
5960
#include <optional>
6061
#include <future>
62+
#include <thread>
63+
#include <atomic>
6164

6265
namespace rviz_mbf_plugins
6366
{
@@ -70,13 +73,13 @@ class MbfGoalActionsPanel : public rviz_common::Panel
7073

7174
public:
7275
explicit MbfGoalActionsPanel(QWidget * parent = nullptr);
73-
~MbfGoalActionsPanel() noexcept override = default;
76+
~MbfGoalActionsPanel() noexcept override;
7477

7578
void onInitialize() override;
7679
void save(rviz_common::Config config) const override;
7780
void load(const rviz_common::Config & config) override;
7881

79-
void newMeshGoalCallback(const geometry_msgs::msg::PoseStamped & msg);
82+
void newGoalCallback(const geometry_msgs::msg::PoseStamped & msg);
8083

8184
protected:
8285
//! Sets up the properties widget, which contains editable fields that configures the panel (e.g. which topic to subscribe to)
@@ -98,23 +101,42 @@ private Q_SLOTS:
98101
void updateGoalInputSubscription();
99102
void updateGetPathActionClient();
100103
void updateExePathActionClient();
104+
void stopGetPathAction();
105+
void stopExePathAction();
101106

102107
protected:
103108
rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr goal_pose_subscription_;
104109

110+
rclcpp::Node::SharedPtr ros_node_;
111+
105112
//! Action client for getting a path
113+
std::mutex get_path_action_client_mutex_;
106114
GetPathClient::SharedPtr action_client_get_path_;
115+
std::shared_ptr<rclcpp::AsyncParametersClient> planner_parameter_client_;
116+
std::string get_path_node_name_;
117+
std::string get_path_action_server_name_;
118+
std::string get_path_planner_name_;
119+
107120
//! Goal handle of active get path action
108121
GetPathClient::GoalHandle::SharedPtr goal_handle_get_path_;
109-
//! Potential next get path goal, used for quickly restarting the planner after cancelling the previous goal
110-
std::optional<mbf_msgs::action::GetPath::Goal> next_get_path_goal_;
111122

112123
//! Action client for traversing a path
124+
std::mutex exe_path_action_client_mutex_;
113125
ExePathClient::SharedPtr action_client_exe_path_;
126+
std::shared_ptr<rclcpp::AsyncParametersClient> controller_parameter_client_;
127+
std::string exe_path_node_name_;
128+
std::string exe_path_action_server_name_;
129+
std::string exe_path_controller_name_;
130+
114131
//! Goal handle of active exe path action
115132
ExePathClient::GoalHandle::SharedPtr goal_handle_exe_path_;
116-
//! Potential next exe path goal, used for quickly restarting the path execution after cancelling the previous goal
117-
std::optional<mbf_msgs::action::ExePath::Goal> next_exe_path_goal_;
133+
134+
std::atomic_bool conn_check_thread_get_path_stop_;
135+
std::thread conn_check_thread_get_path_;
136+
std::atomic_bool conn_check_thread_exe_path_stop_;
137+
std::thread conn_check_thread_exe_path_;
138+
std::atomic_bool executor_thread_stop_;
139+
std::thread executor_thread_;
118140

119141
//! Retry counter for goal execution
120142
size_t goal_retry_cnt_;
@@ -134,8 +156,6 @@ private Q_SLOTS:
134156
rviz_common::properties::RosActionProperty* exe_path_action_server_path_;
135157
rviz_common::properties::EditableEnumProperty* controller_name_property_;
136158

137-
std::shared_ptr<rclcpp::AsyncParametersClient> planner_parameter_client_;
138-
std::shared_ptr<rclcpp::AsyncParametersClient> controller_parameter_client_;
139159

140160
QGroupBox * goal_input_ui_box_;
141161
QVBoxLayout * goal_input_ui_layout_;
@@ -149,6 +169,7 @@ private Q_SLOTS:
149169
QHBoxLayout * get_path_ui_layout_goal_status_;
150170
QLabel * get_path_action_goal_status_desc_;
151171
QLabel * get_path_action_goal_status_;
172+
QPushButton * stop_get_path_button_;
152173

153174
QGroupBox * exe_path_ui_box_;
154175
QVBoxLayout * exe_path_ui_layout_;
@@ -158,6 +179,7 @@ private Q_SLOTS:
158179
QHBoxLayout * exe_path_ui_layout_goal_status_;
159180
QLabel * exe_path_action_goal_status_desc_;
160181
QLabel * exe_path_action_goal_status_;
182+
QPushButton * stop_exe_path_button_;
161183
};
162184

163185
} // namespace rviz_mbf_plugins

0 commit comments

Comments
 (0)