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