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