libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
HRICS_Workspace.hpp
1 #ifndef HRICS_PLANNER_H
2 #define HRICS_PLANNER_H
3 
4 /*
5  * HRICS_CostSpace.h
6  * BioMove3D
7  *
8  * Created by Jim Mainprice on 04/12/09.
9  * Copyright 2009 mainprice@laas.fr All rights reserved.
10  *
11  */
12 
13 #include "API/planningAPI.hpp"
14 #include "planner/planner.hpp"
15 #include "planner/Diffusion/RRT.hpp"
16 
17 #include "HRICS_Distance.hpp"
18 #include "HRICS_Visibility.hpp"
19 #include "HRICS_Natural.hpp"
20 #include "Grid/HRICS_Grid.hpp"
21 #include "Grid/HRICS_GridState.hpp"
22 #include "Grid/HRICS_AgentGrid.hpp"
23 
31 namespace HRICS
32 {
33 
38  {
39 
40  public:
42  Planner(),
43  m_DistanceSpace(NULL),
44  m_VisibilitySpace(NULL),
45  m_ReachableSpace(NULL),
46  m_NaturalSpace(NULL) { }
47 
48  HumanAwareMotionPlanner(Robot* rob, Graph* graph) :
49  Planner(rob,graph),
50  m_DistanceSpace(NULL),
51  m_VisibilitySpace(NULL),
52  m_ReachableSpace(NULL),
53  m_NaturalSpace(NULL) { }
54 
56  {
57  delete m_DistanceSpace;
58  delete m_VisibilitySpace;
59  }
60 
61  Distance* getDistance() { return m_DistanceSpace; }
62  Visibility* getVisibility() { return m_VisibilitySpace; }
63  Natural* getNaturality() { return m_NaturalSpace; }
64  Natural* getReachability() { return m_ReachableSpace; }
65 
66 
67  void setDistance(Distance* dist)
68  {
69  if( m_DistanceSpace )
70  {
71  delete m_DistanceSpace;
72  }
73  m_DistanceSpace = dist;
74  }
75 
76  void setVisibility(Visibility* visib)
77  {
78  if( m_VisibilitySpace )
79  {
80  delete m_VisibilitySpace;
81  }
82  m_VisibilitySpace = visib;
83  }
84 
85  void setNatural(Natural* nat)
86  {
87  if( m_NaturalSpace )
88  {
89  delete m_NaturalSpace;
90  }
91  m_NaturalSpace = nat;
92  }
93 
94  void setReachability(Natural* nat)
95  {
96  if( m_ReachableSpace )
97  {
98  delete m_ReachableSpace;
99  }
100  m_ReachableSpace = nat;
101  }
102 
103  unsigned int run() { return 0; }
104 
105  protected:
111  Visibility* m_VisibilitySpace;
112  Natural* m_ReachableSpace;
113  Natural* m_NaturalSpace;
114 
115  };
116 
121  {
122 
123  public :
124 
128  Workspace();
129  Workspace(Robot* rob, Graph* graph);
130  ~Workspace();
131 
135  void initGrid();
136  void deleteGrid();
137 
138  void initAgentGrids(double cellsize);
139  void deleteAgentGrids();
140  std::vector<AgentGrid*> getAgentGrids() { return m_HumanGrids; }
141 
142  void initDistance();
143  void initVisibility();
144  void initReachable();
145  void initNatural();
146  void initOtpPlanner();
147 #ifdef HRI_PLANNER
148  void setAgents( HRI_AGENTS* agents ) { m_Agents = agents; }
149 #endif
150 
154  Robot* getHuman(){ return mHumans[0]; }
155  std::vector<Robot*> getHumans(){ return mHumans; }
156  Robot* getRobot(){ return _Robot; }
157  Eigen::Vector3d getVisball();
158 
162  bool computeAStarIn3DGrid();
163  double pathCost();
164  void draw3dPath();
165 
169  double distanceToEntirePath();
170  double distanceToCellPath();
171 
175  Grid* getGrid() { return m3DGrid; }
176  std::vector<Eigen::Vector3d> get3DPath() { return m3DPath; }
177  std::vector<API::ThreeDCell*> getCellPath() { return m3DCellPath; }
178  int getIndexObjectDof()
179  {
180  if(mIndexObjectDof==0)
181  {
182  std::cout << "Workspace::Warning::mIndexObjectDof == 0" << std::endl;
183  }
184  return mIndexObjectDof;
185  }
186 
190  bool initHriRRT();
191 
197  void activateOnlyBaseCollision();
198 
202  bool sampleRobotBase(std::tr1::shared_ptr<Configuration> q_base, const Eigen::Vector3d& WSPoint);
203 
207  bool transPFromBaseConf(std::tr1::shared_ptr<Configuration> q_base, std::vector< Eigen::Vector3d > points );
208  bool baseInSight(std::tr1::shared_ptr<Configuration> q_base);
209 
213  void setCurrentOTP(const Eigen::Vector3d& p) { m_OTP = p; }
214 
218  Eigen::Vector3d getCurrentOTP() { return m_OTP; }
219 
223  bool testCol(std::tr1::shared_ptr<Configuration> q_base);
224 
228  void initPR2RepoConf();
229 
233  void initPR2GiveConf();
234 
238  void initPR2AndHumanTest();
239 
243  void computePR2GIK(bool move);
244 
248  void ChangeRobotPos(double value);
249 
253  void drawCurrentOTP();
254 
258  double* testTransferPointToTrajectory( const Eigen::Vector3d& WSPoint, API::Trajectory& traj, unsigned int& id);
259 
260 
264  bool chooseBestTransferPoint(Eigen::Vector3d& transfPoint, bool move, unsigned int threshold);
265 
270  bool computeBestTransferPoint(Eigen::Vector3d& transfPoint);
271 
276  bool computeBestFeasableTransferPoint(Eigen::Vector3d& transfPoint);
277 
283  bool ComputeTheObjectTransfertPoint(bool Move, int type, Eigen::Vector3d& transfPoint, int threshold);
284 
292  Eigen::Vector3d computeOTPFromHandPose( bool rightHand );
293 
294  private:
295 
296  void solveAStar(State* start,State* goal);
297 
299  std::vector<Robot*> mHumans;
300 
303  int mIndexObjectDof;
304 
306  Eigen::Vector3d m_OTP;
307 
309  Grid* m3DGrid;
310  std::vector<AgentGrid*> m_HumanGrids;
311 
312 #ifdef HRI_PLANNER
313  HRI_AGENTS* m_Agents;
314 #endif
315 
317  bool mPathExist;
318  std::vector<Eigen::Vector3d> m3DPath;
319  std::vector<API::ThreeDCell*> m3DCellPath;
320  };
321 }
322 
323 #endif
void initPR2GiveConf()
set PR2 to Give configuration
Definition: HRICS_Workspace.cpp:1605
Robot * _Robot
Le Robot pour lequel la recherche va se faire.
Definition: planner.hpp:174
bool chooseBestTransferPoint(Eigen::Vector3d &transfPoint, bool move, unsigned int threshold)
Choses a good transfer point.
Definition: HRICS_Workspace.cpp:1085
void deactivateOnlyBaseCollision()
Choose best transfer point from the natural costspace associated to the human.
Definition: HRICS_Workspace.cpp:609
bool initHriRRT()
Run RRT.
Definition: HRICS_Workspace.cpp:562
Planner()
Plain Constructor of the class.
Definition: planner.cpp:27
bool sampleRobotBase(std::tr1::shared_ptr< Configuration > q_base, const Eigen::Vector3d &WSPoint)
Test if Jido (Base?) is in collision in this configuration.
Definition: HRICS_Workspace.cpp:711
void initPR2AndHumanTest()
set PR2 and Human to testing position
Definition: HRICS_Workspace.cpp:1654
Definition: HRICS_Grid.hpp:16
void initPR2RepoConf()
set Repo Pose of PR2
Definition: HRICS_Workspace.cpp:1543
bool transPFromBaseConf(std::tr1::shared_ptr< Configuration > q_base, std::vector< Eigen::Vector3d > points)
Test if Jido is in collision in this configuration (?)
Definition: HRICS_Workspace.cpp:620
double distanceToEntirePath()
Distance to 3D path.
Definition: HRICS_Workspace.cpp:481
void drawCurrentOTP()
Draws the current OTP.
Definition: HRICS_Workspace.cpp:842
Distance * m_DistanceSpace
Distance and Visibility cost spaces.
Definition: HRICS_Workspace.hpp:110
void setCurrentOTP(const Eigen::Vector3d &p)
Set the OTP from given point.
Definition: HRICS_Workspace.hpp:213
Workspace()
Constructors & Destructors.
Definition: HRICS_Workspace.cpp:54
Definition: HRICS_GridState.hpp:14
Definition: graph.hpp:28
bool computeBestFeasableTransferPoint(Eigen::Vector3d &transfPoint)
Compute a transfert point from a loaded grid, taking into acount a possible colision.
Definition: HRICS_Workspace.cpp:1392
Natural Motion and Arm Confort.
Definition: HRICS_Natural.hpp:33
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
bool testCol(std::tr1::shared_ptr< Configuration > q_base)
testColision for the given configuration
Definition: HRICS_Workspace.cpp:662
double * testTransferPointToTrajectory(const Eigen::Vector3d &WSPoint, API::Trajectory &traj, unsigned int &id)
Test straight lines between target point and the point of the trajectory.
Definition: HRICS_Workspace.cpp:872
unsigned int run()
Run function.
Definition: HRICS_Workspace.hpp:103
double distanceToCellPath()
Computes a distance to the Cells in the 3D Path Coarse grain compared to the above distance...
Definition: HRICS_Workspace.cpp:534
void ChangeRobotPos(double value)
change Robot position to test PR2
Definition: HRICS_Workspace.cpp:1803
Definition: trajectory.hpp:40
Definition: HRICS_Visibility.hpp:18
Workspace Motion Planners.
Definition: HRICS_Workspace.hpp:120
Definition: HRICS_Distance.hpp:20
Base class for planning algorithms.
Definition: planner.hpp:28
void computePR2GIK(bool move)
Compute the position of the Robot Arm considering the current configuration.
Definition: HRICS_Workspace.cpp:1709
Grid * getGrid()
Getters.
Definition: HRICS_Workspace.hpp:175
bool computeBestTransferPoint(Eigen::Vector3d &transfPoint)
Compute a transfert point from a loaded grid, without taking into acount a possible colision...
Definition: HRICS_Workspace.cpp:1334
void draw3dPath()
Draws the 3D path as a yellow line.
Definition: HRICS_Workspace.cpp:462
bool computeAStarIn3DGrid()
Computes A* in Grid.
Definition: HRICS_Workspace.cpp:281
Eigen::Vector3d computeOTPFromHandPose(bool rightHand)
compute an object transfert point.
Definition: HRICS_Workspace.cpp:1521
Eigen::Vector3d getCurrentOTP()
Return the OTP.
Definition: HRICS_Workspace.hpp:218
Robot * getHuman()
Get Robot and Human.
Definition: HRICS_Workspace.hpp:154
Base class for the HRICS motion planners.
Definition: HRICS_Workspace.hpp:37
void initGrid()
Init Associated Objects.
Definition: HRICS_Workspace.cpp:156
bool ComputeTheObjectTransfertPoint(bool Move, int type, Eigen::Vector3d &transfPoint, int threshold)
compute an object transfert point.
Definition: HRICS_Workspace.cpp:1456