skeleton.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __SKELETON_H
00025 #define __SKELETON_H
00026
00027 #include <ode_robots/oderobot.h>
00028 #include <ode_robots/raysensorbank.h>
00029 #include <ode_robots/gripper.h>
00030
00031 namespace lpzrobots {
00032
00033 class Primitive;
00034 class Joint;
00035 class OneAxisServo;
00036 class TwoAxisServo;
00037 class AngularMotor;
00038
00039
00040 typedef struct {
00041 public:
00042 double size;
00043 double massfactor;
00044
00045 bool useVelocityServos;
00046
00047 double relLegmass;
00048 double relArmmass;
00049 double relFeetmass;
00050 double hipPower;
00051 double hipDamping;
00052 double hipVelocity;
00053 double hipJointLimit;
00054 double hip2Power;
00055 double hip2Damping;
00056 double hip2JointLimit;
00057 double neckPower;
00058 double neckDamping;
00059 double neckVelocity;
00060 double neckJointLimit;
00061 double kneePower;
00062 double kneeDamping;
00063 double kneeVelocity;
00064 double kneeJointLimit;
00065 double anklePower;
00066 double ankleDamping;
00067 double ankleVelocity;
00068 double ankleJointLimit;
00069 double armPower;
00070 double armDamping;
00071 double armVelocity;
00072 double armJointLimit;
00073 double elbowPower;
00074 double elbowDamping;
00075 double elbowVelocity;
00076 double elbowJointLimit;
00077 double pelvisPower;
00078 double pelvisDamping;
00079 double pelvisVelocity;
00080 double pelvisJointLimit;
00081 double backPower;
00082 double backDamping;
00083 double backVelocity;
00084 double backJointLimit;
00085
00086 double powerFactor;
00087 double relForce;
00088 double dampingFactor;
00089
00090 double jointLimitFactor;
00091
00092
00093 bool onlyPrimaryFunctions;
00094 bool onlyMainParameters;
00095
00096 bool handsRotating;
00097 bool useGripper;
00098 double gripDuration;
00099 double releaseDuration;
00100
00101 bool movableHead;
00102
00103 bool useBackJoint;
00104
00105 bool irSensors;
00106
00107 std::string headColor;
00108 std::string bodyColor;
00109 std::string trunkColor;
00110 std::string trouserColor;
00111
00112
00113 std::string headTexture;
00114 std::string bodyTexture;
00115 std::string trunkTexture;
00116
00117
00118 } SkeletonConf;
00119
00120
00121
00122
00123 class Skeleton : public OdeRobot, public Inspectable{
00124 public:
00125
00126 enum SkelParts {Hip,Trunk_comp, Belly, Thorax, Neck,
00127 Head_comp,
00128 Left_Shoulder, Left_Forearm, Left_Hand,
00129 Right_Shoulder, Right_Forearm, Right_Hand,
00130 Left_Thigh, Left_Shin, Left_Foot,
00131 Right_Thigh, Right_Shin, Right_Foot,
00132 LastPart };
00133
00134
00135
00136
00137
00138
00139
00140
00141 Skeleton(const OdeHandle& odeHandle, const OsgHandle& osgHandle, SkeletonConf& conf,
00142 const std::string& name);
00143
00144 virtual ~Skeleton(){ destroy(); };
00145
00146 static SkeletonConf getDefaultConf(){
00147 SkeletonConf c;
00148 c.size = 1;
00149 c.massfactor = 1;
00150 c.relLegmass = 1;
00151 c.relFeetmass = 1;
00152 c.relArmmass = 1;
00153
00154 c.useVelocityServos = false;
00155 c.powerFactor = 1.0;
00156 c.relForce = 1.0;
00157 c.dampingFactor = 1.0;
00158 c.jointLimitFactor = 1.1;
00159
00160 c.hipPower = 20;
00161 c.hipDamping = 0.2;
00162 c.hipVelocity = 20;
00163
00164 c.hip2Power = 20;
00165 c.hip2Damping = 0.2;
00166
00167 c.neckPower = 2;
00168 c.neckDamping = 0.1;
00169 c.neckVelocity = 20;
00170
00171 c.kneePower = 10;
00172 c.kneeDamping = 0.1;
00173 c.kneeVelocity = 20;
00174
00175 c.anklePower = 3;
00176 c.ankleDamping = 0.1;
00177 c.ankleVelocity = 20;
00178
00179 c.armPower = 8;
00180 c.armDamping = 0.1;
00181 c.armVelocity = 20;
00182
00183 c.elbowPower = 4;
00184 c.elbowDamping = 0.1;
00185 c.elbowVelocity = 20;
00186
00187 c.pelvisPower = 20;
00188 c.pelvisDamping = 0.2;
00189 c.pelvisVelocity = 20;
00190
00191 c.backPower = 20;
00192 c.backDamping = 0.1;
00193 c.backVelocity = 20;
00194
00195 c.hipJointLimit = 2.1;
00196 c.hip2JointLimit = .8;
00197
00198 c.kneeJointLimit = 2;
00199 c.ankleJointLimit = M_PI/2;
00200
00201 c.armJointLimit = M_PI/2;
00202 c.elbowJointLimit = 1.4;
00203
00204 c.pelvisJointLimit = M_PI/10;
00205
00206 c.neckJointLimit = M_PI/5;
00207 c.backJointLimit = M_PI/3;
00208
00209 c.onlyMainParameters = true;
00210 c.onlyPrimaryFunctions = false;
00211 c.handsRotating = false;
00212 c.movableHead = false;
00213 c.useBackJoint = true;
00214 c.irSensors = false;
00215 c.useGripper = false;
00216 c.gripDuration = 30;
00217 c.releaseDuration = 1;
00218
00219
00220 c.headTexture = "Images/dusty.rgb";
00221 c.headColor = "robot4";
00222
00223 c.bodyTexture = "Images/dusty.rgb";
00224 c.bodyColor = "robot4";
00225 c.trunkTexture = "Images/dusty.rgb";
00226 c.trunkColor = "robot1";
00227 c.trouserColor = "robot2";
00228 return c;
00229 }
00230
00231 static SkeletonConf getDefaultConfVelServos(){
00232 SkeletonConf c = getDefaultConf();
00233
00234 c.useVelocityServos = true;
00235
00236 c.hipDamping = 0.01;
00237 c.hip2Damping = 0.01;
00238 c.neckDamping = 0.01;
00239 c.kneeDamping = 0.01;
00240 c.ankleDamping = 0.01;
00241 c.armDamping = 0.01;
00242 c.elbowDamping = 0.01;
00243 c.pelvisDamping = 0.01;
00244 c.backDamping = 0.01;
00245
00246
00247 return c;
00248 }
00249
00250
00251
00252
00253
00254 virtual void update();
00255
00256
00257
00258
00259
00260 virtual void place(const osg::Matrix& pose);
00261
00262
00263
00264
00265
00266
00267 virtual int getSensors(sensor* sensors, int sensornumber);
00268
00269
00270
00271
00272
00273 virtual void setMotors(const motor* motors, int motornumber);
00274
00275
00276
00277 virtual int getSensorNumber();
00278
00279
00280
00281 virtual int getMotorNumber();
00282
00283
00284
00285
00286
00287 virtual void doInternalStuff(GlobalData& globalData);
00288
00289
00290 virtual void notifyOnChange(const paramkey& key);
00291
00292
00293 virtual Primitive* getMainPrimitive() const { return objects[Thorax]; }
00294
00295
00296 virtual Position getHeadPosition();
00297
00298
00299 virtual Position getTrunkPosition();
00300
00301
00302 GripperList& getGrippers();
00303
00304
00305 protected:
00306
00307
00308
00309
00310 virtual void create(const osg::Matrix& pose);
00311
00312
00313
00314 virtual void destroy();
00315
00316 SkeletonConf conf;
00317
00318 bool created;
00319
00320 OdeHandle ignoreColSpace;
00321
00322 std::vector<TwoAxisServo*> hipservos;
00323 std::vector<OneAxisServo*> kneeservos;
00324 std::vector<OneAxisServo*> ankleservos;
00325 std::vector<TwoAxisServo*> armservos;
00326 std::vector<OneAxisServo*> arm1servos;
00327
00328 std::vector<TwoAxisServo*> headservos;
00329
00330 OneAxisServo* pelvisservo;
00331 std::vector<OneAxisServo*> backservos;
00332
00333
00334 std::vector<AngularMotor*> frictionmotors;
00335
00336 RaySensorBank irSensorBank;
00337 GripperList grippers;
00338 };
00339
00340 }
00341
00342 #endif