libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
HRICS_NaturalGrid.hpp
1 /*
2  * HRICS_NaturalCell.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_NATURALGRID_H_
11 #define HRICS_NATURALGRID_H_
12 
13 #include "API/Device/robot.hpp"
14 #include "API/ConfigSpace/configuration.hpp"
15 #include "API/Grids/ThreeDGrid.hpp"
16 
17 namespace HRICS
18 {
19  class Natural;
20  class NaturalCell;
21 
23  {
24  public:
25  NaturalGrid();
26  NaturalGrid( std::vector<int> size );
27  NaturalGrid(double pace, std::vector<double> envSize,Natural* costSpace);
28  NaturalGrid(const NaturalGrid& grid);
29 
30  void setGridOrigin();
31 
32  API::ThreeDCell* createNewCell(unsigned int index,unsigned int x,unsigned int y,unsigned int z );
33  void computeAllCellCost();
34 #ifdef HRI_PLANNER
35  /*
36  * compute all reachable point in the grid : either with right or left hand
37  */
38  void computeReachability();
39 #endif
40  int robotConfigInCell(int i);
41 
42  Eigen::Affine3d getTransformFromRobotPos();
43  Eigen::Vector3d getTranformedToRobotFrame(const Eigen::Vector3d& WSPoint);
44  bool isInReachableGrid(const Eigen::Vector3d& WSPoint);
45 
46  bool isReachable(const Eigen::Vector3d& WSPoint);
47  bool isReachableWithRA(const Eigen::Vector3d& WSPoint);
48  bool isReachableWithLA(const Eigen::Vector3d& WSPoint);
49 
50  double getCellCostAt(const Eigen::Vector3d& WSPoint);
51 
52  void drawVector( const std::vector< std::pair<double,NaturalCell*> >& cells );
53  void draw();
54  std::vector<Eigen::Vector3d> getBox();
55  void resetCellCost();
56  void resetReachability();
57  void initReachable();
58 
59  NaturalGrid* mergeWith(NaturalGrid* otherGrid);
60  std::vector<NaturalCell*> getAllReachableCells();
61  std::vector<NaturalCell*> getAllReachableCellsOneArm(bool right_arm);
62  std::vector<std::pair<double,NaturalCell*> > getAllReachableCellsSorted();
63  std::vector<NaturalCell*> getAllReachableCells(double CostThreshold);
64 
65  void setNaturalCostSpace(Natural* NCS) { m_NaturalCostSpace = NCS; setGridOrigin(); }
66  Natural* getNaturalCostSpace() { return m_NaturalCostSpace; }
67  Eigen::Affine3d getRobotOrigin() { return m_RobotOriginPos; }
68  //std::tr1::shared_ptr<Configuration> getActualConfig() { return m_ActualConfig; }
69 
70  Robot* getRobot();
71 
72  bool writeToXmlFile(std::string docname);
73  bool loadFromXmlFile(std::string docname);
74 
75 
76  private:
77  Natural* m_NaturalCostSpace;
78  bool m_firstDisplay;
79  std::tr1::shared_ptr<Configuration> m_ActualConfig;
80  Eigen::Affine3d m_RobotOriginPos;
81  };
82 }
83 
84 #endif
std::vector< std::pair< double, NaturalCell * > > getAllReachableCellsSorted()
Reachable Cells sorted
Definition: HRICS_NaturalGrid.cpp:320
Eigen::Vector3d getTranformedToRobotFrame(const Eigen::Vector3d &WSPoint)
Transform the point to the robot frame.
Definition: HRICS_NaturalGrid.cpp:413
NaturalGrid * mergeWith(NaturalGrid *otherGrid)
Fusion Grid
Definition: HRICS_NaturalGrid.cpp:222
void resetCellCost()
Reset Grid Cost.
Definition: HRICS_NaturalGrid.cpp:104
Natural Motion and Arm Confort.
Definition: HRICS_Natural.hpp:33
Eigen::Affine3d getTransformFromRobotPos()
Get the Transform Matrix between the robot and the grid point
Definition: HRICS_NaturalGrid.cpp:382
Definition: ThreeDGrid.hpp:24
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
bool loadFromXmlFile(std::string docname)
Reads the grid from an xml file.
Definition: HRICS_NaturalGrid.cpp:669
std::vector< NaturalCell * > getAllReachableCells()
Reachable Cells return all reachable cells by the human
Definition: HRICS_NaturalGrid.cpp:258
std::vector< NaturalCell * > getAllReachableCellsOneArm(bool right_arm)
Reachable Cells return all reachable by one arm
Definition: HRICS_NaturalGrid.cpp:279
Definition: ThreeDCell.hpp:25
std::vector< Eigen::Vector3d > getBox()
Definition: HRICS_NaturalGrid.cpp:505
void computeAllCellCost()
Compute Grid Cost.
Definition: HRICS_NaturalGrid.cpp:130
API::ThreeDCell * createNewCell(unsigned int index, unsigned int x, unsigned int y, unsigned int z)
Virtual function that creates a new Cell.
Definition: HRICS_NaturalGrid.cpp:84
int robotConfigInCell(int i)
get Config
Definition: HRICS_NaturalGrid.cpp:373
void draw()
Draw a openGl view of the grid.
Definition: HRICS_NaturalGrid.cpp:550
double getCellCostAt(const Eigen::Vector3d &WSPoint)
Get the cell containing WSPoint and returns the cost.
Definition: HRICS_NaturalGrid.cpp:494
Definition: HRICS_NaturalGrid.hpp:22
bool isReachable(const Eigen::Vector3d &WSPoint)
Returns wether a point is reachable in the natural grid.
Definition: HRICS_NaturalGrid.cpp:448
void initReachable()
Compute Grid Accecibility whith right and left hand !
Definition: HRICS_NaturalGrid.cpp:198
bool writeToXmlFile(std::string docname)
Writes the grid to en xml file.
Definition: HRICS_NaturalGrid.cpp:576
void resetReachability()
Reset Grid Reachability.
Definition: HRICS_NaturalGrid.cpp:117