Skip to content

Commit d3ad2b8

Browse files
fix: change warning to exception when goal poses cannot be transformed (#5759)
- Replace RCLCPP_WARN with std::runtime_error exception in onPreempt method - Remove bt_action_server_->terminatePendingGoal() call after accepting goal - Add required stdexcept include for exception handling Fixes issue where navigators accept pending goal but are not properly terminated if rejected during goal pose transformation. Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent f430550 commit d3ad2b8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

nav2_bt_navigator/src/navigators/navigate_through_poses.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <set>
1818
#include <memory>
1919
#include <limits>
20+
#include <stdexcept>
2021
#include "nav2_bt_navigator/navigators/navigate_through_poses.hpp"
2122

2223
namespace nav2_bt_navigator
@@ -217,11 +218,9 @@ NavigateThroughPosesNavigator::onPreempt(ActionT::Goal::ConstSharedPtr goal)
217218
// if pending goal has an empty behavior_tree field, it requests the default BT file
218219
// accept the pending goal if the current goal is running the default BT file
219220
if (!initializeGoalPoses(bt_action_server_->acceptPendingGoal())) {
220-
RCLCPP_WARN(
221-
logger_,
221+
throw std::runtime_error(
222222
"Preemption request was rejected since the goal poses could not be "
223-
"transformed. For now, continuing to track the last goal until completion.");
224-
bt_action_server_->terminatePendingGoal();
223+
"transformed.");
225224
}
226225
} else {
227226
RCLCPP_WARN(

0 commit comments

Comments
 (0)