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