sliderwheelie.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 __SLIDERWHEELIE_H
00025 #define __SLIDERWHEELIE_H
00026
00027 #include<vector>
00028 #include<assert.h>
00029
00030 #include "oderobot.h"
00031 #include"primitive.h"
00032 #include "joint.h"
00033 #include "angularmotor.h"
00034
00035 #include "oneaxisservo.h"
00036
00037
00038 namespace lpzrobots {
00039
00040 typedef struct {
00041 public:
00042 enum MotorType {Servo, CenteredServo, AngularMotor };
00043
00044 int segmNumber;
00045 double segmLength;
00046 double segmDia;
00047 double segmMass;
00048 double motorPower;
00049 double motorDamp;
00050 double powerRatio;
00051 double sensorFactor;
00052 double frictionGround;
00053 double frictionJoint;
00054 double jointLimitIn;
00055 double jointLimitOut;
00056 double sliderLength;
00057 MotorType motorType;
00058 bool showCenter;
00059
00060 std::string texture;
00061 } SliderWheelieConf;
00062
00063
00064
00065
00066
00067
00068
00069 class SliderWheelie : public OdeRobot
00070 {
00071 private:
00072 bool created;
00073
00074 std::vector <AngularMotor*> angularMotors;
00075 SliderWheelieConf conf;
00076
00077 std::vector <HingeServo*> hingeServos;
00078 std::vector <SliderServo*> sliderServos;
00079
00080 Primitive* center;
00081 DummyPrimitive* dummycenter;
00082 public:
00083 SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00084 const SliderWheelieConf& conf, const std::string& name,
00085 const std::string& revision = "");
00086
00087 virtual ~SliderWheelie();
00088
00089 static SliderWheelieConf getDefaultConf(){
00090 SliderWheelieConf conf;
00091 conf.segmNumber = 8;
00092 conf.segmLength = 0.4;
00093 conf.segmDia = 0.2;
00094 conf.segmMass = 0.4;
00095 conf.motorPower = 5;
00096 conf.motorDamp = 0.01;
00097 conf.powerRatio = 2;
00098 conf.sensorFactor = 1;
00099 conf.frictionGround = 0.8;
00100 conf.frictionJoint = 0.0;
00101 conf.jointLimitIn = M_PI/3;
00102 conf.jointLimitOut = -1;
00103 conf.sliderLength = 1;
00104 conf.motorType = SliderWheelieConf::CenteredServo;
00105 conf.showCenter = false;
00106 conf.texture = "";
00107 return conf;
00108 }
00109
00110 virtual void place(const osg::Matrix& pose);
00111
00112 virtual void update();
00113
00114 void doInternalStuff(GlobalData& global);
00115
00116 virtual void setMotors ( const motor* motors, int motornumber );
00117
00118 virtual int getSensors ( sensor* sensors, int sensornumber );
00119
00120 virtual int getSensorNumber() { assert(created);
00121 return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
00122
00123 virtual int getMotorNumber(){ assert(created);
00124 return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
00125
00126 virtual Primitive* getMainPrimitive() const {
00127 if(dummycenter) return dummycenter;
00128 else if(!objects.empty()){
00129 return (objects[0]);
00130 }else return 0;
00131 }
00132
00133 virtual std::vector<Primitive*> getAllPrimitives() const { return objects;}
00134
00135
00136 virtual void notifyOnChange(const paramkey& key);
00137
00138 private:
00139 static void mycallback(void *data, dGeomID o1, dGeomID o2);
00140
00141 virtual void create(const osg::Matrix& pose);
00142 virtual void destroy();
00143 };
00144
00145 }
00146
00147 #endif