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