discus.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  *                                                                 *
00022  ***************************************************************************
00023  *                                                                         *
00024  * A discusbot
00025  *                                                                         *
00026  *   $Log: discus.h,v $
00027  *   Revision 1.2  2009/08/10 07:26:08  guettler
00028  *   removed typedef to avoid compiler warnings
00029  *
00030  *   Revision 1.1  2009/01/19 14:33:34  martius
00031  *   new discus-shaped robot
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   /// configuration object for the Discus robot.
00050 typedef struct {
00051 public:
00052   double diameter;
00053   double relativewidth;
00054   double stabdiameter;    ///< diameter of capsule relative to diameter of body
00055   unsigned int  numAxes;  ///< number of axes with moving masses
00056   double spheremass;
00057   double pendulardiameter; ///< automatically set
00058   double pendularmass;
00059   double motorpowerfactor; ///< power factor for servos w.r.t. pendularmass 
00060   double pendularrange;    ///< fraction of the diameter the pendular masses can move to one side
00061   double pendularrangeN;   ///< fraction of the diameter the normal pendular masses can move to one side
00062   bool motorsensor;        ///< motor values as sensors
00063   bool irAxis1;
00064   bool irAxis2;
00065   bool irAxis3;
00066   bool irRing;            ///< IR sensors in a ring in x,z plane (collides with irAxis1 and irAxis3)
00067   bool irSide;            ///< 4 IR senors to both side in y direction (collides with irAxis2)
00068   bool drawIRs;
00069   double irsensorscale; ///< range of the ir sensors in units of diameter
00070   double irCharacter;   ///< characteristics of sensor (\f[ x^c \f] where x is the range-distance)
00071   RaySensor* irSensorTempl;  ///< template for creation of the other ir sensors (if 0 then IRSensor(irCharacter))
00072   double motor_ir_before_sensors; ///< if true motor sensors and ir sensors are given before additional sensors
00073   double brake;         ///< if nonzero the robot brakes (deaccelerates actively/magically) (velocity dependend torque)
00074 
00075   /// function that deletes sensors
00076   void destroy(); 
00077   /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
00078   std::list<Sensor*> sensors; 
00079   /// adds a sensor to the list of sensors
00080   void addSensor(Sensor* s) { sensors.push_back(s); }    
00081 } DiscusConf;
00082 
00083 /**
00084    A spherical robot with 3 internal masses, which can slide on their orthogonal axes.
00085    This robot was inspired by Julius Popp (http://sphericalrobots.com)
00086 */
00087 class Discus : public OdeRobot
00088 {
00089 public:
00090   /// enum for the objects of the robot
00091   /* typedef */ 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; ///< a collection of ir sensors  
00103   double transparency;
00104   bool created;
00105 
00106 public:
00107 
00108   /**
00109    *constructor
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    *constructor for children
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   /// initialises some internal variables
00122   void init();
00123 public:  
00124   virtual ~Discus();
00125 
00126         
00127   /// default configuration
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;// 0.1
00135     c.pendularmass  = 0.75;
00136     c.pendularrange  = 0.20; // range of the slider from center in multiple of diameter [-range,range]
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

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7