Skip to content

Commit f924da8

Browse files
VladyslavHrynchak200204masf7g
authored andcommitted
Fixed timed_behavior.hpp (ros-navigation#4602)
Signed-off-by: Vladyslav Hrynchak <[email protected]>
1 parent 9027a00 commit f924da8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

nav2_behaviors/include/nav2_behaviors/timed_behavior.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,6 @@ class TimedBehavior : public nav2_core::Behavior
237237

238238
while (rclcpp::ok()) {
239239
elasped_time_ = clock_->now() - start_time;
240-
if (action_server_->is_cancel_requested()) {
241-
RCLCPP_INFO(logger_, "Canceling %s", behavior_name_.c_str());
242-
stopRobot();
243-
result->total_elapsed_time = elasped_time_;
244-
onActionCompletion(result);
245-
action_server_->terminate_all(result);
246-
return;
247-
}
248-
249240
// TODO(orduno) #868 Enable preempting a Behavior on-the-fly without stopping
250241
if (action_server_->is_preempt_requested()) {
251242
RCLCPP_ERROR(
@@ -259,6 +250,15 @@ class TimedBehavior : public nav2_core::Behavior
259250
return;
260251
}
261252

253+
if (action_server_->is_cancel_requested()) {
254+
RCLCPP_INFO(logger_, "Canceling %s", behavior_name_.c_str());
255+
stopRobot();
256+
result->total_elapsed_time = elasped_time_;
257+
onActionCompletion(result);
258+
action_server_->terminate_all(result);
259+
return;
260+
}
261+
262262
ResultStatus on_cycle_update_result = onCycleUpdate();
263263
switch (on_cycle_update_result.status) {
264264
case Status::SUCCEEDED:

0 commit comments

Comments
 (0)