libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
HRICS_EnvGrid.hpp
1 #ifndef HRICS_EnvGRID_HPP
2 #define HRICS_EnvGRID_HPP
3 
4 #include "API/planningAPI.hpp"
5 #include "API/Grids/gridsAPI.hpp"
6 
7 namespace HRICS
8 {
9  class EnvCell;
14  class EnvGrid : public API::TwoDGrid
15  {
16  public:
17 
18  EnvGrid();
19  EnvGrid(double pace, std::vector<double> envSize, bool isHumanCentered);
20  EnvGrid(double pace, std::vector<double> envSize, bool isHumanCentered, Robot* robot, Robot* human);
21 
22  //getters and setters
23  void setRobot(Robot* R) { mRobot = R; }
24  Robot* getRobot() { return mRobot; }
25 
26  void setHuman(Robot* R) { mHuman = R; }
27  Robot* getHuman() { return mHuman; }
28 
29  Robot* getHumanCylinder() {return humCyl;}
30  Robot* getRobotCylinder() {return robotCyl;}
31 
32  double getNbCellX() {return _nbCellsX;}
33  double getNbCellY() {return _nbCellsY;}
34 
35  double getHumanMaxDist() {return m_humanMaxDist;}
36  double getRobotMaxDist() { return m_robotMaxDist;}
37 
38  void setAsNotSorted() {gridIsSorted = false;}
39 
40  std::vector<EnvCell*> getHumanAccessibleCells() {return m_HumanAccessible;}
41 
42  void dumpVar();
43 
47  void init(std::pair<double,double> minMax);
48 
52  void initGrid(Eigen::Vector3d humanPos);
53 
57  void recomputeGridWhenHumanMove(Eigen::Vector3d humanPos);
58 
62  void computeHumanRobotReacheability(std::pair<double,double> minMax);
63 
72  API::TwoDCell* createNewCell(unsigned int index,unsigned int x,unsigned int y );
73 
77  void computeDistances(EnvCell* cell, bool isHuman);
78 
82  void computeRobotDistances(EnvCell* cell);
83 
87  void computeHumanDistances(EnvCell* cell);
88 
92  void draw();
93 
97  void setCellsToblankCost();
98 
102  void initAllCellState();
103 
107  void initAllTrajs();
108 
112  void initAllReachability();
113 
117  std::vector<std::pair<double,EnvCell*> > getSortedGrid();
118 
119  private:
123  Robot* mRobot;
124 
128  Robot* mHuman;
129 
133  Robot* robotCyl;
134 
138  Robot* humCyl;
139 
143  double m_humanMaxDist;
144 
148  double m_robotMaxDist;
149 
153  std::vector<EnvCell*> m_HumanAccessible;
154 
158  std::vector<EnvCell*> m_RobotAccessible;
159 
163  std::vector<std::pair<double,EnvCell*> > sortedGrid;
164 
168  bool gridIsSorted;
169  };
170 
175  class EnvCell : public API::TwoDCell
176  {
177 
178  public:
179  EnvCell();
180  EnvCell(int i, Eigen::Vector2i coord, Eigen::Vector2d corner, EnvGrid* grid);
181 
182  ~EnvCell() { }
183 
184  //#######################
185  //getters et setters ####
186  //#######################
187 
188  //human distance computing
189  void setHumanDist(double value) {m_humanDist = value; }
190  double getHumanDist() {return m_humanDist; }
191  void setHumanDistIsComputed() {m_humanDistIsComputed = true;}
192  bool isHumanDistComputed() {return m_humanDistIsComputed;}
193 
194  // robot distance computing
195  void setRobotDist(double value) {m_robotDist = value; }
196  double getRobotDist() {return m_robotDist; }
197  void setRobotDistIsComputed() {m_robotDistIsComputed = true;}
198  bool isRobotDistComputed() {return m_robotDistIsComputed;}
199 
200  // distance propagation algorithm
201  bool getOpen() { return _Open; }
202  void setOpen() { _Open = true; }
203 
204  bool getClosed() { return _Closed; }
205  void setClosed() { _Closed = true; }
206 
207  void resetExplorationStatus() { _Open = false; _Closed = false; }
208 
209  // Trajectories
210 
211  std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > getHumanVectorTraj() {return humanVectorTraj;}
212  void setHumanVectorTraj(std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > _humanVectorTraj) {humanVectorTraj = _humanVectorTraj; }
213 
214  std::vector<EnvCell*> getHumanTraj() {return humanTraj;}
215  void setHumanTraj(std::vector<EnvCell*> _humanTraj) {humanTraj = _humanTraj; }
216 
217  std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > getRobotVectorTraj() {return robotVectorTraj;}
218  void setRobotVectorTraj(std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > _RobotVectorTraj) {robotVectorTraj = _RobotVectorTraj; }
219 
220  std::vector<EnvCell*> getRobotTraj() {return robotTraj;}
221  void setRobotTraj(std::vector<EnvCell*> _robotTraj) {robotTraj = _robotTraj; }
222 
223  //accessibility
224  bool isHumAccessible() {return m_isHumanAccessible;}
225  void setHumAccessible(bool value) {m_isHumanAccessible = value;}
226 
227  bool isRobAccessible() {return m_isRobotAccessible;}
228  void setRobAccessible(bool value) {m_isRobotAccessible = value;}
229 
230  // human robot reachability (the crown)
231  void setHumanRobotReachable(std::vector<EnvCell*> value) {initHumanRobotReachable = value;}
232  std::vector<EnvCell*> getHumanRobotReachable() {return initHumanRobotReachable;}
233  void addToHumanRobotReachable(EnvCell* cell) {initHumanRobotReachable.push_back(cell);}
234  void clearHumanRobotReachable() {initHumanRobotReachable.clear();}
235 
236  void setCurrentHumanRobotReachable(std::vector<EnvCell*> value) {currentHumanRobotReachable = value;}
237  std::vector<EnvCell*> getCurrentHumanRobotReachable() {return currentHumanRobotReachable;}
238  void addToCurrentHumanRobotReachable(EnvCell* cell) {currentHumanRobotReachable.push_back(cell);}
239  void clearCurrentHumanRobotReachable() {currentHumanRobotReachable.clear();}
240 
241  //special grid usage (slices)
242  std::pair<double,EnvCell*> getRobotBestPos(){return robotBestPos;}
243  void setRobotBestPos(std::pair<double,EnvCell*> value){robotBestPos = value;}
244 
245  void setAngleForHumanComming(double value) {angleForHumanComming = value;}
246  double getAngleForHumanComming(){return angleForHumanComming;}
247 
248  //other
249  void setBlankCost() { mCostIsComputed = false; }
250  void setCost(double value) {mCost = value; }
251  double getCost() {return mCost; }
252 
253  Eigen::Vector2i getCoord() { return _Coord; }
254 
255  std::vector<double> getRandomVector(){return randomVectorPoint;}
256 
257 
258 
259  //#######################
260  // others ###############
261  //#######################
262 
266  void computeHumanReach();
267 
271  void computeRobotReach();
272 
276  double computeCost();
277 
281  bool computeBestRobotPos();
282 
286  void resetReacheability();
287 
291  void resetTraj();
292 
296  std::vector<EnvCell*> getNeighbors(bool isHuman);
297 
301  double computeDist(EnvCell* neighCell);
302 
306  void addPoint(double Rz);
307 
311  std::vector<EnvCell*> getCrown(double min, double max);
312 
313  private:
317  Eigen::Vector2i _Coord;
318 
322  bool _Open;
323 
327  bool _Closed;
328 
332  bool mCostIsComputed;
333 
337  double mCost;
338 
342  bool m_isHumanAccessible;
343 
347  bool m_isRobotAccessible;
348 
352  bool m_reachComputed;
353 
357  bool m_humanDistIsComputed;
358 
362  double m_humanDist;
363 
367  std::vector<EnvCell*> humanTraj;
368 
372  std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > humanVectorTraj;
373 
377  bool m_robotDistIsComputed;
378 
382  double m_robotDist;
383 
387  std::vector<EnvCell*> robotTraj;
388 
392  std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > robotVectorTraj;
393 
397  std::vector<double> randomVectorPoint;
398 
402  std::vector<EnvCell*> initHumanRobotReachable;
403 
407  std::vector<EnvCell*> currentHumanRobotReachable;
408 
412  std::pair<double,EnvCell*> robotBestPos;
413 
417  double angleForHumanComming;
418 
419  };
420 }
421 
422 
423 
424 #endif // HRICS_TWODGRID_HPP
void initAllCellState()
call resetexplorationstatus() in each cell
Definition: HRICS_EnvGrid.cpp:758
void computeDistances(EnvCell *cell, bool isHuman)
using the method of distance propagation to compute distances
Definition: HRICS_EnvGrid.cpp:968
std::vector< EnvCell * > getCrown(double min, double max)
return the crown arround the cell taking the min and max value
Definition: HRICS_EnvGrid.cpp:1364
Plannar HRI Grid.
Definition: HRICS_EnvGrid.hpp:14
void computeHumanDistances(EnvCell *cell)
using the method of distance propagation to compute distances for human
Definition: HRICS_EnvGrid.cpp:786
void resetTraj()
reset the Trajectories computing
Definition: HRICS_EnvGrid.cpp:1348
std::vector< EnvCell * > getNeighbors(bool isHuman)
find the neighbors of this cell (used when computing distance propagation)
Definition: HRICS_EnvGrid.cpp:1297
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
void draw()
drawing the grid
Definition: HRICS_EnvGrid.cpp:499
Definition: TwoDCell.hpp:19
void initAllTrajs()
call resetTrajs() in each cell
Definition: HRICS_EnvGrid.cpp:766
bool computeBestRobotPos()
compute best robot pos
Definition: HRICS_EnvGrid.cpp:1273
void computeHumanRobotReacheability(std::pair< double, double > minMax)
Compute the crown arround the human for reacheability.
Definition: HRICS_EnvGrid.cpp:433
std::vector< std::pair< double, EnvCell * > > getSortedGrid()
sort the cells of the grid
Definition: HRICS_EnvGrid.cpp:441
void setCellsToblankCost()
call setBlankCost() in each cell
Definition: HRICS_EnvGrid.cpp:747
Definition: TwoDGrid.hpp:25
void computeHumanReach()
test if there is a collision with a BB (the cylinders) for the human
Definition: HRICS_EnvGrid.cpp:1180
void initAllReachability()
call resetexplorationstatus() in each cell
Definition: HRICS_EnvGrid.cpp:774
double computeDist(EnvCell *neighCell)
compute distance between two cells
Definition: HRICS_EnvGrid.cpp:1331
API::TwoDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y)
Virtual function that creates a new Cell.
Definition: HRICS_EnvGrid.cpp:484
void recomputeGridWhenHumanMove(Eigen::Vector3d humanPos)
recompute the grid cost if human move
Definition: HRICS_EnvGrid.cpp:376
void computeRobotReach()
test if there is a collision with a BB (the cylinders) for the robot
Definition: HRICS_EnvGrid.cpp:1212
void addPoint(double Rz)
add a point to the random vector in order to draw it (the red arrows)
Definition: HRICS_EnvGrid.cpp:1358
void resetReacheability()
reset the reacheability computing
Definition: HRICS_EnvGrid.cpp:1336
double computeCost()
compute partial cost
Definition: HRICS_EnvGrid.cpp:1243
void computeRobotDistances(EnvCell *cell)
using the method of distance propagation to compute distances for robot
Definition: HRICS_EnvGrid.cpp:883
void initGrid(Eigen::Vector3d humanPos)
initialising the part of the grid needed for fused grid use
Definition: HRICS_EnvGrid.cpp:201
void init(std::pair< double, double > minMax)
initialisation of the grid ( computing distances and taking obstacle into account) ...
Definition: HRICS_EnvGrid.cpp:72
Plannar HRI Cell.
Definition: HRICS_EnvGrid.hpp:175