The AbstractPlannerExecution class loads and binds the global planner plugin. It contains a thread running the plugin in a cycle to plan and re-plan. An internal state is saved and will be pulled by the server, which controls the global planner execution. Due to a state change it wakes up all threads connected to the condition variable. More...
#include <abstract_planner_execution.h>
Public Types | |
enum | PlanningState { INITIALIZED, STARTED, PLANNING, FOUND_PLAN, MAX_RETRIES, PAT_EXCEEDED, NO_PLAN_FOUND, CANCELED, STOPPED, INTERNAL_ERROR } |
Internal states. More... | |
typedef boost::shared_ptr < AbstractPlannerExecution > | Ptr |
shared pointer type to the planner execution. | |
Public Member Functions | |
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 bool | cancel () |
Cancel the planner execution. This calls the cancel method of the planner plugin. This could be useful if the computation takes too much time. | |
double | getCost () |
Gets computed costs. | |
double | getFrequency () |
Gets planning frequency. | |
ros::Time | getLastValidPlanTime () |
Returns the last time a valid plan was available. | |
std::vector < geometry_msgs::PoseStamped > | getPlan () |
Returns a new plan, if one is available. | |
PlanningState | getState () |
Returns the current internal state. | |
bool | isPatienceExceeded () |
Checks whether the patience was exceeded. | |
void | reconfigure (const MoveBaseFlexConfig &config) |
Is called by the server thread to reconfigure the controller execution, if a user uses dynamic reconfigure to reconfigure the current state. | |
void | setNewGoal (const geometry_msgs::PoseStamped &goal, double tolerance) |
Sets a new goal pose for the planner execution. | |
void | setNewStart (const geometry_msgs::PoseStamped &start) |
Sets a new start pose for the planner execution. | |
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 | start (const geometry_msgs::PoseStamped &start, const geometry_msgs::PoseStamped &goal, double tolerance) |
Starts the planner execution thread with the given parameters. | |
virtual | ~AbstractPlannerExecution () |
Destructor. | |
Protected Member Functions | |
virtual void | run () |
The main run method, a thread will execute this method. It contains the main planner execution loop. | |
Protected Attributes | |
mbf_abstract_core::AbstractPlanner::Ptr | planner_ |
the local planer to calculate the velocity command | |
std::string | plugin_name_ |
the name of the loaded planner plugin | |
Private Member Functions | |
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, if a goal tolerance is enabled in the planner plugin. | |
void | setState (PlanningState state) |
Sets the internal state, thread communication safe. | |
Private Attributes | |
boost::mutex | configuration_mutex_ |
dynamic reconfigure mutex for a thread safe communication | |
double | cost_ |
current global plan cost | |
double | frequency_ |
planning cycle frequency (used only when running full navigation; we store here for grouping parameters nicely) | |
std::string | global_frame_ |
the global frame in which the planner needs to plan | |
geometry_msgs::PoseStamped | goal_ |
the current goal pose used for planning | |
boost::mutex | goal_start_mtx_ |
mutex to handle safe thread communication for the goal and start pose. | |
bool | has_new_goal_ |
true, if a new goal pose has been set, until it is used. | |
bool | has_new_start_ |
true, if a new start pose has been set, until it is used. | |
ros::Time | last_call_start_time_ |
the last call start time, updated each cycle. | |
ros::Time | last_valid_plan_time_ |
the last time a valid plan has been computed. | |
int | max_retries_ |
planning max retries | |
ros::Duration | patience_ |
planning patience duration time | |
std::vector < geometry_msgs::PoseStamped > | plan_ |
current global plan | |
boost::mutex | plan_mtx_ |
mutex to handle safe thread communication for the plan and plan-costs | |
bool | planning_ |
main cycle variable of the execution loop | |
boost::mutex | planning_mtx_ |
mutex to handle safe thread communication for the planning_ flag. | |
std::string | robot_frame_ |
robot frame used for computing the current robot pose | |
geometry_msgs::PoseStamped | start_ |
the current start pose used for planning | |
PlanningState | state_ |
current internal state | |
boost::mutex | state_mtx_ |
mutex to handle safe thread communication for the current state | |
const TFPtr | tf_listener_ptr_ |
shared pointer to a common TransformListener | |
double | tolerance_ |
optional goal tolerance, in meters |
The AbstractPlannerExecution class loads and binds the global planner plugin. It contains a thread running the plugin in a cycle to plan and re-plan. An internal state is saved and will be pulled by the server, which controls the global planner execution. Due to a state change it wakes up all threads connected to the condition variable.
Definition at line 76 of file abstract_planner_execution.h.
typedef boost::shared_ptr<AbstractPlannerExecution > mbf_abstract_nav::AbstractPlannerExecution::Ptr |
shared pointer type to the planner execution.
Definition at line 81 of file abstract_planner_execution.h.
Internal states.
Definition at line 120 of file abstract_planner_execution.h.
mbf_abstract_nav::AbstractPlannerExecution::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.
condition | Thread sleep condition variable, to wake up connected threads |
Definition at line 47 of file abstract_planner_execution.cpp.
Destructor.
Definition at line 66 of file abstract_planner_execution.cpp.
bool mbf_abstract_nav::AbstractPlannerExecution::cancel | ( | ) | [virtual] |
Cancel the planner execution. This calls the cancel method of the planner plugin. This could be useful if the computation takes too much time.
Implements mbf_abstract_nav::AbstractExecutionBase.
Definition at line 193 of file abstract_planner_execution.cpp.
Gets computed costs.
Definition at line 71 of file abstract_planner_execution.cpp.
double mbf_abstract_nav::AbstractPlannerExecution::getFrequency | ( | ) | [inline] |
Gets planning frequency.
Definition at line 143 of file abstract_planner_execution.h.
Returns the last time a valid plan was available.
Definition at line 118 of file abstract_planner_execution.cpp.
std::vector< geometry_msgs::PoseStamped > mbf_abstract_nav::AbstractPlannerExecution::getPlan | ( | ) |
Returns a new plan, if one is available.
plan | A reference to a plan, which then will be filled. |
cost | A reference to the costs, which then will be filled. |
Definition at line 131 of file abstract_planner_execution.cpp.
Returns the current internal state.
Definition at line 105 of file abstract_planner_execution.cpp.
Checks whether the patience was exceeded.
Definition at line 125 of file abstract_planner_execution.cpp.
uint32_t mbf_abstract_nav::AbstractPlannerExecution::makePlan | ( | const geometry_msgs::PoseStamped & | start, |
const geometry_msgs::PoseStamped & | goal, | ||
double | tolerance, | ||
std::vector< geometry_msgs::PoseStamped > & | plan, | ||
double & | cost, | ||
std::string & | message | ||
) | [private, virtual] |
calls the planner plugin to make a plan from the start pose to the goal pose with the given tolerance, if a goal tolerance is enabled in the planner plugin.
start | The start pose for planning |
goal | The goal pose for planning |
tolerance | The goal tolerance |
plan | The computed plan by the plugin |
cost | The computed costs for the corresponding plan |
message | An optional message which should correspond with the returned outcome |
Definition at line 208 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::reconfigure | ( | const MoveBaseFlexConfig & | config | ) |
Is called by the server thread to reconfigure the controller execution, if a user uses dynamic reconfigure to reconfigure the current state.
config | MoveBaseFlexConfig object |
Definition at line 92 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::run | ( | ) | [protected, virtual] |
The main run method, a thread will execute this method. It contains the main planner execution loop.
Implements mbf_abstract_nav::AbstractExecutionBase.
Definition at line 218 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::setNewGoal | ( | const geometry_msgs::PoseStamped & | goal, |
double | tolerance | ||
) |
Sets a new goal pose for the planner execution.
goal | the new goal pose |
tolerance | tolerance to the goal for the planning |
Definition at line 139 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::setNewStart | ( | const geometry_msgs::PoseStamped & | start | ) |
Sets a new start pose for the planner execution.
start | new start pose |
Definition at line 148 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::setNewStartAndGoal | ( | const geometry_msgs::PoseStamped & | start, |
const geometry_msgs::PoseStamped & | goal, | ||
double | tolerance | ||
) |
Sets a new star and goal pose for the planner execution.
start | new start pose |
goal | new goal pose |
tolerance | tolerance to the new goal for the planning |
Definition at line 156 of file abstract_planner_execution.cpp.
void mbf_abstract_nav::AbstractPlannerExecution::setState | ( | PlanningState | state | ) | [private] |
Sets the internal state, thread communication safe.
state | the current state |
Definition at line 111 of file abstract_planner_execution.cpp.
bool mbf_abstract_nav::AbstractPlannerExecution::start | ( | const geometry_msgs::PoseStamped & | start, |
const geometry_msgs::PoseStamped & | goal, | ||
double | tolerance | ||
) |
Starts the planner execution thread with the given parameters.
start | start pose for the planning |
goal | goal pose for the planning |
tolerance | tolerance to the goal pose for the planning |
Definition at line 169 of file abstract_planner_execution.cpp.
boost::mutex mbf_abstract_nav::AbstractPlannerExecution::configuration_mutex_ [private] |
dynamic reconfigure mutex for a thread safe communication
Definition at line 301 of file abstract_planner_execution.h.
double mbf_abstract_nav::AbstractPlannerExecution::cost_ [private] |
current global plan cost
Definition at line 265 of file abstract_planner_execution.h.
double mbf_abstract_nav::AbstractPlannerExecution::frequency_ [private] |
planning cycle frequency (used only when running full navigation; we store here for grouping parameters nicely)
Definition at line 277 of file abstract_planner_execution.h.
std::string mbf_abstract_nav::AbstractPlannerExecution::global_frame_ [private] |
the global frame in which the planner needs to plan
Definition at line 292 of file abstract_planner_execution.h.
geometry_msgs::PoseStamped mbf_abstract_nav::AbstractPlannerExecution::goal_ [private] |
the current goal pose used for planning
Definition at line 271 of file abstract_planner_execution.h.
boost::mutex mbf_abstract_nav::AbstractPlannerExecution::goal_start_mtx_ [private] |
mutex to handle safe thread communication for the goal and start pose.
Definition at line 244 of file abstract_planner_execution.h.
bool mbf_abstract_nav::AbstractPlannerExecution::has_new_goal_ [private] |
true, if a new goal pose has been set, until it is used.
Definition at line 250 of file abstract_planner_execution.h.
bool mbf_abstract_nav::AbstractPlannerExecution::has_new_start_ [private] |
true, if a new start pose has been set, until it is used.
Definition at line 253 of file abstract_planner_execution.h.
the last call start time, updated each cycle.
Definition at line 256 of file abstract_planner_execution.h.
the last time a valid plan has been computed.
Definition at line 259 of file abstract_planner_execution.h.
int mbf_abstract_nav::AbstractPlannerExecution::max_retries_ [private] |
planning max retries
Definition at line 283 of file abstract_planner_execution.h.
planning patience duration time
Definition at line 280 of file abstract_planner_execution.h.
std::vector<geometry_msgs::PoseStamped> mbf_abstract_nav::AbstractPlannerExecution::plan_ [private] |
current global plan
Definition at line 262 of file abstract_planner_execution.h.
boost::mutex mbf_abstract_nav::AbstractPlannerExecution::plan_mtx_ [private] |
mutex to handle safe thread communication for the plan and plan-costs
Definition at line 241 of file abstract_planner_execution.h.
mbf_abstract_core::AbstractPlanner::Ptr mbf_abstract_nav::AbstractPlannerExecution::planner_ [protected] |
the local planer to calculate the velocity command
Definition at line 200 of file abstract_planner_execution.h.
bool mbf_abstract_nav::AbstractPlannerExecution::planning_ [private] |
main cycle variable of the execution loop
Definition at line 286 of file abstract_planner_execution.h.
boost::mutex mbf_abstract_nav::AbstractPlannerExecution::planning_mtx_ [private] |
mutex to handle safe thread communication for the planning_ flag.
Definition at line 247 of file abstract_planner_execution.h.
std::string mbf_abstract_nav::AbstractPlannerExecution::plugin_name_ [protected] |
the name of the loaded planner plugin
Definition at line 203 of file abstract_planner_execution.h.
std::string mbf_abstract_nav::AbstractPlannerExecution::robot_frame_ [private] |
robot frame used for computing the current robot pose
Definition at line 289 of file abstract_planner_execution.h.
geometry_msgs::PoseStamped mbf_abstract_nav::AbstractPlannerExecution::start_ [private] |
the current start pose used for planning
Definition at line 268 of file abstract_planner_execution.h.
current internal state
Definition at line 298 of file abstract_planner_execution.h.
boost::mutex mbf_abstract_nav::AbstractPlannerExecution::state_mtx_ [private] |
mutex to handle safe thread communication for the current state
Definition at line 238 of file abstract_planner_execution.h.
const TFPtr mbf_abstract_nav::AbstractPlannerExecution::tf_listener_ptr_ [private] |
shared pointer to a common TransformListener
Definition at line 295 of file abstract_planner_execution.h.
double mbf_abstract_nav::AbstractPlannerExecution::tolerance_ [private] |
optional goal tolerance, in meters
Definition at line 274 of file abstract_planner_execution.h.