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