libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
HRICS_Natural.hpp
1 /*
2  * HRICS_Natural.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_NATURAL_HPP
11 #define HRICS_NATURAL_HPP
12 
13 #include "API/planningAPI.hpp"
14 
15 #include "HRI_costspace/Grid/HRICS_NaturalGrid.hpp"
16 #include "HRI_costspace/Grid/HRICS_NaturalCell.hpp"
17 
18 //#include "HRI_costspace/Grid/HRICS_TwoDGrid.hpp"
19 
20 
21 #ifdef HRI_PLANNER
22 #include <libmove3d/hri/hri.h>
23 #endif
24 
28 namespace HRICS
29 {
33  class Natural
34  {
35  public:
36  Natural();
37  Natural(Robot* R);
38  ~Natural();
39 
44  void initGeneral();
45  void initNaturalJustin();
46  void initNaturalAchile();
47  void initNaturalHerakles();
48  void initNaturalOldDude();
49  void initHumanBaseGrid(std::vector<double> box);
50 
51  void printBodyPos();
52  void setRobotToConfortPosture();
53 
57  double getConfigCost();
58  double getCost(const Eigen::Vector3d& WSPoint, bool useLeftvsRightArm, bool withEffect = false);
59 
63  double getWorkspaceCost(const Eigen::Vector3d& WSPoint);
64  bool getWorkspaceIsReachable(const Eigen::Vector3d& WSPoint);
65 
70  double getJointDisplacement();
71  double getEnergy();
72  double getDiscomfort();
73 
77  double basicNaturalArmCost(bool useLeftvsRightArm);
78  void setRobotColorFromConfiguration(bool toSet);
79 
80  /*
81  double akinRightArmReachCost();
82  double akinLeftArmReachCost();
83  */
84  std::vector<double> getUpperBodyHeigth(bool useReference = true);
86  double getJointLimits(Configuration& q);
87 
91  double getNumberOfIKCost(const Eigen::Vector3d& WSPoint);
92 
97  bool computeIsReachableAndMove( const Eigen::Vector3d& WSPoint, bool leftArm);
98 
99 
104  bool computeIsReachableOnly(const Eigen::Vector3d& WSPoint, bool leftArm);
105 
106 
107 
111  Eigen::Affine3d getGridOriginMatrix();
112 
118  void computeAllCellCost();
119  void computeAllReachableCellCost();
120  std::vector< Eigen::Vector3d > getSortedReachableWSPoint();
121  std::vector< std::pair<double,Eigen::Vector3d> > getReachableWSPoint();
122 
126  int getObjectDof() { return m_IndexObjectDof; }
127  bool IsHuman() { return m_IsHuman; }
128  Robot* getRobot() { return m_Robot; }
129  NaturalGrid* getGrid() { return m_Grid; }
130 
134  void setGrid(NaturalGrid* grid) { m_Grid = grid; }
135 
136  private:
137  bool m_debug;
138 
139  int m_IndexObjectDof;
140 
141  bool m_computeNbOfIK;
142 
143  bool m_leftArmCost;
144 
145  bool m_BestPointsSorted;
146 
147  Robot* m_Robot;
148 
149  NaturalGrid* m_Grid;
150 
151  enum Kinematic
152  {
153  Default,
154  Justin,
155  Achile,
156  Herakles,
157  OldDude
158  };
159 
160  bool m_IsHuman;
161 
162 #ifdef HRI_PLANNER
163  HRI_AGENTS* m_Agents;
164 #endif
165 
166  Kinematic m_KinType;
167 
168  /***********************************************/
169  int m_JOINT_SPINE;
170  int m_JOINT_HEAD;
171 
172  int m_JOINT_ARM_RIGTH_SHOULDER;
173  int m_JOINT_ARM_RIGTH_ELBOW;
174  int m_JOINT_ARM_RIGTH_WRIST;
175 
176  int m_JOINT_ARM_LEFT_SHOULDER;
177  int m_JOINT_ARM_LEFT_ELBOW;
178  int m_JOINT_ARM_LEFT_WRIST;
179 
180  /***********************************************/
181  int m_CONFIG_INDEX_SPINE;
182  int m_CONFIG_INDEX_HEAD;
183 
184  int m_CONFIG_INDEX_ARM_RIGTH_SHOULDER;
185  int m_CONFIG_INDEX_ARM_RIGTH_ELBOW;
186  int m_CONFIG_INDEX_ARM_RIGTH_WRIST;
187 
188  int m_CONFIG_INDEX_ARM_LEFT_SHOULDER;
189  int m_CONFIG_INDEX_ARM_LEFT_ELBOW;
190  int m_CONFIG_INDEX_ARM_LEFT_WRIST;
191 
192 
196  std::tr1::shared_ptr<Configuration> m_q_Confort;
197 
201  std::tr1::shared_ptr<Configuration> m_q_ConfortWeigths;
202 
206  double m_G;
207 
212  std::vector<double> m_mg;
213 
217  std::vector<double> m_armHeightL;
218  std::vector<double> m_armHeightR;
219 
220  std::tr1::shared_ptr<Configuration> m_q_Init;
221  std::tr1::shared_ptr<Configuration> m_q_Goal;
222 
226  std::vector< NaturalCell* > m_SortedCells;
227  };
228 }
229 
230 #endif
double getWorkspaceCost(const Eigen::Vector3d &WSPoint)
Get the cost of a point in the grid.
Definition: HRICS_Natural.cpp:1231
bool getWorkspaceIsReachable(const Eigen::Vector3d &WSPoint)
Is point reachable in workspace.
Definition: HRICS_Natural.cpp:1244
bool computeIsReachableOnly(const Eigen::Vector3d &WSPoint, bool leftArm)
Compute if the Workspace Point is Reachable Move the robot.
Definition: HRICS_Natural.cpp:1388
double getConfigCost()
Get the cost of the current configuration.
Definition: HRICS_Natural.cpp:858
Eigen::Affine3d getGridOriginMatrix()
Computation on the Grid.
Definition: HRICS_Natural.cpp:1437
double basicNaturalArmCost(bool useLeftvsRightArm)
Others.
Definition: HRICS_Natural.cpp:1071
std::vector< Eigen::Vector3d > getSortedReachableWSPoint()
Get the sorted cells.
Definition: HRICS_Natural.cpp:1511
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
double getDiscomfort()
Discomfort : This function evaluates the joint displacement from the VRS project at Iwoa...
Definition: HRICS_Natural.cpp:930
void initGeneral()
Initilize the parameters for the Natural Cost space.
Definition: HRICS_Natural.cpp:60
bool computeIsReachableAndMove(const Eigen::Vector3d &WSPoint, bool leftArm)
Compute if the Workspace Point is Reachable Move the robot.
Definition: HRICS_Natural.cpp:1290
void setGrid(NaturalGrid *grid)
Basic setters.
Definition: HRICS_Natural.hpp:134
double getNumberOfIKCost(const Eigen::Vector3d &WSPoint)
Simple number of IK Cost.
Definition: HRICS_Natural.cpp:1252
int getObjectDof()
Basic accesors.
Definition: HRICS_Natural.hpp:126
double getCustomDistConfig(Configuration &q)
Compute the classic square distance between two configurations with weight.
Definition: HRICS_Natural.cpp:999
std::vector< double > getUpperBodyHeigth(bool useReference=true)
Discomfort : This function evaluates the different in heigth of each body regarding the confort posit...
Definition: HRICS_Natural.cpp:939
Classe représentant une Configuration d'un Robot.
Definition: configuration.hpp:25
double getEnergy()
Energy : This function evaluates the joint displacement from the VRS project at Iwoa.
Definition: HRICS_Natural.cpp:908
Definition: HRICS_NaturalGrid.hpp:22
double getJointDisplacement()
Get the 3 component of natural cost space.
Definition: HRICS_Natural.cpp:899
void initHumanBaseGrid(std::vector< double > box)
Definition: HRICS_Natural.cpp:785
NaturalGrid * computeNaturalGrid()
compute a NaturalGrid (calling class NaturalGrid) by using Env variable.
Definition: HRICS_Natural.cpp:1470
double getCost(const Eigen::Vector3d &WSPoint, bool useLeftvsRightArm, bool withEffect=false)
Computes the cost for a Workspace point.
Definition: HRICS_Natural.cpp:1185