libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
HRICS_AgentGrid.hpp
1 /*
2  * HRICS_AgentCell.hpp
3  * BioMove3D
4  *
5  * Created by Jim Mainprice on 27/04/10.
6  * Copyright 2010 LAAS/CNRS. All rights reserved.
7  *
8  */
9 
10 #ifndef HRICS_HUMAN_CENTERED_GRID_H_
11 #define HRICS_HUMAN_CENTERED_GRID_H_
12 
13 #include "API/Device/robot.hpp"
14 #include "API/ConfigSpace/configuration.hpp"
15 #include "API/Grids/ThreeDGrid.hpp"
16 
17 #include "Graphic-pkg.h"
18 
19 namespace HRICS
20 {
21  class AgentGrid;
22 
23  class AgentCell : public API::ThreeDCell
24  {
25  public:
26  AgentCell();
27  AgentCell(int i, Eigen::Vector3i pos , Eigen::Vector3d corner, AgentGrid* grid);
28  //AgentCell(const AgentCell& cell);
29 
30  ~AgentCell();
31 
32  double getCost();
33  void setCost(double Cost) { m_Cost = Cost; }
34  void setBlankCost();
35 
36  double getDistance();
37  double getVisibility();
38  double getReachability();
39  double getCombined();
40 
41  void computeDistance();
42  void computeVisibility();
43  void computeReachability();
44  void computeCombined();
45 
46  void resetReachable();
47  bool getIsLeftArmReachable();
48 
49  Eigen::Vector3d getWorkspacePoint();
50 
51  void setIsReachable(bool reach) { m_IsReachable = reach; }
52  void setIsReachableWithLA(bool reach) { m_IsReachWithLeftArm = reach; }
53  void setIsReachableWithRA(bool reach) { m_IsReachWithRightArm = reach; }
54 
55  bool isReachable() { return m_IsReachable; }
56  bool isReachableWithLA() { return m_IsReachWithLeftArm; }
57  bool isReachableWithRA() { return m_IsReachWithRightArm; }
58 
59  void resetExplorationStatus();
60  void createDisplaylist();
61 
62  void drawOnePoint( bool withTransform );
63  void draw(bool transform);
64  int setRobotToStoredConfig();
65 
66  bool writeToXml(xmlNodePtr cur);
67  bool readCellFromXml(xmlNodePtr cur);
68 
69  protected:
70 
71  Eigen::Vector3i getCoord() { return m_Coord; }
72 
73  bool getOpen() { return m_Open; }
74  void setOpen() { m_Open = true; }
75 
76  bool getClosed() { return m_Closed; }
77  void setClosed() { m_Closed = true; }
78 
79  private:
80 
81  double radius;
82 
83  Eigen::Vector3d m_Center;
84  Eigen::Vector3i m_Coord;
85 
86  double* m_v0; double* m_v1; double* m_v2; double* m_v3;
87  double* m_v4; double* m_v5; double* m_v6; double* m_v7;
88 
89  bool m_Open;
90  bool m_Closed;
91 
92  bool m_IsCostComputed;
93  double m_Cost;
94 
95  bool m_IsReachable;
96  bool m_IsReachWithLeftArm;
97  bool m_IsReachWithRightArm;
98 
99  double m_Distance;
100  double m_Visiblity;
101  double m_Reachability;
102  double m_Combined;
103 
104  unsigned int m_NbDirections;
105 
106  std::tr1::shared_ptr<Configuration> m_QStored;
107 
108  GLint m_list;
109  };
110 
111 
112  class Distance;
113  class Visibility;
114  class Natural;
115 
116  class AgentGrid : public API::ThreeDGrid
117  {
118  public:
119  AgentGrid();
120  AgentGrid( Robot* robot, Distance* distCostSpace,Visibility* VisiCostSpace, Natural* NatuCostSpace );
121  AgentGrid( std::vector<int> size );
122  AgentGrid( double pace, std::vector<double> envSize,
123  Robot* robot, Distance* distCostSpace,Visibility* VisiCostSpace, Natural* NatuCostSpace);
124  AgentGrid( const AgentGrid& grid );
125 
126  ~AgentGrid();
127 
128  API::ThreeDCell* createNewCell(unsigned int index,unsigned int x,unsigned int y,unsigned int z );
129 
130  Robot* getRobot();
131 
132  Distance* getDistance();
133  Visibility* getVisibility();
134  Natural* getNatural();
135 
136  Eigen::Affine3d getTransformFromRobotPos();
137  Eigen::Vector3d getTranformedToRobotFrame(const Eigen::Vector3d& WSPoint);
138 
139  bool isReachable(const Eigen::Vector3d& WSPoint);
140 
141  double getCellCostAt(const Eigen::Vector3d& WSPoint);
142  double getCompleteCellCostAt(const Eigen::Vector3d& WSPoint, std::vector<double>& costs);
143 
144  std::vector<Eigen::Vector3d> getBox();
145  void resetCellCost();
146  void resetReachability();
147  void initReachable();
148 
149  int robotConfigInCell(int i);
150 
151  void computeReachability();
152  void computeAllCellCost();
153  void computeCellVectors();
154  void computeRadius();
155  void computeCostCombination();
156 
157  void draw();
158 
159  private:
160 
161  Robot* m_Robot;
162 
163  double m_Radius;
164 
165  Distance* m_DistanceCostSpace;
166  Visibility* m_VisibilityCostSpace;
167  Natural* m_NaturalCostSpace;
168 
169  std::vector<AgentCell*> m_DangerCells;
170  std::vector<AgentCell*> m_VisibilityCells;
171  std::vector<AgentCell*> m_ReachableCells;
172  std::vector<AgentCell*> m_CombinedCells;
173 
174  bool m_firstDisplay;
175  std::tr1::shared_ptr<Configuration> m_ActualConfig;
176  std::tr1::shared_ptr<Configuration> m_LastConfig;
177  Eigen::Affine3d m_RobotOriginPos;
178 
179  };
180 }
181 
182 #endif
Eigen::Vector3d getTranformedToRobotFrame(const Eigen::Vector3d &WSPoint)
Get the global frame points in the robot frame.
Definition: HRICS_AgentGrid.cpp:751
void computeVisibility()
Compute the visibility of the cell.
Definition: HRICS_AgentGrid.cpp:235
API::ThreeDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z)
Virtual function that creates a new cell.
Definition: HRICS_AgentGrid.cpp:701
void computeReachability()
Compute the cell reachbility.
Definition: HRICS_AgentGrid.cpp:246
int robotConfigInCell(int i)
get config
Definition: HRICS_AgentGrid.cpp:860
void computeCellVectors()
Compute Grid Cost.
Definition: HRICS_AgentGrid.cpp:883
Definition: HRICS_AgentGrid.hpp:23
Natural Motion and Arm Confort.
Definition: HRICS_Natural.hpp:33
std::vector< Eigen::Vector3d > getBox()
Returns the bounding box of the human grid The initial box is tranformed to the current agent positio...
Definition: HRICS_AgentGrid.cpp:760
void draw()
Draw a openGl view of the grid.
Definition: HRICS_AgentGrid.cpp:944
Definition: ThreeDGrid.hpp:24
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
double getCellCostAt(const Eigen::Vector3d &WSPoint)
Get the cell containing WSPoint and returns the cost.
Definition: HRICS_AgentGrid.cpp:819
void computeDistance()
Compute the from the cell to the human.
Definition: HRICS_AgentGrid.cpp:224
void computeAllCellCost()
Compute Grid Cost.
Definition: HRICS_AgentGrid.cpp:908
Definition: HRICS_AgentGrid.hpp:116
Definition: ThreeDCell.hpp:25
Definition: HRICS_Visibility.hpp:18
Definition: HRICS_Distance.hpp:20
Eigen::Affine3d getTransformFromRobotPos()
Get the transform matrix between the origin and the robot current position All grid points are stored...
Definition: HRICS_AgentGrid.cpp:741
void resetCellCost()
Reset Grid Cost.
Definition: HRICS_AgentGrid.cpp:837
Eigen::Vector3d getWorkspacePoint()
Get the Workspace Point transformed by the freeflyer of the human.
Definition: HRICS_AgentGrid.cpp:165
double getCost()
compute cost depending on right/left hand
Definition: HRICS_AgentGrid.cpp:141
double getCompleteCellCostAt(const Eigen::Vector3d &WSPoint, std::vector< double > &costs)
Get the cell containing WSPoint and returns the cost.
Definition: HRICS_AgentGrid.cpp:792