Skip to content

Commit

Permalink
hubero_core & ros - fixed delayed reception of navigation result (cau…
Browse files Browse the repository at this point in the history
…sed switching active<->finished in MoveToGoal), added Nav::finish call when goal reached (Actor)
  • Loading branch information
rayvburn committed Feb 20, 2022
1 parent b55f42b commit e0bf60f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
6 changes: 6 additions & 0 deletions hubero_core/src/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ void Actor::addFsmSuperTransitionHandlers(
TaskMoveToGoal::State::FINISHED,
std::bind(&TaskMoveToGoal::finish, task_move_to_goal_ptr)
);

task_move_to_goal_ptr->addStateTransitionHandler(
TaskMoveToGoal::State::ACTIVE,
TaskMoveToGoal::State::FINISHED,
std::bind(&NavigationBase::finish, navigation_ptr)
);
}

// static
Expand Down
13 changes: 0 additions & 13 deletions hubero_ros/include/hubero_ros/navigation_ros.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,6 @@ class NavigationRos: public NavigationBase {
void callbackResult(const move_base_msgs::MoveBaseActionResult::ConstPtr& msg);
/// @}

/**
* @defgroup mbinterfaceaction ROS move_base action interface callbacks
* @{
*/
/**
* @brief Called when action is done
*/
void callbackActionDone(
const actionlib::SimpleClientGoalState& state,
const move_base_msgs::MoveBaseResultConstPtr& msg
);
/// @}

/**
* @brief Finds transform between coordinate systems using ROS TF buffer
* @return std::tuple<bool, Pose3> first element is true if transform (second elem) is valid
Expand Down
23 changes: 8 additions & 15 deletions hubero_ros/src/navigation_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,15 @@ bool NavigationRos::setGoal(const Pose3& pose, const std::string& frame) {
nav_goal_.target_pose.header.stamp = ros::Time::now();
nav_goal_.target_pose.pose = ignPoseToMsgPose(pose);

// SimpleActiveCallback: we subscribe more extensive action state feedback
// SimpleFeedbackCallback: feedback returns current pose of the 'base', which we know quite well
/*
* - SimpleDoneCallback: returns action status with a big delay (compared to topic data) that interferes HuBeRo
* task-switching logic
* - SimpleActiveCallback: we subscribe more extensive action state feedback
* - SimpleFeedbackCallback: feedback returns current pose of the 'base', which we know quite well
*/
nav_action_client_ptr_->sendGoal(
nav_goal_,
std::bind(&NavigationRos::callbackActionDone, this, std::placeholders::_1, std::placeholders::_2),
MoveBaseActionClient::SimpleDoneCallback(),
MoveBaseActionClient::SimpleActiveCallback(),
MoveBaseActionClient::SimpleFeedbackCallback()
);
Expand Down Expand Up @@ -467,17 +471,6 @@ void NavigationRos::callbackResult(const move_base_msgs::MoveBaseActionResult::C
feedback_ = fb_type;
}

void NavigationRos::callbackActionDone(
const actionlib::SimpleClientGoalState& state,
const move_base_msgs::MoveBaseResultConstPtr& msg
) {
auto fb_type = NavigationRos::convertSimpleClientStateToTaskFeedback(state.state_);
if (fb_type == TASK_FEEDBACK_UNDEFINED) {
return;
}
feedback_ = fb_type;
}

std::tuple<bool, Pose3> NavigationRos::findTransform(const std::string& frame_source, const std::string& frame_target) const {
Pose3 transform;
bool success = false;
Expand Down Expand Up @@ -601,7 +594,7 @@ nav_msgs::Path NavigationRos::computePlan(
// restore previous goal
nav_action_client_ptr_->sendGoal(
nav_goal_,
std::bind(&NavigationRos::callbackActionDone, this, std::placeholders::_1, std::placeholders::_2),
MoveBaseActionClient::SimpleDoneCallback(),
MoveBaseActionClient::SimpleActiveCallback(),
MoveBaseActionClient::SimpleFeedbackCallback()
);
Expand Down

0 comments on commit e0bf60f

Please sign in to comment.