Klamp't  0.8.1
Robot.h
1 #ifndef MODELING_ROBOT_H
2 #define MODELING_ROBOT_H
3 
4 #include <KrisLibrary/robotics/RobotWithGeometry.h>
5 #include <KrisLibrary/utils/PropertyMap.h>
6 #include "ManagedGeometry.h"
7 
8 using namespace std;
9 
13 struct RobotJoint
14 {
24  enum Type { Weld, Normal, Spin, Floating, FloatingPlanar, BallAndSocket, Closed };
25 
30  int linkIndex;
33  int baseIndex;
35  Vector3 localPt,attachmentPt;
36 };
37 
42 {
53  enum Type { Normal, Affine, Translation, Rotation, Custom };
54 
55  int NumControls() const; //number of input controls
56  int NumLinks() const;
57  bool Affects(int link) const;
58 
59  Type type;
60  vector<int> linkIndices;
61  Real qmin,qmax; //min/max values
62  Real vmin,vmax; //min/max velocities
63  Real amin,amax; //min/max accelerations
64  Real tmin,tmax; //min/max torques
65  vector<Real> affScaling; //for Affine joints
66  vector<Real> affOffset; //for Affine joints
67  Real servoP,servoI,servoD; //servo parameters
68  Real dryFriction; //constant friction coefficient
69  Real viscousFriction; //velocity-dependent friction coefficient
70 };
71 
79 class Robot : public RobotWithGeometry
80 {
81 public:
82  virtual std::string LinkName(int i) const;
83  int LinkIndex(const char* name) const;
84  bool Load(const char* fn);
85  bool LoadRob(const char* fn);
86  bool LoadURDF(const char* fn);
87  bool Save(const char* fn);
88  bool LoadGeometry(int i,const char* file);
89  void SetGeomFiles(const char* geomPrefix="",const char* geomExt="off");
90  void SetGeomFiles(const vector<string>& geomFiles);
91  bool SaveGeometry(const char* prefix="");
92  void InitStandardJoints();
93  bool CheckValid() const;
94  //adds a geometry to the geometry of the given link
95  void Mount(int link,const Geometry::AnyGeometry3D& geom,const RigidTransform& T);
96  //adds a subchain as descendents of a given link
97  void Mount(int link,const Robot& subchain,const RigidTransform& T,const char* prefix=NULL);
99  void Merge(const std::vector<Robot*>& robots);
100 
101  bool DoesJointAffect(int joint,int dof) const;
102  void GetJointIndices(int joint,vector<int>& indices) const;
104  void SetJointByTransform(int joint,int link,const RigidTransform& T);
106  void SetJointByOrientation(int joint,int link,const Matrix3& R);
108  void SetJointVelocityByMoment(int joint,int link,const Vector3& w,const Vector3& v);
109 
111  bool IsPassiveDOF(int dof) const;
112  bool DoesDriverAffect(int driver,int dof) const;
113  void GetDriverIndices(int driver,vector<int>& indices) const;
114  Vector2 GetDriverLimits(int driver) const;
115  Real GetDriverValue(int driver) const;
116  Real GetDriverVelocity(int driver) const;
117  void SetDriverValue(int driver,Real value);
118  void SetDriverVelocity(int driver,Real value);
120  void GetDriverJacobian(int driver,Vector& J);
121 
125  void ComputeLipschitzMatrix();
126 
127  string name;
128  vector<string> geomFiles;
129  vector<ManagedGeometry> geomManagers;
130  Vector accMax;
131  vector<RobotJoint> joints;
132  vector<RobotJointDriver> drivers;
133  vector<string> linkNames;
134  vector<string> driverNames;
135 
141  PropertyMap properties;
142 
145 
149 };
150 
151 #endif
Type
Definition: Robot.h:53
Vector accMax
conservative acceleration limits, used by DynamicPath
Definition: Robot.h:130
The main robot type used in RobotSim.
Definition: Robot.h:79
vector< ManagedGeometry > geomManagers
geometry loaders (speeds up loading)
Definition: Robot.h:129
static bool disableGeometryLoading
Definition: Robot.h:148
Type type
The type of this joint.
Definition: Robot.h:27
int linkIndex
Definition: Robot.h:30
Additional joint properties.
Definition: Robot.h:13
vector< string > geomFiles
geometry file names (used in saving)
Definition: Robot.h:128
int baseIndex
Definition: Robot.h:33
Matrix lipschitzMatrix
A matrix of lipschitz constants (see ComputeLipschitzMatrix)
Definition: Robot.h:144
Vector3 localPt
For closed joints.
Definition: Robot.h:35
Determines the effects of an actuator on the robot configuration.
Definition: Robot.h:41
PropertyMap properties
Definition: Robot.h:141
Type
Definition: Robot.h:24