libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
MultiPathPlanner.h
1 #ifndef MULTIPATHPLANNER_H
2 #define MULTIPATHPLANNER_H
3 
4 #include <vector>
5 #include "HRI_costspace/HRICS_MultiHandOver.h"
6 #include "MultiHandOverUtils.hpp"
7 #include "utils/MultiHandOverAlgos.h"
8 #include "utils/multiHandOver/LazyWAstar.h"
9 
11 {
12 public:
14  MultiPathLWANode(std::vector<unsigned int> agents, std::vector<HRICS::MultiAgentCell*> positions,
15  HRICS::MHO::AbstractSolutionTools *sol_tools , bool allow_delay=false);
16  MultiPathLWANode(std::vector<unsigned int> agents, std::vector<HRICS::MultiAgentCell*> positions,
18  std::deque<mho::LWANodeInterface*> *prev_paths, std::deque<mho::LWANodeInterface*>::iterator prev_path_current, bool allow_delay=false);
20  virtual ~MultiPathLWANode();
21  virtual mho::LWANodeInterface* clone();
22 
23  virtual std::vector<LWANodeInterface*> sons();
24 
25  virtual double edgeCostEstimationFrom(LWANodeInterface *parent);
26  virtual double computeHeuristic(LWANodeInterface *goal);
27  virtual double computeTrueCost(LWANodeInterface *other);
28  virtual bool isSameConf(LWANodeInterface *other);
29 
30  double getDurationMax(){return _duration_max;}
31 
32  static MultiPathLWANode *cast(LWANodeInterface *p){return dynamic_cast<MultiPathLWANode *>(p);}
33 
34  HRICS::MultiAgentCell* cell(unsigned int i){return (i<_positions.size() ? _positions[i] : 0);}
35  void cell(unsigned int i, HRICS::MultiAgentCell*c){ if(i<_positions.size()){ _positions[i]=c;}}
36  int agent_index(unsigned int i){return (i<_agents_indices.size() ? _agents_indices[i] : -1);}
37  void agent_index(unsigned int i, unsigned int a){ if(i<_agents_indices.size()){ _agents_indices[i]=a;}}
38  typedef enum {NEVER,BEGIN,END} FreeWaiting_T;
39  void freeWainting(unsigned int i,FreeWaiting_T when){if(i<_agents_indices.size()) _wait_is_free[i]=when;}
40  FreeWaiting_T freeWainting(unsigned int i){return (i<_wait_is_free.size() ? _wait_is_free[i] : NEVER);}
41  void setAllowDelay(bool b){_allow_delay=b;}
42  bool getAllowDelay(){return _allow_delay;}
43  void setStartGoal(MultiPathLWANode *start,MultiPathLWANode* goal){_start=start;_goal=goal;}
44 
45 private:
47  std::vector<unsigned int> _agents_indices;
48  std::vector<HRICS::MultiAgentCell*> _positions;
49  MultiPathLWANode *_start,*_goal;
50  double _duration_max;
51  bool _allow_delay;
52  std::vector<FreeWaiting_T> _wait_is_free;
53 
54  HRICS::MHO::AbstractSolutionTools *_solution_tools;
55  std::deque<mho::LWANodeInterface*> *_prev_path;
56  std::deque<mho::LWANodeInterface*>::iterator _prev_path_current;
57 
58 };
59 
61 {
62  MOVE3D_STATIC_LOGGER;
63 public:
64  MultiPathPlannerLWADisplayInterface(bool show_text=true,bool draw=false,HRICS::MultiAgentGrid *grid=0):
65  _showText(show_text), _draw(draw), _grid(grid),
66  _open_c(0),_closed_c(0)
67  {}
68 
69  void setShowText(bool b){this->_showText=b;}
70  void setDraw(bool b,HRICS::MultiAgentGrid* grid){this->_draw=b;this->_grid=grid;}
71 
72  virtual void onOpen(mho::LWANodeInterface* open);
73  virtual void onClose(mho::LWANodeInterface* closed);
74  virtual void onFound(mho::LWANodeInterface* goal);
75  virtual void onFail();
76  virtual void onAbort();
77  virtual void onEnd(std::vector<std::pair<unsigned int,double> > times);
78 
79 private:
80  bool _showText;
81  bool _draw;
82  vector<HRICS::MultiAgentCell*> _cells_for_draw;
83  HRICS::MultiAgentGrid *_grid;
84  double _open_c;
85  double _closed_c;
86 };
87 
89 {
90  MOVE3D_STATIC_LOGGER;
91 public:
94 
95  bool compute(double time_limit_ms=-1);
96 
103  std::vector<HRICS::MultiAgentCell*> findParking(const std::deque<mho::LWANodeInterface *> &existing_path, unsigned int agent_to_park);
104 
105  std::deque<mho::LWANodeInterface*> getPath();
106 
107  void reset();
108 
110  void setAgents(std::vector<unsigned int> agents_ids);
112  void setStart(std::vector<HRICS::MultiAgentCell*> cells);
114  void setStart(unsigned int index, HRICS::MultiAgentCell* start);
116  void setStartByID(unsigned int agent_id,HRICS::MultiAgentCell* start);
120  void setGoal(std::vector<HRICS::MultiAgentCell*> cells);
121  void setGoal(unsigned int index, HRICS::MultiAgentCell* goal);
123  void setGoalByID(unsigned int agent_id,HRICS::MultiAgentCell* goal);
124 
125  void useParkingAreas(bool b,HRICS::MultiAgentGrid* grid){_park=b;_grid=grid;}
126 
127  void setSolutionTools(HRICS::MHO::AbstractSolutionTools *sol_tools);
128 
129  void setDisplay(bool showText,bool drawGrid=false,HRICS::MultiAgentGrid* grid=0);
130 
131  void setHierarchy(bool h){_hierachy=h;}
132  bool getHierarchy(){return _hierachy;}
133 
134 private:
137  bool _hierachy;
138  bool _park;
140  std::vector<unsigned int> _agents_indices;
142  std::vector<HRICS::MultiAgentCell*> _start_pos;
144  std::vector<HRICS::MultiAgentCell*> _goal_pos;
145 
146  double _epsilon;
148  MultiPathLWANode *_start,*_goal;
149 
151  HRICS::MHO::AbstractSolutionTools *_solution_tools;
152  HRICS::MultiAgentGrid *_grid;
153 };
154 
156 {
157 public:
159  std::map<HRICS::MHO::MultiHandOverAgent*,HRICS::MultiAgentCell*> start_state);
160  bool check();
161  std::vector<std::pair<HRICS::MHO::SubTask*,HRICS::MHO::SubTask*> > & getTasksInCollision(){return _colliding_stk;}
162  void setTask(HRICS::MHO::Task task);
163 private:
164  HRICS::MHO::Task* _tk;
165  std::map<HRICS::MHO::MultiHandOverAgent*,HRICS::MultiAgentCell*> _start_state;
166  HRICS::MultiAgentGrid *_grid;
167  std::vector<std::pair<HRICS::MHO::SubTask*,HRICS::MHO::SubTask*> > _colliding_stk;
168 };
169 
170 #endif // MULTIPATHPLANNER_H
Definition: MultiPathPlanner.h:155
void setAgents(std::vector< unsigned int > agents_ids)
set the agents to use
Definition: MultiPathPlanner.cpp:33
void setGoal(std::vector< HRICS::MultiAgentCell * > cells)
set the goal cells.
Definition: MultiPathPlanner.cpp:39
void setStart(std::vector< HRICS::MultiAgentCell * > cells)
set the starting cells for all agents
Definition: MultiPathPlanner.cpp:46
Definition: MultiPathPlanner.h:60
Definition: LazyWAstar.h:136
Plannar HRI Grid considering multiple agents systems for HRi operations.
Definition: HRICS_MultiAgentGrid.hpp:28
Definition: LazyWAstar.h:69
Definition: MultiHandOverAlgos.h:14
Definition: LazyWAstar.h:56
void setGoalByID(unsigned int agent_id, HRICS::MultiAgentCell *goal)
set the goal position for the agent having ID agent_id
Definition: MultiPathPlanner.cpp:69
Definition: MultiPathPlanner.h:10
void setStartByID(unsigned int agent_id, HRICS::MultiAgentCell *start)
set the starting position for the agent having ID agent_id
Definition: MultiPathPlanner.cpp:63
Plannar HRI Cell.
Definition: HRICS_MultiAgentGrid.hpp:462
Definition: MultiPathPlanner.h:88
Definition: MultiHandOverUtils.hpp:328
std::vector< HRICS::MultiAgentCell * > findParking(const std::deque< mho::LWANodeInterface * > &existing_path, unsigned int agent_to_park)
findParking finds a cell where an agent is safe from collision with any other robot anywhere along th...
Definition: MultiPathPlanner.cpp:146
Definition: LazyWAstar.h:25