libmove3d-planners
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Groups Pages
robot.hpp
1 #ifndef ROBOT_HPP
2 #define ROBOT_HPP
3 
4 #include <Eigen/Core>
5 #define EIGEN_USE_NEW_STDVECTOR
6 #include <Eigen/StdVector>
7 #include <Eigen/Geometry>
8 
9 #include "API/Device/joint.hpp"
10 #include "API/Device/objectrob.hpp"
11 #include "API/ConfigSpace/configuration.hpp"
12 //#ifdef HRI_PLANNER
13 #include <libmove3d/hri/hri.h>
14 //#endif
15 
16 
17 class Scene;
18 class ObjectRob;
19 
20 namespace API { class Trajectory; }
21 
22 #ifndef _DEVICE_H
23 struct rob;
24 struct jnt;
25 #endif
26 
27 #ifndef _TRAJ_H
28 struct traj;
29 #endif
30 
42 class Robot {
43 
44 public:
45  //constructor and destructor
51  Robot(rob* R , bool copy = false );
52 
56  virtual ~Robot();
57 
58  rob* copyRobotStruct(rob* robotPt);
59 
60  //Accessor
65  rob* getRobotStruct();
66 
71  std::string getName();
72 
76  HRI_AGENT* getHriAgent();
77 
81  void setHriAgent(HRI_AGENT* ag);
82 
87 
91  void setObjectRob(ObjectRob* ore);
92 
96  void setActiveScene(Scene* sc) { m_ActiveScene = sc; }
97 
101  Scene* getActiveScene() { return m_ActiveScene; }
102 
107  traj* getTrajStruct();
108 
113 
118  unsigned int getNumberOfJoints();
119 
124  Joint* getJoint(unsigned int i);
125 
130  Joint* getJoint(std::string name);
131 
135  const std::vector<Joint*>& getAllJoints();
136 
141  std::vector<Eigen::Vector3d> getObjectBox();
142 
147  void initObjectBox();
148 
153  std::tr1::shared_ptr<Configuration> shootQuadConf();
154 
160  std::tr1::shared_ptr<Configuration> shoot(bool samplePassive = false);
161 
162  std::tr1::shared_ptr<Configuration> shootDirections(std::tr1::shared_ptr<Configuration> from , int nactive, int scale=1);
163 
169  std::tr1::shared_ptr<Configuration> shootDir(bool samplePassive = false);
170 
174  std::tr1::shared_ptr<Configuration> shootFreeFlyer(double* box);
175 
179  int setAndUpdateFreeFlyer(const Eigen::Vector3d& pos);
180 
186  int setAndUpdate(Configuration& q, bool withoutFreeFlyers = false);
187 
194 
200 
205 
210  std::tr1::shared_ptr<Configuration> getInitialPosition();
211 
216  bool isInCollision();
217 
223 
227  void setInitialPosition(Configuration& conf);
228 
233  std::tr1::shared_ptr<Configuration> getGoTo();
234 
238  void setGoTo(Configuration& conf);
239 
243  std::tr1::shared_ptr<Configuration> getCurrentPos();
244 
248  std::tr1::shared_ptr<Configuration> getNewConfig();
249 
253  Eigen::Matrix4d getJointAbsPos(int id);
254 
260  Eigen::Vector3d getJointPos(int id);
261 
265  unsigned int getNumberOfActiveDoF();
266 
270  Joint* getIthActiveDoFJoint(unsigned int ithActiveDoF , unsigned int& ithDofOnJoint );
271 
272  void getListOfPassiveJoints(std::list<Joint *> & passiveJoints);
273 
274  unsigned getNbConf() const { return _Robot->nconf; }
275 
276  confPtr_t getConf(unsigned i) {
277  confPtr_t conf(new Configuration(this, _Robot->conf[i]->q));
278  return conf;
279  }
280 
281 #ifdef LIGHT_PLANNER
282 
285  int getObjectDof();
286 
291  bool isActiveCcConstraint();
292 
296  void activateCcConstraint();
297 
301  void deactivateCcConstraint();
302 
306  jnt* getBaseJnt();
307 
308  unsigned int getBaseJointIndex();
309 
313  std::tr1::shared_ptr<Configuration> shootRandomDirection();
314 
318  std::tr1::shared_ptr<Configuration> shootBase();
319 
323  std::tr1::shared_ptr<Configuration> shootBaseWithoutCC();
324 
328  std::tr1::shared_ptr<Configuration> shootAllExceptBase();
329 
333  bool setAndUpdateAllExceptBase(Configuration& Conf);
334 
339  void shootObjectJoint(Configuration& Conf);
340 
344  bool isCarryingObject(int armId);
345 #endif
346 
347  bool isAgent(){return isAnAgent;}
348  void isAgent(bool isAg){isAnAgent = isAg;}
349 
350  void attachObj(Robot* obj, int jointId);
351  void dettachObj(Robot* obj);
352  void dettachObj(int jointId);
353  bool isObjectAttached();
354  bool isObjectAttached(Robot* obj, int jointId);
355  Joint* whereObjectAttached(Robot* obj);
356  p3d_rob *whichObjectAttached(int jointId);
357  p3d_rob* isAttached();
358 
359 private:
360  rob* _Robot;
361  HRI_AGENT* _agent;
362  bool isAnAgent;
363  ObjectRob* _objectRob;
364  std::string _Name;
365  Scene* m_ActiveScene;
366  bool _copy;
368  std::vector<Joint*> m_Joints;
369 
370  Eigen::Vector3d m_ObjectBoxCenter;
371  Eigen::Vector3d m_ObjectBoxDimentions;
372 };
373 
374 extern Robot* API_activeRobot;
375 
376 #endif
ObjectRob * getObjectRob()
return objectRob related to the robot if possible
Definition: robot.cpp:118
bool setAndUpdateHumanArms(Configuration &q)
set and update Human Arms
Definition: robot.cpp:630
Eigen::Vector3d getJointPos(int id)
Get the Robot joint Position.
Definition: robot.cpp:736
std::tr1::shared_ptr< Configuration > shootFreeFlyer(double *box)
shoots the active free flyer inside a box
Joint * getJoint(unsigned int i)
Gets the ith joint structure.
void initObjectBox()
Initializes the box in which the FF Will be sampled.
Definition: robot.cpp:229
int setAndUpdate(Configuration &q, bool withoutFreeFlyers=false)
place le Robot dans une Configuration
Definition: robot.cpp:595
bool isInCollisionWithOthersAndEnv()
Returns true if the robot is in colision with obstacles or other robots.
Definition: robot.cpp:669
bool isInCollision()
Returns true if the robot is in colision with obstacles, other robots and self.
Definition: robot.cpp:644
Scene * getActiveScene()
Returns the active scene involving the robot.
Definition: robot.hpp:101
std::vector< Eigen::Vector3d > getObjectBox()
Returns the Object Box.
Definition: robot.cpp:180
unsigned int getNumberOfJoints()
Get the number of Joints.
Definition: robot.cpp:149
std::tr1::shared_ptr< Configuration > getNewConfig()
Returns a new configuration.
Definition: robot.cpp:700
This class holds a the robot represented by a kinematic chain.
Definition: robot.hpp:42
Definition: objectrob.hpp:22
void setHriAgent(HRI_AGENT *ag)
set hri_agent related to the robot if possible
Definition: robot.cpp:113
Class that represents a Scene, Described by a p3d file.
Definition: scene.hpp:22
bool setAndUpdateMultiSol(Configuration &q)
place le Robot dans une Configuration
Definition: robot.cpp:612
void setObjectRob(ObjectRob *ore)
set hri_agent related to the robot if possible
Definition: robot.cpp:123
This class holds a Joint and is associated with a Body (Link) It's the basic element of a kinematic c...
Definition: joint.hpp:27
Definition: trajectory.hpp:40
std::tr1::shared_ptr< Configuration > shootQuadConf()
Sampling method for quadrotor configurations.
Definition: robot.cpp:435
Eigen::Matrix4d getJointAbsPos(int id)
Get the Robot joint AbsPos.
Definition: robot.cpp:705
void setGoTo(Configuration &conf)
Sets the Goto Position of the Robot.
Definition: robot.cpp:689
std::tr1::shared_ptr< Configuration > getCurrentPos()
Returns the Robot current Configuration.
Definition: robot.cpp:694
std::tr1::shared_ptr< Configuration > getInitialPosition()
obtient la Configuration current du Robot
Definition: robot.cpp:674
int setAndUpdateFreeFlyer(const Eigen::Vector3d &pos)
set and update the active free flyer
Definition: robot.cpp:582
traj * getTrajStruct()
Gets traj associated with Robot.
Definition: robot.cpp:138
std::tr1::shared_ptr< Configuration > shootDir(bool samplePassive=false)
obtient une Configuration-Direction aléatoire pour le Robot
Definition: robot.cpp:574
virtual ~Robot()
Destructeur de la classe.
Definition: robot.cpp:86
rob * getRobotStruct()
obtient la structure p3d_rob de la classe
Definition: robot.cpp:129
unsigned int getNumberOfActiveDoF()
Get Number of active DoFs.
Definition: robot.cpp:755
Classe représentant une Configuration d'un Robot.
Definition: configuration.hpp:25
API::Trajectory getCurrentTraj()
Gets the current trajectory.
Definition: robot.cpp:143
void setAndUpdateWithoutConstraints(Configuration &q)
place le Robot dans une Configuration, without checking the cinematic constraints.
Definition: robot.cpp:622
void setInitialPosition(Configuration &conf)
Sets the Initial Position of the Robot.
Definition: robot.cpp:679
Robot(rob *R, bool copy=false)
Constructeur de la classe.
Definition: robot.cpp:67
Joint * getIthActiveDoFJoint(unsigned int ithActiveDoF, unsigned int &ithDofOnJoint)
Get Number of active DoFs.
Definition: robot.cpp:782
std::tr1::shared_ptr< Configuration > shoot(bool samplePassive=false)
tire une Configuration aléatoire pour le Robot
Definition: robot.cpp:495
HRI_AGENT * getHriAgent()
return hri_agent related to the robot if possible
Definition: robot.cpp:107
const std::vector< Joint * > & getAllJoints()
Returns an vector of all robot joints.
Definition: robot.cpp:175
std::tr1::shared_ptr< Configuration > getGoTo()
obtient la Configuration GoTo du Robot
Definition: robot.cpp:684
std::string getName()
obtient le nom du Robot
Definition: robot.cpp:102
void setActiveScene(Scene *sc)
Associate an active scene to the robot.
Definition: robot.hpp:96