Klamp't  0.9.0
4 #include "Robot.h"
5 #include "RigidObject.h"
6 #include "World.h"
7 #include <map>
9 namespace Klampt {
18 {
19  public:
22  int Add(RobotModel* robot,const char* name=NULL);
23  int Add(RigidObjectModel* object,const char* name=NULL);
24  void Remove(int id);
25  void Remove(const char* name) { Remove(ID(name)); }
26  void Remove(RobotModel* robot) { Remove(ID(robot)); }
27  void Remove(RigidObjectModel* object) { Remove(ID(object)); }
29  int ID(const char* name) const;
31  int ID(RobotModel* robot) const;
33  int ID(RigidObjectModel* object) const;
35  int NumDof() const;
37  string DofName(int index) const;
39  int DofToID(int index) const;
41  pair<int,int> Dofs(int id) const;
43  pair<int,int> Dofs(const char* name) const { return Dofs(ID(name)); }
45  pair<int,int> Dofs(RobotModel* robot) const { return Dofs(ID(robot)); }
47  pair<int,int> Dofs(RigidObjectModel* object) const { return Dofs(ID(object)); }
49  int Dof(int id,int link) const { return Dofs(id).first+link; }
51  int Dof(RobotModel* robot,int link) const { return Dof(ID(robot),link); }
53  int Dof(const char* name,int link) const { return Dof(ID(name),link); }
55  void SetConfig(const Config& q);
57  void SetVelocity(const Vector& v);
59  void GetConfig(Config& q) const;
61  void GetVelocity(Vector& v) const;
63  void UpdateGeometry();
65  void Split(const Config& q,vector<Config>& qsplit) const;
67  void SplitRefs(const Config& q,vector<Config>& qsplit) const;
69  void Join(const vector<Config>& qsplit,Config& q) const;
71  void Interpolate(const Config& a,const Config& b,Real u,Config& out) const;
73  void InterpolateVelocity(const Config& a,const Config& b,Real u,Vector& dq) const;
74  //Integrates a velocity vector dq from q to obtain the configuration out
75  void Integrate(const Config& q,const Vector& dq,Config& out) const;
77  Real Distance(const Config& a,const Config& b,Real floatingRotationWeight=1.0) const;
79  void GetJointLimits(Config& qmin,Config& qmax) const;
81  Vector3 GetCOM() const;
83  void GetMegaRobot(RobotModel& voltron) const;
85  struct Element
86  {
87  string name;
88  RobotModel* robot;
89  RigidObjectModel* object;
91  int indexStart,indexEnd;
92  };
93  map<int,Element> elements;
94 };
99 void ObjectToRobot(const RigidObjectModel& object,RobotModel& robot);
102 void ConfigToTransform(const Vector& q,RigidTransform& T);
105 void TransformToConfig(const RigidTransform& T,Vector& q);
107 } // namespace Klampt
109 #endif
pair< int, int > Dofs(RigidObjectModel *object) const
Returns the DOF index range associated with the given object.
Definition: GeneralizedRobot.h:47
void Interpolate(const Config &a, const Config &b, Real u, Config &out) const
Interpolates two configurations.
Vector3 GetCOM() const
Gets the overall center of mass.
int NumDof() const
Returns the total number of DOF.
int ID(const char *name) const
Returns the array index of the given named element.
void SetConfig(const Config &q)
Sets a joint configuration of all the elements.
void GetConfig(Config &q) const
Gets the joint configuration of all the elements.
pair< int, int > Dofs(const char *name) const
Returns the DOF index range associated with the given named element.
Definition: GeneralizedRobot.h:43
A (static) rigid object that may be manipulated.
Definition: RigidObject.h:15
Defines the WorldModel class.
Definition: GeneralizedRobot.h:85
string DofName(int index) const
Returns a name for the given DOF index.
void GetJointLimits(Config &qmin, Config &qmax) const
Gets joint limits among all objects.
int DofToID(int index) const
Returns the ID for the indicated DOF.
pair< int, int > Dofs(RobotModel *robot) const
Returns the DOF index range associated with the given robot.
Definition: GeneralizedRobot.h:45
void GetVelocity(Vector &v) const
Gets the joint velocity of all the elements.
A collection of robots and objects that can be treated like one "big robot".
Definition: GeneralizedRobot.h:17
void GetMegaRobot(RobotModel &voltron) const
Gets the "mega robot" that merges all robots and objects together.
pair< int, int > Dofs(int id) const
Returns the DOF index range associated with the given id.
int Dof(RobotModel *robot, int link) const
Returns the DOF index associated with the element of the given id, offset by link.
Definition: GeneralizedRobot.h:51
void InterpolateVelocity(const Config &a, const Config &b, Real u, Vector &dq) const
Returns the velocity vector that will move from a to b at the parameter u.
int indexStart
indices governed by this element are in range [indexStart,indexEnd)
Definition: GeneralizedRobot.h:91
void Join(const vector< Config > &qsplit, Config &q) const
Joins a list of configurations of indivdual elements into a single joint configuration.
void Split(const Config &q, vector< Config > &qsplit) const
Splits the joint configuration to a list of configurations of individual elements.
The main robot type used in RobotSim.
Definition: Robot.h:83
void SplitRefs(const Config &q, vector< Config > &qsplit) const
Same as split, but generates references to q in order to minimize copying.
int Dof(const char *name, int link) const
Returns the DOF index associated with the element of the given name.
Definition: GeneralizedRobot.h:53
void UpdateGeometry()
Updates the geometry of all the elements.
Definition: ContactDistance.h:6
Real Distance(const Config &a, const Config &b, Real floatingRotationWeight=1.0) const
Returns a distance metric between two configurations.
void SetVelocity(const Vector &v)
Sets a joint velocity of all the elements.
The main world class containing multiple robots, objects, and static geometries (terrains). Lights and other viewport information may also be stored here.
Definition: World.h:24
int Dof(int id, int link) const
Returns the DOF index associated with the element of the given id, offset by link.
Definition: GeneralizedRobot.h:49