@@ -118,7 +118,7 @@ Nav2Panel::Nav2Panel(QWidget * parent)
118
118
// State entered when navigate_to_pose action is not active
119
119
accumulating_ = new QState ();
120
120
accumulating_->setObjectName (" accumulating" );
121
- accumulating_->assignProperty (start_reset_button_, " text" , " Reset " );
121
+ accumulating_->assignProperty (start_reset_button_, " text" , " Cancel Waypoint Mode " );
122
122
accumulating_->assignProperty (start_reset_button_, " toolTip" , cancel_waypoint_msg);
123
123
accumulating_->assignProperty (start_reset_button_, " enabled" , true );
124
124
@@ -131,6 +131,18 @@ Nav2Panel::Nav2Panel(QWidget * parent)
131
131
accumulating_->assignProperty (navigation_mode_button_, " toolTip" , waypoint_goal_msg);
132
132
133
133
accumulated_ = new QState ();
134
+ accumulated_->setObjectName (" accumulated" );
135
+ accumulated_->assignProperty (start_reset_button_, " text" , " Cancel" );
136
+ accumulated_->assignProperty (start_reset_button_, " toolTip" , cancel_msg);
137
+ accumulated_->assignProperty (start_reset_button_, " enabled" , true );
138
+
139
+ accumulated_->assignProperty (pause_resume_button_, " text" , " Pause" );
140
+ accumulated_->assignProperty (pause_resume_button_, " enabled" , false );
141
+ accumulated_->assignProperty (pause_resume_button_, " toolTip" , pause_msg);
142
+
143
+ accumulated_->assignProperty (navigation_mode_button_, " text" , " Start Navigation" );
144
+ accumulated_->assignProperty (navigation_mode_button_, " enabled" , false );
145
+ accumulated_->assignProperty (navigation_mode_button_, " toolTip" , waypoint_goal_msg);
134
146
135
147
// State entered to cancel the navigate_to_pose action
136
148
canceled_ = new QState ();
@@ -186,12 +198,12 @@ Nav2Panel::Nav2Panel(QWidget * parent)
186
198
idle_->addTransition (navigation_mode_button_, SIGNAL (clicked ()), accumulating_);
187
199
accumulating_->addTransition (navigation_mode_button_, SIGNAL (clicked ()), accumulated_);
188
200
accumulating_->addTransition (start_reset_button_, SIGNAL (clicked ()), idle_);
201
+ accumulated_->addTransition (start_reset_button_, SIGNAL (clicked ()), canceled_);
189
202
190
203
// Internal state transitions
191
204
canceled_->addTransition (canceled_, SIGNAL (entered ()), idle_);
192
205
reset_->addTransition (reset_, SIGNAL (entered ()), initial_);
193
206
resumed_->addTransition (resumed_, SIGNAL (entered ()), idle_);
194
- accumulated_->addTransition (accumulated_, SIGNAL (entered ()), idle_);
195
207
196
208
// Pause/Resume button click transitions
197
209
idle_->addTransition (pause_resume_button_, SIGNAL (clicked ()), paused_);
@@ -206,6 +218,15 @@ Nav2Panel::Nav2Panel(QWidget * parent)
206
218
runningTransition->setTargetState (idle_);
207
219
running_->addTransition (runningTransition);
208
220
221
+ ROSActionQTransition * idleAccumulatedTransition =
222
+ new ROSActionQTransition (QActionState::INACTIVE);
223
+ idleAccumulatedTransition->setTargetState (accumulated_);
224
+ idle_->addTransition (idleAccumulatedTransition);
225
+
226
+ ROSActionQTransition * accumulatedTransition = new ROSActionQTransition (QActionState::ACTIVE);
227
+ accumulatedTransition->setTargetState (idle_);
228
+ accumulated_->addTransition (accumulatedTransition);
229
+
209
230
initial_thread_ = new InitialThread (client_nav_, client_loc_);
210
231
connect (initial_thread_, &InitialThread::finished, initial_thread_, &QObject::deleteLater);
211
232
@@ -408,7 +429,7 @@ Nav2Panel::onNewGoal(double x, double y, double theta, QString frame)
408
429
void
409
430
Nav2Panel::onCancelButtonPressed ()
410
431
{
411
- if (state_machine_. configuration (). contains (accumulating_) ) {
432
+ if (waypoint_follower_goal_handle_ ) {
412
433
auto future_cancel =
413
434
waypoint_follower_action_client_->async_cancel_goal (waypoint_follower_goal_handle_);
414
435
@@ -418,7 +439,9 @@ Nav2Panel::onCancelButtonPressed()
418
439
RCLCPP_ERROR (client_node_->get_logger (), " Failed to cancel waypoint follower" );
419
440
return ;
420
441
}
421
- } else {
442
+ }
443
+
444
+ if (navigation_goal_handle_) {
422
445
auto future_cancel = navigation_action_client_->async_cancel_goal (navigation_goal_handle_);
423
446
424
447
if (rclcpp::spin_until_future_complete (client_node_, future_cancel, server_timeout_) !=
@@ -449,7 +472,7 @@ Nav2Panel::onAccumulating()
449
472
void
450
473
Nav2Panel::timerEvent (QTimerEvent * event)
451
474
{
452
- if (state_machine_.configuration ().contains (accumulating_ )) {
475
+ if (state_machine_.configuration ().contains (accumulated_ )) {
453
476
if (event->timerId () == timer_.timerId ()) {
454
477
if (!waypoint_follower_goal_handle_) {
455
478
RCLCPP_DEBUG (client_node_->get_logger (), " Waiting for Goal" );
0 commit comments