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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 #ifndef __SLIDERWHEELIE_H
00084 #define __SLIDERWHEELIE_H
00085
00086 #include<vector>
00087 #include<assert.h>
00088
00089 #include "oderobot.h"
00090 #include"primitive.h"
00091 #include "joint.h"
00092 #include "angularmotor.h"
00093
00094 #include "oneaxisservo.h"
00095
00096
00097 namespace lpzrobots {
00098
00099 typedef struct {
00100 public:
00101 enum MotorType {Servo, CenteredServo, AngularMotor };
00102
00103 int segmNumber;
00104 double segmLength;
00105 double segmDia;
00106 double segmMass;
00107 double motorPower;
00108 double motorDamp;
00109 double powerRatio;
00110 double sensorFactor;
00111 double frictionGround;
00112 double frictionJoint;
00113 double jointLimitIn;
00114 double jointLimitOut;
00115 double sliderLength;
00116 MotorType motorType;
00117 bool showCenter;
00118 } SliderWheelieConf;
00119
00120
00121
00122
00123
00124
00125
00126 class SliderWheelie : public OdeRobot
00127 {
00128 private:
00129 bool created;
00130
00131
00132 std::vector <Primitive*> objects;
00133 std::vector <Joint*> joints;
00134 std::vector <AngularMotor*> angularMotors;
00135 SliderWheelieConf conf;
00136
00137 std::vector <HingeServo*> hingeServos;
00138 std::vector <SliderServo*> sliderServos;
00139
00140 Primitive* center;
00141 DummyPrimitive* dummycenter;
00142 public:
00143 SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00144 const SliderWheelieConf& conf, const std::string& name,
00145 const std::string& revision = "");
00146
00147 virtual ~SliderWheelie();
00148
00149 static SliderWheelieConf getDefaultConf(){
00150 SliderWheelieConf conf;
00151 conf.segmNumber = 8;
00152 conf.segmLength = 0.4;
00153 conf.segmDia = 0.2;
00154 conf.segmMass = 0.4;
00155 conf.motorPower = 5;
00156 conf.motorDamp = 0.01;
00157 conf.powerRatio = 2;
00158 conf.sensorFactor = 1;
00159 conf.frictionGround = 0.8;
00160 conf.frictionJoint = 0.0;
00161 conf.jointLimitIn = M_PI/3;
00162 conf.jointLimitOut = -1;
00163 conf.sliderLength = 1;
00164 conf.motorType = SliderWheelieConf::CenteredServo;
00165 conf.showCenter = false;
00166 return conf;
00167 }
00168
00169 virtual void place(const osg::Matrix& pose);
00170
00171 virtual void update();
00172
00173 void doInternalStuff(GlobalData& global);
00174
00175 bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00176
00177 virtual void setMotors ( const motor* motors, int motornumber );
00178
00179 virtual int getSensors ( sensor* sensors, int sensornumber );
00180
00181 virtual int getSensorNumber() { assert(created);
00182 return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
00183
00184 virtual int getMotorNumber(){ assert(created);
00185 return hingeServos.size()+angularMotors.size()+sliderServos.size(); }
00186
00187 virtual Primitive* getMainPrimitive() const {
00188 if(dummycenter) return dummycenter;
00189 else if(!objects.empty()){
00190 return (objects[0]);
00191 }else return 0;
00192 }
00193
00194 virtual paramlist getParamList() const;
00195
00196 virtual paramval getParam(const paramkey& key) const;
00197
00198 virtual bool setParam(const paramkey& key, paramval val);
00199
00200 private:
00201 static void mycallback(void *data, dGeomID o1, dGeomID o2);
00202
00203 virtual void create(const osg::Matrix& pose);
00204 virtual void destroy();
00205 };
00206
00207 }
00208
00209 #endif