libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
mightabilitiesGrids.hpp
1 #ifndef MIGHTABILITIESGRIDS_HPP
2 #define MIGHTABILITIESGRIDS_HPP
3 
4 #include "grid.hpp"
5 #include "API/Grids/ThreeDGrid.hpp"
6 #include "API/Grids/TwoDGrid.hpp"
7 #include "worldState.hpp"
8 #include "P3d-pkg.h"
9 
10 #include "API/planningAPI.hpp"
11 
12 #include "move3d-headless.h"
13 #include "Planner-pkg.h"
14 #include "Collision-pkg.h"
15 
16 class MightabilitiesCell;
17 class WorldState;
18 
19 enum typeCells {
20  agentC,
21  reachDist,
22  reachCol,
23  reachDistSupp,
24  reachColSupp,
25  visDist,
26  visCol,
27  visDistSupp,
28  visColSupp,
29  typeCellSize
30 };
31 
32 
34 {
35 public:
37  Robot* agent;
38  std::map<typeCells, std::vector<MightabilitiesCell*> > cells;
39 };
40 
41 
43 public:
44  typeCellLists(){}
45  std::vector<MightabilitiesCell*> getListFromType(typeCells tc);
46  void addCellTo(MightabilitiesCell* c, typeCells tc);
47 
48 
49  std::vector<std::pair<typeCells, std::vector<MightabilitiesCell*> > > lists;
50 };
51 
53 {
54 public:
56  MightabilitiesGrid( Eigen::Vector3i size, std::vector<double> envSize);
57  MightabilitiesGrid( double samplingRate, std::vector<double> envSize);
58  MightabilitiesGrid( const ThreeDGrid& grid);
59 
60  void initVariables();
61 
62  void init(Eigen::Vector3i size, std::vector<double> envSize);
63  void init(double samplingRate , std::vector<double> envSize);
64 
65  void setVisBall();
66  void placeVisball(MightabilitiesCell* c);
67  void placeVisball(p3d_point p);
68 
69  void computeMights(std::vector<Robot*> agents, std::vector<Robot *> supports, std::vector<typeCells> abilities);
70 
71  std::vector<MightabilitiesCell*> getCellsFromEntity(Robot* entity);
72 
73  std::vector<MightabilitiesCell*> mergeVectors(std::vector<MightabilitiesCell*> c1,std::vector<MightabilitiesCell*> c2);
74 
75  void computeReachDist(Robot* ag, MightabilitiesCell* cells);
76  void computeReachCol(Robot* ag, MightabilitiesCell* cells);
77  void computeVisDist(Robot* ag, MightabilitiesCell* cells);
78  void computeVisCol(Robot* ag, MightabilitiesCell* cells);
79  bool computeVisballCollision();
80 
81  bool testLineArea(MightabilitiesCell* cells, p3d_point p);
82 
83 
84 
85 // void init(double samplingRate, vector<Robot*> ag);
86 
87  API::ThreeDCell* createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z );
88 
89  void draw();
90 
91  MightabilitiesCell* getCell(int i);
92 
93  WorldState* getWorldState() {return _WS;}
94  void setWorldState(WorldState* ws) {_WS = ws;}
95  void show();
96  void show(std::vector< std::pair<Robot*,typeCells> > toShow);
97 
98  void setSampleRate(double SR) { _samplingRate = SR; }
99 
100  std::vector<MightabilitiesCell*> getList(Robot* ag);
101  std::vector<MightabilitiesCell*> getList(Robot* ag, typeCells tc);
102  std::vector<MightabilitiesCell*> getList(std::vector< std::pair<Robot*,typeCells> > rpc);
103 
104  void addCellToList(MightabilitiesCell* c, Robot* ag, typeCells tc);
105 
106 
107 private:
108  WorldState* _WS;
109 
110  double _samplingRate;
111  Robot* _visball;
112  std::vector<agentLinkedCells> _ALC;
113 
114  std::map<Robot*, typeCellLists* > listMapAgentsType;
115 
116  std::vector< std::pair<Robot*,typeCells> > _toShow;
117  std::vector<MightabilitiesCell*> _allWorldCells;
118 
119 };
120 
121 
123 {
124 public:
127  MightabilitiesCell(int i, Eigen::Vector3d corner, MightabilitiesGrid* grid);
129 
130  void draw();
131 
132  void addAgent(Robot* ag);
133  void removeAgent(Robot* ag);
134  bool belongToAgent(Robot* ag);
135  bool belongToAtLeastOneAgent();
136 
137  void addTypeC(Robot* ag, typeCells tc);
138  void removeTypeC(Robot *ag, typeCells tc);
139  bool belongToTypeC(Robot* ag, typeCells tc);
140 
141  void setObject(Robot* r){_object = r;}
142  Robot* getObject(){return _object;}
143 
144  void setIsSupport(bool v) {isSupport = v;}
145  bool isItSupport() {return isSupport;}
146 
147 private:
148  std::vector< std::pair<Robot*, typeCells> > agentTypeBelongings;
149 
150  Robot* _object;
151  bool isSupport;
152 
153 };
154 
155 
156 #endif // MIGHTABILITIESGRIDS_HPP
void draw()
Draw a openGl view of the grid.
Definition: mightabilitiesGrids.cpp:814
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ThreeDGrid()
Constructor.
Definition: ThreeDGrid.cpp:21
Definition: ThreeDGrid.hpp:24
Definition: mightabilitiesGrids.hpp:122
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
Definition: mightabilitiesGrids.hpp:52
Definition: ThreeDCell.hpp:25
Definition: worldState.hpp:30
Definition: mightabilitiesGrids.hpp:42
Definition: mightabilitiesGrids.hpp:33
API::ThreeDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z)
Virtual function that creates a new Cell.
Definition: mightabilitiesGrids.cpp:799