49 const MoveBaseFlexConfig &config,
50 boost::function<
void()> setup_fn,
51 boost::function<
void()> cleanup_fn) :
53 planner_(planner_ptr), state_(INITIALIZED), planning_(false),
54 has_new_start_(false), has_new_goal_(false)
73 boost::lock_guard<boost::mutex> guard(
plan_mtx_);
81 geometry_msgs::PoseStamped prev_pose =
plan_.front();
82 for(std::vector<geometry_msgs::PoseStamped>::iterator iter =
plan_.begin() + 1; iter !=
plan_.end(); ++iter)
107 boost::lock_guard<boost::mutex> guard(
state_mtx_);
113 boost::lock_guard<boost::mutex> guard(
state_mtx_);
120 boost::lock_guard<boost::mutex> guard(
plan_mtx_);
133 boost::lock_guard<boost::mutex> guard(
plan_mtx_);
157 const geometry_msgs::PoseStamped &goal,
170 const geometry_msgs::PoseStamped &goal,
183 geometry_msgs::Point
s = start.pose.position;
184 geometry_msgs::Point g = goal.pose.position;
186 ROS_DEBUG_STREAM(
"Start planning from the start pose: (" << s.x <<
", " << s.y <<
", " << s.z <<
")" 187 <<
" to the goal pose: ("<< g.x <<
", " << g.y <<
", " << g.z <<
")");
200 ROS_WARN_STREAM(
"Cancel planning failed or is not supported by the plugin. " 201 <<
"Wait until the current planning finished!");
209 const geometry_msgs::PoseStamped &goal,
211 std::vector<geometry_msgs::PoseStamped> &plan,
213 std::string &message)
215 return planner_->makePlan(start, goal, tolerance, plan, cost, message);
222 geometry_msgs::PoseStamped current_start =
start_;
223 geometry_msgs::PoseStamped current_goal =
goal_;
226 bool success =
false;
227 bool make_plan =
false;
228 bool exceeded =
false;
237 boost::chrono::thread_clock::time_point start_time = boost::chrono::thread_clock::now();
240 std::vector<geometry_msgs::PoseStamped> plan;
249 ROS_INFO_STREAM(
"A new start pose is available. Planning with the new start pose!");
251 geometry_msgs::Point
s =
start_.pose.position;
252 ROS_INFO_STREAM(
"New planning start pose: (" << s.x <<
", " << s.y <<
", " << s.z <<
")");
257 current_goal =
goal_;
259 ROS_INFO_STREAM(
"A new goal pose is available. Planning with the new goal pose and the tolerance: " 260 << current_tolerance);
262 geometry_msgs::Point g =
goal_.pose.position;
263 ROS_INFO_STREAM(
"New goal pose: (" << g.x <<
", " << g.y <<
", " << g.z <<
")");
315 << (
cancel_ ?
"; planner canceled!" :
""));
344 catch (
const boost::thread_interrupted &ex)
354 ROS_FATAL_STREAM(
"Unknown error occurred: " << boost::current_exception_diagnostic_information());
ros::Time last_valid_plan_time_
the last time a valid plan has been computed.
boost::condition_variable condition_
condition variable to wake up control thread
void notify_all() BOOST_NOEXCEPT
PlanningState getState()
Returns the current internal state.
geometry_msgs::PoseStamped goal_
the current goal pose used for planning
bool has_new_start_
true, if a new start pose has been set, until it is used.
int max_retries_
planning max retries
virtual uint32_t makePlan(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, double tolerance, std::vector< geometry_msgs::PoseStamped > &plan, double &cost, std::string &message)
calls the planner plugin to make a plan from the start pose to the goal pose with the given tolerance...
geometry_msgs::PoseStamped start_
the current start pose used for planning
The planner has been stopped.
double tolerance_
optional goal tolerance, in meters
bool isPatienceExceeded()
Checks whether the patience was exceeded.
No plan has been found (MAX_RETRIES and PAT_EXCEEDED are 0).
PlanningState state_
current internal state
void setState(PlanningState state)
Sets the internal state, thread communication safe.
boost::mutex configuration_mutex_
dynamic reconfigure mutex for a thread safe communication
The planner has been canceled.
AbstractPlannerExecution(const std::string name, const mbf_abstract_core::AbstractPlanner::Ptr planner_ptr, const MoveBaseFlexConfig &config, boost::function< void()> setup_fn, boost::function< void()> cleanup_fn)
Constructor.
virtual void run()
The main run method, a thread will execute this method. It contains the main planner execution loop...
bool planning_
main cycle variable of the execution loop
bool cancel_
flag for canceling controlling
std::string message_
the last received plugin execution message
double cost_
current global plan cost
Exceeded the maximum number of retries without a valid command.
ros::Time getLastValidPlanTime()
Returns the last time a valid plan was available.
#define ROS_FATAL_STREAM(args)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
ros::Time last_call_start_time_
the last call start time, updated each cycle.
An internal error occurred.
uint32_t outcome_
the last received plugin execution outcome
boost::mutex state_mtx_
mutex to handle safe thread communication for the current state
void setNewStart(const geometry_msgs::PoseStamped &start)
Sets a new start pose for the planner execution.
virtual bool cancel()
Cancel the planner execution. This calls the cancel method of the planner plugin. This could be usefu...
Exceeded the patience time without a valid command.
void setNewGoal(const geometry_msgs::PoseStamped &goal, double tolerance)
Sets a new goal pose for the planner execution.
double frequency_
planning cycle frequency (used only when running full navigation; we store here for grouping paramete...
std::vector< geometry_msgs::PoseStamped > getPlan()
Returns a new plan, if one is available.
boost::mutex plan_mtx_
mutex to handle safe thread communication for the plan and plan-costs
#define ROS_WARN_STREAM(args)
PlanningState
Internal states.
#define ROS_DEBUG_STREAM(args)
std::string global_frame_
the global frame in which the planner needs to plan
boost::mutex goal_start_mtx_
mutex to handle safe thread communication for the goal and start pose.
double distance(const geometry_msgs::PoseStamped &pose1, const geometry_msgs::PoseStamped &pose2)
std::vector< geometry_msgs::PoseStamped > plan_
current global plan
#define ROS_INFO_STREAM(args)
void setNewStartAndGoal(const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, double tolerance)
Sets a new star and goal pose for the planner execution.
bool has_new_goal_
true, if a new goal pose has been set, until it is used.
mbf_abstract_core::AbstractPlanner::Ptr planner_
the local planer to calculate the velocity command
boost::mutex planning_mtx_
mutex to handle safe thread communication for the planning_ flag.
virtual ~AbstractPlannerExecution()
Destructor.
void reconfigure(const MoveBaseFlexConfig &config)
Is called by the server thread to reconfigure the controller execution, if a user uses dynamic reconf...
std::string robot_frame_
robot frame used for computing the current robot pose
ros::Duration patience_
planning patience duration time
double getCost()
Gets computed costs.