Klamp't  0.8.1
ODERobot.h
1 #ifndef ODE_INTERFACE_ROBOT_H
2 #define ODE_INTERFACE_ROBOT_H
3 
4 #include <Klampt/Modeling/Robot.h>
5 #include "ODEGeometry.h"
6 #include "ODESurface.h"
7 #include <ode/common.h>
8 #include <KrisLibrary/File.h>
9 using namespace Math;
10 using namespace std;
11 
28 class ODERobot
29 {
30  public:
31  static double defaultPadding;
32  static ODESurfaceProperties defaultSurface;
33 
34  ODERobot(Robot& robot);
35  ~ODERobot();
36  void Create(int index,dWorldID worldID,bool useBoundaryLayer=true);
37  void Clear();
38  void EnableSelfCollisions(bool enabled);
39  bool SelfCollisionsEnabled() const;
40  void SetConfig(const Config& q);
41  void GetConfig(Config& q) const;
42  void SetVelocities(const Config& dq);
43  void GetVelocities(Config& dq) const;
44  void AddTorques(const Vector& t);
45  Real GetJointAngle(int joint) const;
46  Real GetJointVelocity(int joint) const;
47  void AddJointTorque(int joint,Real t);
48  void SetJointDryFriction(int joint,Real coeff);
49  void SetJointFixedVelocity(int joint,Real vel,Real tmax);
50  Real GetLinkAngle(int link) const;
51  Real GetLinkVelocity(int link) const;
52  void AddLinkTorque(int link,Real t);
53  void SetLinkDryFriction(int link,Real coeff);
54  void SetLinkFixedVelocity(int link,Real vel,Real tmax);
55  Real GetDriverValue(int driver) const;
56  Real GetDriverVelocity(int driver) const;
57  void AddDriverTorques(const Vector& t);
58  void AddDriverTorque(int driver,Real t);
59  void SetDriverFixedVelocity(int driver,Real vel,Real tmax);
60 
61  void SetLinkTransform(int link,const RigidTransform& T);
62  void GetLinkTransform(int link,RigidTransform& T) const;
63  void SetLinkVelocity(int link,const Vector3& w,const Vector3& v);
64  void GetLinkVelocity(int link,Vector3& w,Vector3& v) const;
65  Real GetKineticEnergy() const;
66  Real GetKineticEnergy(int link) const;
67  bool ReadState(File& f);
68  bool WriteState(File& f) const;
69 
70  inline dSpaceID space() const { return spaceID; }
71  inline dBodyID body(int link) const { return bodyID[link]; }
72  inline dGeomID geom(int link) const { return geometry[link]->geom(); }
73  inline dJointID joint(int link) const { return jointID[link]; }
74  inline ODEGeometry* triMesh(int link) const { return geometry[link]; }
75  dBodyID baseBody(int link) const; //for attached links, returns the base body for the link
76  inline dJointFeedback feedback(int link) const { return jointFeedback[link]; }
77 
78  Robot& robot;
79 
80  private:
81  vector<RigidTransform> T_bodyToLink;
82  vector<dBodyID> bodyID;
83  vector<ODEGeometry*> geometry;
84  vector<dJointID> jointID;
85  vector<dJointFeedback> jointFeedback;
86  dJointGroupID jointGroupID;
87  dSpaceID spaceID;
88  vector<shared_ptr<RobotWithGeometry::CollisionGeometry> > tempGeometries;
89 };
90 
91 #endif
A robot simulated in an ODE "world".
Definition: ODERobot.h:28
The main robot type used in RobotSim.
Definition: Robot.h:79
An ODE collision geometry.
Definition: ODEGeometry.h:17
surface properties for any ODE rigid object, robot link, or fixed object.
Definition: ODESurface.h:8