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 #ifndef __SLIDERWHEELIE_H
00063 #define __SLIDERWHEELIE_H
00064
00065 #include<vector>
00066 #include<assert.h>
00067
00068 #include "oderobot.h"
00069 #include"primitive.h"
00070 #include "joint.h"
00071 #include "angularmotor.h"
00072
00073 #include "oneaxisservo.h"
00074
00075
00076 namespace lpzrobots {
00077
00078 typedef struct {
00079 public:
00080 int segmNumber;
00081 double segmLength;
00082 double segmDia;
00083 double segmMass;
00084 double motorPower;
00085 double powerRatio;
00086 double sensorFactor;
00087 double frictionGround;
00088 double frictionJoint;
00089 double jointLimitIn;
00090 double jointLimitOut;
00091 double sliderLength;
00092 } SliderWheelieConf;
00093
00094
00095
00096
00097
00098
00099
00100 class SliderWheelie : public OdeRobot
00101 {
00102 private:
00103 bool created;
00104
00105 std::vector <Primitive*> objects;
00106 std::vector <Joint*> joints;
00107 std::vector <AngularMotor*> frictionmotors;
00108 SliderWheelieConf conf;
00109
00110 std::vector <HingeServo*> hingeServos;
00111 std::vector <SliderServo*> sliderServos;
00112
00113 Primitive* center;
00114 public:
00115 SliderWheelie(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00116 const SliderWheelieConf& conf, const std::string& name,
00117 const std::string& revision = "");
00118
00119 virtual ~SliderWheelie();
00120
00121 static SliderWheelieConf getDefaultConf(){
00122 SliderWheelieConf conf;
00123 conf.segmNumber = 8;
00124 conf.segmLength = 0.4;
00125 conf.segmDia = 0.2;
00126 conf.segmMass = 0.4;
00127 conf.motorPower = 0.2;
00128 conf.powerRatio = 2;
00129 conf.sensorFactor = 1;
00130 conf.frictionGround = 0.8;
00131 conf.frictionJoint = 0.0;
00132 conf.jointLimitIn = M_PI/2;
00133 conf.jointLimitOut = -1;
00134 conf.sliderLength = 1;
00135 return conf;
00136 }
00137
00138 virtual void place(const osg::Matrix& pose);
00139
00140 virtual void update();
00141
00142 void doInternalStuff(GlobalData& global);
00143
00144 bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
00145
00146 virtual void setMotors ( const motor* motors, int motornumber );
00147
00148 virtual int getSensors ( sensor* sensors, int sensornumber );
00149
00150 virtual int getSensorNumber() { assert(created); return hingeServos.size()+sliderServos.size(); }
00151
00152 virtual int getMotorNumber(){ assert(created); return hingeServos.size()+sliderServos.size(); }
00153
00154 virtual Primitive* getMainPrimitive() const {
00155 if(center) return center;
00156 else if(!objects.empty()){
00157 return (objects[0]);
00158 }else return 0;
00159 }
00160
00161 virtual paramlist getParamList() const;
00162
00163 virtual paramval getParam(const paramkey& key) const;
00164
00165 virtual bool setParam(const paramkey& key, paramval val);
00166
00167 private:
00168 static void mycallback(void *data, dGeomID o1, dGeomID o2);
00169
00170 virtual void create(const osg::Matrix& pose);
00171 virtual void destroy();
00172 };
00173
00174 }
00175
00176 #endif