00001 #ifndef CONTINUAL_PLANNING_H 00002 #define CONTINUAL_PLANNING_H 00003 00004 #include <vector> 00005 #include <ros/ros.h> 00006 #include "continual_planning_executive/symbolicState.h" 00007 #include "continual_planning_executive/stateCreator.h" 00008 #include "continual_planning_executive/goalCreator.h" 00009 #include "continual_planning_executive/plannerInterface.h" 00010 #include "continual_planning_executive/statusPublisher.h" 00011 #include "planExecutor.h" 00012 00013 // constantly do the following: 00014 // estimate current state 00015 // check that curState + curPlan will lead to goal 00016 // if not: 00017 // replan 00018 // executros 00019 // check/keep running actions 00020 // preempt if conflicting? planner always assumes no running actions? 00021 // should never decide: oops s.th. changed lets redo everything 00022 // -- make monitoring nice/safe 00023 // 00024 // Plan monitoring does not work, if move_base/make_plan fails during movement 00025 // also: Execution failures should trigger replan somehow: i.e. drive to gap -> fail -> replan 00026 // probably need partial/subgoal plan then to get away and make new situation 00027 // 00028 // check contiplan paper 00029 00030 00032 class ContinualPlanning 00033 { 00034 public: 00035 friend bool loadStateCreators(ros::NodeHandle & nh); 00036 friend bool loadGoalCreators(ros::NodeHandle & nh); 00037 friend bool loadActionExecutors(ros::NodeHandle & nh); 00038 friend bool loadPlanner(ros::NodeHandle & nh); 00039 friend void signal_handler(int); 00040 00041 enum ContinualPlanningState { 00042 Running, 00043 FinishedNoPlanToGoal, 00044 FinishedAtGoal 00045 }; 00046 00047 enum ReplanningTriggerMethod { 00048 ReplanAlways, 00049 ReplanIfLogicalStateChanged, 00050 ReplanByMonitoring 00051 }; 00052 00053 ContinualPlanning(); 00054 ~ContinualPlanning(); 00055 00057 00060 ContinualPlanningState loop(); 00061 00063 bool estimateCurrentState(); 00064 00066 bool isGoalFulfilled() const; 00067 00068 00070 bool executeActionDirectly(const DurativeAction & a, bool publishStatus); 00071 00073 void forceReplanning() { _forceReplan = true; } 00074 00075 protected: 00077 00084 Plan monitorAndReplan(bool & atGoal); 00085 00087 00090 bool needReplanning(bool & atGoal) const; 00091 00092 protected: 00093 std::vector<continual_planning_executive::StateCreator*> _stateCreators; 00094 continual_planning_executive::PlannerInterface* _planner; 00095 PlanExecutor _planExecutor; 00096 00097 SymbolicState _currentState; 00098 SymbolicState _goal; 00099 Plan _currentPlan; 00100 00101 bool _forceReplan; 00102 ReplanningTriggerMethod _replanningTrigger; 00103 00104 bool _allowDirectGoalCheck; 00105 00106 StatusPublisher _status; 00107 }; 00108 00109 #endif 00110