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 #ifndef __DISCUS_H
00038 #define __DISCUS_H
00039
00040 #include <ode_robots/primitive.h>
00041 #include <ode_robots/joint.h>
00042 #include <ode_robots/oneaxisservo.h>
00043 #include <ode_robots/oderobot.h>
00044 #include <ode_robots/sensor.h>
00045 #include <ode_robots/raysensorbank.h>
00046
00047 namespace lpzrobots {
00048
00049
00050 typedef struct {
00051 public:
00052 double diameter;
00053 double relativewidth;
00054 double stabdiameter;
00055 unsigned int numAxes;
00056 double spheremass;
00057 double pendulardiameter;
00058 double pendularmass;
00059 double motorpowerfactor;
00060 double pendularrange;
00061 double pendularrangeN;
00062 bool motorsensor;
00063 bool irAxis1;
00064 bool irAxis2;
00065 bool irAxis3;
00066 bool irRing;
00067 bool irSide;
00068 bool drawIRs;
00069 double irsensorscale;
00070 double irCharacter;
00071 RaySensor* irSensorTempl;
00072 double motor_ir_before_sensors;
00073 double brake;
00074
00075
00076 void destroy();
00077
00078 std::list<Sensor*> sensors;
00079
00080 void addSensor(Sensor* s) { sensors.push_back(s); }
00081 } DiscusConf;
00082
00083
00084
00085
00086
00087 class Discus : public OdeRobot
00088 {
00089 public:
00090
00091 enum objects { Base, Stabilizer, Pendular1, Pendular2, Pendular3, Last } ;
00092
00093 protected:
00094 static const int maxservono=3;
00095
00096 Primitive* object[Last];
00097 SliderServo* servo[maxservono];
00098 SliderJoint* joint[maxservono];
00099 OSGPrimitive* axis[maxservono];
00100
00101 DiscusConf conf;
00102 RaySensorBank irSensorBank;
00103 double transparency;
00104 bool created;
00105
00106 public:
00107
00108
00109
00110
00111 Discus ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00112 const DiscusConf& conf, const std::string& name, double transparency=0.5 );
00113
00114 protected:
00115
00116
00117
00118 Discus ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00119 const DiscusConf& conf,
00120 const std::string& name, const std::string& revision, double transparency);
00121
00122 void init();
00123 public:
00124 virtual ~Discus();
00125
00126
00127
00128 static DiscusConf getDefaultConf(){
00129 DiscusConf c;
00130 c.diameter = 1;
00131 c.relativewidth= 0.2;
00132 c.stabdiameter=0.7;
00133 c.numAxes = 3;
00134 c.spheremass = 1;
00135 c.pendularmass = 0.75;
00136 c.pendularrange = 0.20;
00137 c.pendularrangeN = 0.25;
00138 c.motorpowerfactor = 100;
00139 c.motorsensor = true;
00140 c.irAxis1=false;
00141 c.irAxis2=false;
00142 c.irAxis3=false;
00143 c.irRing=false;
00144 c.irSide=false;
00145 c.drawIRs=true;
00146 c.irsensorscale=1.5;
00147 c.irCharacter=1;
00148 c.irSensorTempl=0;
00149 c.motor_ir_before_sensors=false;
00150 c.brake=0;
00151 return c;
00152 }
00153
00154 virtual void update();
00155
00156 virtual void place(const osg::Matrix& pose);
00157
00158 virtual void doInternalStuff(GlobalData& globalData);
00159
00160 virtual int getSensors ( sensor* sensors, int sensornumber );
00161
00162 virtual void setMotors ( const motor* motors, int motornumber );
00163
00164 virtual int getMotorNumber();
00165
00166 virtual int getSensorNumber();
00167
00168 virtual Primitive* getMainPrimitive() const { return object[Base]; }
00169
00170 protected:
00171
00172 virtual void create(const osg::Matrix& pose);
00173 virtual void destroy();
00174
00175
00176 };
00177
00178 }
00179
00180 #endif