43 #include "mbf_abstract_nav/MoveBaseFlexConfig.h" 51 const std::vector<std::string> &behaviors)
52 : name_(name), robot_info_(robot_info), private_nh_(
"~"),
53 action_client_exe_path_(private_nh_,
"exe_path"),
54 action_client_get_path_(private_nh_,
"get_path"),
55 action_client_recovery_(private_nh_,
"recovery"),
56 oscillation_timeout_(0),
57 oscillation_distance_(0),
58 recovery_enabled_(true),
59 behaviors_(behaviors),
61 recovery_trigger_(NONE),
72 mbf_abstract_nav::MoveBaseFlexConfig &config, uint32_t level)
74 if (config.planner_frequency > 0.0)
86 <<
": start replanning, using the \"get_path\" action!");
132 const mbf_msgs::MoveBaseGoal& goal = *(goal_handle.
getGoal().get());
134 mbf_msgs::MoveBaseResult move_base_result;
151 geometry_msgs::PoseStamped robot_pose;
156 move_base_result.message =
"Could not get the current robot pose!";
157 move_base_result.outcome = mbf_msgs::MoveBaseResult::TF_ERROR;
158 goal_handle.
setAborted(move_base_result, move_base_result.message);
168 "\"get_path\" , \"exe_path\", \"recovery \"!");
169 move_base_result.outcome = mbf_msgs::MoveBaseResult::INTERNAL_ERROR;
170 move_base_result.message =
"Could not connect to the move_base_flex actions!";
171 goal_handle.
setAborted(move_base_result, move_base_result.message);
187 const mbf_msgs::ExePathFeedbackConstPtr &feedback)
213 ROS_INFO_NAMED(
"move_base",
"Recovered from robot oscillation: restart recovery behaviors");
220 std::stringstream oscillation_msgs;
231 mbf_msgs::MoveBaseResult move_base_result;
234 move_base_result.message = oscillation_msgs.str() +
" No recovery behaviors for the move_base action are defined!";
236 move_base_result.message = oscillation_msgs.str() +
" Recovery is disabled for the move_base action! use the param \"enable_recovery\"";
248 const mbf_msgs::GetPathResultConstPtr &result_ptr)
252 const mbf_msgs::GetPathResult &result = *(result_ptr.get());
254 mbf_msgs::MoveBaseResult move_base_result;
258 ROS_FATAL_STREAM_NAMED(
"move_base",
"get_path PENDING state not implemented, this should not be reachable!");
263 <<
"move_base\" received a path from \"" 264 <<
"get_path\": " << state.
getText());
268 <<
"move_base\" sends the path to \"" 273 ROS_WARN_NAMED(
"move_base",
"Recovered from planner failure: restart recovery behaviors");
295 move_base_result.outcome = result.outcome;
296 move_base_result.message = result.message;
310 move_base_result.outcome = result.outcome;
311 move_base_result.message = result.message;
320 ROS_FATAL_STREAM_NAMED(
"move_base",
"The states RECALLED and REJECTED are not implemented in the SimpleActionServer!");
357 const mbf_msgs::ExePathResultConstPtr &result_ptr)
363 const mbf_msgs::ExePathResult& result = *(result_ptr.get());
365 mbf_msgs::MoveBaseResult move_base_result;
368 move_base_result.outcome = result.outcome;
369 move_base_result.message = result.message;
370 move_base_result.dist_to_goal = result.dist_to_goal;
371 move_base_result.angle_to_goal = result.angle_to_goal;
372 move_base_result.final_pose = result.final_pose;
379 move_base_result.outcome = mbf_msgs::MoveBaseResult::SUCCESS;
380 move_base_result.message =
"Action \"move_base\" succeeded!";
387 switch (result.outcome)
389 case mbf_msgs::ExePathResult::INVALID_PATH:
390 case mbf_msgs::ExePathResult::TF_ERROR:
391 case mbf_msgs::ExePathResult::NOT_INITIALIZED:
392 case mbf_msgs::ExePathResult::INVALID_PLUGIN:
393 case mbf_msgs::ExePathResult::INTERNAL_ERROR:
417 <<
"exe_path" <<
"\" was preempted successfully!");
423 <<
"exe_path" <<
"\" was recalled!");
429 <<
"exe_path" <<
"\" was rejected!");
439 "Reached unreachable case! Unknown SimpleActionServer state!");
479 const mbf_msgs::RecoveryResultConstPtr &result_ptr)
483 const mbf_msgs::RecoveryResult& result = *(result_ptr.get());
485 mbf_msgs::MoveBaseResult move_base_result;
488 move_base_result.outcome = result.outcome;
489 move_base_result.message = result.message;
501 <<
", outcome: " << result.outcome);
507 "All recovery behaviors failed. Abort recovering and abort the move_base action");
527 "Try planning again and increment the current recovery behavior in the list.");
537 "The recovery action has been preempted!");
544 "The recovery action has been recalled!");
551 "The recovery action has been rejected!");
556 "The recovery action has lost the connection to the server!");
561 "Reached unreachable case! Unknown state!");
569 const mbf_msgs::GetPathResultConstPtr &result)
576 ROS_DEBUG_STREAM_NAMED(
"move_base",
"Replanning succeeded; sending a goal to \"exe_path\" with the new plan");
void publishFeedback(const Feedback &feedback)
double angle(const geometry_msgs::PoseStamped &pose1, const geometry_msgs::PoseStamped &pose2)
std::vector< std::string > recovery_behaviors_
#define ROS_INFO_NAMED(name,...)
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
mbf_msgs::GetPathGoal get_path_goal_
mbf_msgs::MoveBaseFeedback move_base_feedback_
ros::Duration oscillation_timeout_
#define ROS_DEBUG_STREAM_NAMED(name, args)
geometry_msgs::PoseStamped last_oscillation_pose_
#define ROS_ERROR_STREAM_NAMED(name, args)
#define ROS_WARN_NAMED(name,...)
void actionExePathDone(const actionlib::SimpleClientGoalState &state, const mbf_msgs::ExePathResultConstPtr &result)
ros::Time last_oscillation_reset_
void setRejected(const Result &result=Result(), const std::string &text=std::string(""))
MoveBaseAction(const std::string &name, const RobotInformation &robot_info, const std::vector< std::string > &controllers)
boost::shared_ptr< const Goal > getGoal() const
#define ROS_INFO_STREAM_NAMED(name, args)
ros::Rate replanning_rate_
void setCanceled(const Result &result=Result(), const std::string &text=std::string(""))
std::string toString() const
ActionClientGetPath action_client_get_path_
Action client used by the move_base action.
void setAccepted(const std::string &text=std::string(""))
void reconfigure(mbf_abstract_nav::MoveBaseFlexConfig &config, uint32_t level)
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
const std::vector< std::string > & behaviors_
#define ROS_FATAL_STREAM_NAMED(name, args)
mbf_msgs::RecoveryGoal recovery_goal_
void actionRecoveryDone(const actionlib::SimpleClientGoalState &state, const mbf_msgs::RecoveryResultConstPtr &result)
std::string getText() const
void actionGetPathDone(const actionlib::SimpleClientGoalState &state, const mbf_msgs::GetPathResultConstPtr &result)
MoveBaseActionState action_state_
#define ROS_DEBUG_STREAM(args)
mbf_msgs::ExePathGoal exe_path_goal_
double distance(const geometry_msgs::PoseStamped &pose1, const geometry_msgs::PoseStamped &pose2)
MoveBaseActionState recovery_trigger_
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
boost::mutex replanning_mtx_
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
std::vector< std::string >::iterator current_recovery_behavior_
geometry_msgs::PoseStamped robot_pose_
SimpleClientGoalState getState() const
ActionClientRecovery action_client_recovery_
Action client used by the move_base action.
void actionGetPathReplanningDone(const actionlib::SimpleClientGoalState &state, const mbf_msgs::GetPathResultConstPtr &result)
void actionExePathFeedback(const mbf_msgs::ExePathFeedbackConstPtr &feedback)
RobotInformation robot_info_
void actionExePathActive()
ActionClientExePath action_client_exe_path_
Action client used by the move_base action.
void start(GoalHandle &goal_handle)
double oscillation_distance_
#define ROS_WARN_STREAM_NAMED(name, args)