Skip to content

Commit

Permalink
Fixed #1207
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Sep 10, 2024
1 parent 9deb8a2 commit 28f9974
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion rtabmap_slam/include/rtabmap_slam/CoreWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class CoreWrapper : public rclcpp::Node, public rtabmap_sync::CommonDataSubscrib
#ifdef NAV_MSGS_FOXY
void goalResponseCallback(std::shared_future<GoalHandleNav2::SharedPtr> future);
#else
void goalResponseCallback(const GoalHandleNav2::SharedPtr & goal_handle);
void goalResponseCallback(const GoalHandleNav2::SharedPtr & goal_handle);
#endif
void resultCallback(const GoalHandleNav2::WrappedResult & result);
#endif
Expand Down Expand Up @@ -381,6 +381,7 @@ class CoreWrapper : public rclcpp::Node, public rtabmap_sync::CommonDataSubscrib
#endif
#ifdef WITH_NAV2_MSGS
rclcpp_action::Client<NavigateToPose>::SharedPtr nav2Client_;
rclcpp_action::GoalUUID lastGoalSent_;
#endif

std::thread* transformThread_;
Expand Down
8 changes: 7 additions & 1 deletion rtabmap_slam/src/CoreWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4436,7 +4436,7 @@ void CoreWrapper::goalResponseCallback(
{
auto goal_handle = future.get();
#else
const GoalHandleNav2::SharedPtr & goal_handle)
const GoalHandleNav2::SharedPtr & goal_handle)
{
#endif
if (!goal_handle) {
Expand All @@ -4448,6 +4448,7 @@ void CoreWrapper::goalResponseCallback(
latestNodeWasReached_ = false;
} else {
RCLCPP_INFO(this->get_logger(), "Goal accepted by server, waiting for result");
lastGoalSent_ = goal_handle->get_goal_id();
}
}

Expand All @@ -4473,6 +4474,11 @@ void CoreWrapper::resultCallback(
RCLCPP_INFO(this->get_logger(), "Planning: nav2 success!");
}
}
else if(result.code==rclcpp_action::ResultCode::ABORTED && result.goal_id != lastGoalSent_)
{
// Just ignored, it is from an old goal
ignore = true;
}
else
{
RCLCPP_ERROR(this->get_logger(), "Planning: nav2 failed for some reason: %s. Aborting the plan...",
Expand Down

0 comments on commit 28f9974

Please sign in to comment.