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();
134 mbf_msgs::MoveBaseResult move_base_result;
155 move_base_result.message =
"Could not get the current robot pose!";
156 move_base_result.outcome = mbf_msgs::MoveBaseResult::TF_ERROR;
157 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)
189 mbf_msgs::MoveBaseFeedback move_base_feedback;
190 move_base_feedback.outcome = feedback->outcome;
191 move_base_feedback.message = feedback->message;
192 move_base_feedback.angle_to_goal = feedback->angle_to_goal;
193 move_base_feedback.dist_to_goal = feedback->dist_to_goal;
194 move_base_feedback.current_pose = feedback->current_pose;
195 move_base_feedback.last_cmd_vel = feedback->last_cmd_vel;
214 ROS_INFO_NAMED(
"move_base",
"Recovered from robot oscillation: restart recovery behaviors");
221 std::stringstream oscillation_msgs;
232 mbf_msgs::MoveBaseResult move_base_result;
233 move_base_result.outcome = mbf_msgs::MoveBaseResult::OSCILLATION;
234 move_base_result.message = oscillation_msgs.str();
236 move_base_result.angle_to_goal = move_base_feedback.angle_to_goal;
237 move_base_result.dist_to_goal = move_base_feedback.dist_to_goal;
246 const mbf_msgs::GetPathResultConstPtr &result_ptr)
248 const mbf_msgs::GetPathResult &get_path_result = *result_ptr;
249 mbf_msgs::MoveBaseResult move_base_result;
257 ROS_FATAL_STREAM_NAMED(
"move_base",
"get_path PENDING state not implemented, this should not be reachable!");
262 <<
"move_base\" received a path from \"" 263 <<
"get_path\": " << state.
getText());
267 <<
"move_base\" sends the path to \"" 272 ROS_WARN_NAMED(
"move_base",
"Recovered from planner failure: restart recovery behaviors");
294 ROS_WARN_STREAM_NAMED(
"move_base",
"Abort the execution of the planner: " << get_path_result.message);
352 const mbf_msgs::ExePathResultConstPtr &result_ptr)
356 const mbf_msgs::ExePathResult& exe_path_result = *result_ptr;
357 mbf_msgs::MoveBaseResult move_base_result;
367 move_base_result.outcome = mbf_msgs::MoveBaseResult::SUCCESS;
368 move_base_result.message =
"Action \"move_base\" succeeded!";
377 switch (exe_path_result.outcome)
379 case mbf_msgs::ExePathResult::INVALID_PATH:
380 case mbf_msgs::ExePathResult::TF_ERROR:
381 case mbf_msgs::ExePathResult::NOT_INITIALIZED:
382 case mbf_msgs::ExePathResult::INVALID_PLUGIN:
383 case mbf_msgs::ExePathResult::INTERNAL_ERROR:
397 ROS_WARN_STREAM_NAMED(
"move_base",
"Abort the execution of the controller: " << exe_path_result.message);
469 const mbf_msgs::RecoveryResultConstPtr &result_ptr)
474 const mbf_msgs::RecoveryResult& recovery_result = *result_ptr;
475 mbf_msgs::MoveBaseResult move_base_result;
489 <<
", outcome: " << recovery_result.outcome);
495 "All recovery behaviors failed. Abort recovering and abort the move_base action");
515 "Try planning again and increment the current recovery behavior in the list.");
549 const mbf_msgs::GetPathResultConstPtr &result)
556 ROS_DEBUG_STREAM_NAMED(
"move_base",
"Replanning succeeded; sending a goal to \"exe_path\" with the new plan");
void publishFeedback(const Feedback &feedback)
const mbf_utility::RobotInformation & robot_info_
current robot state
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_
ros::Duration oscillation_timeout_
timeout after a oscillation is detected
#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_
boost::shared_ptr< const Goal > getGoal() const
#define ROS_INFO_STREAM_NAMED(name, args)
ros::Rate replanning_rate_
MoveBaseAction(const std::string &name, const mbf_utility::RobotInformation &robot_info, const std::vector< std::string > &controllers)
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)
void fillMoveBaseResult(const ResultType &result, mbf_msgs::MoveBaseResult &move_base_result)
mbf_msgs::ExePathGoal exe_path_goal_
double distance(const geometry_msgs::PoseStamped &pose1, const geometry_msgs::PoseStamped &pose2)
MoveBaseActionState recovery_trigger_
bool recovery_enabled_
true, if recovery behavior for the MoveBase action is enabled.
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())
geometry_msgs::PoseStamped goal_pose_
current goal pose; used to compute remaining distance and angle
std::vector< std::string >::iterator current_recovery_behavior_
geometry_msgs::PoseStamped robot_pose_
current robot pose; updated with exe_path action feedback
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)
void actionExePathActive()
ActionClientExePath action_client_exe_path_
Action client used by the move_base action.
void start(GoalHandle &goal_handle)
double oscillation_distance_
minimal move distance to not detect an oscillation
#define ROS_WARN_STREAM_NAMED(name, args)