sphererobot3masses.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  * Spherical Robot inspired by Julius Popp.                                *
00025  *                                                                         *
00026  *   $Log: sphererobot3masses.h,v $
00027  *   Revision 1.17  2009/08/10 07:48:55  guettler
00028  *   removed typedef to avoid compiler warnings
00029  *
00030  *   Revision 1.16  2008/05/07 16:45:52  martius
00031  *   code cosmetics and documentation
00032  *
00033  *   Revision 1.15  2007/11/07 13:21:16  martius
00034  *   doInternal stuff changed signature
00035  *
00036  *   Revision 1.14  2007/09/06 18:48:00  martius
00037  *   createNewSimpleSpace used
00038  *
00039  *   Revision 1.13  2007/08/24 11:57:30  martius
00040  *   additional sensors can be before or after motor and ir sensors
00041  *
00042  *   Revision 1.12  2007/07/31 08:25:11  martius
00043  *   added comments
00044  *
00045  *   Revision 1.11  2007/04/03 16:27:06  der
00046  *   new IR shape
00047  *
00048  *   Revision 1.10  2007/01/26 12:05:05  martius
00049  *   servos combinied into OneAxisServo
00050  *
00051  *   Revision 1.9  2006/12/21 11:43:05  martius
00052  *   commenting style for doxygen //< -> ///<
00053  *   new sensors for spherical robots
00054  *
00055  *   Revision 1.8  2006/12/01 16:20:40  martius
00056  *   *** empty log message ***
00057  *
00058  *   Revision 1.7  2006/11/17 13:44:43  martius
00059  *   corrected z-axes sensor problem
00060  *   there are two sensors for this situation
00061  *
00062  *   Revision 1.6  2006/09/21 22:09:58  martius
00063  *   collision for mesh
00064  *
00065  *   Revision 1.5  2006/09/21 16:17:18  der
00066  *   *** empty log message ***
00067  *
00068  *   Revision 1.4  2006/08/04 15:07:27  martius
00069  *   documentation
00070  *
00071  *   Revision 1.3  2006/07/20 17:19:45  martius
00072  *   removed using namespace std from matrix.h
00073  *
00074  *   Revision 1.2  2006/07/14 12:23:42  martius
00075  *   selforg becomes HEAD
00076  *
00077  *   Revision 1.1.2.4  2006/06/25 16:57:17  martius
00078  *   abstractrobot is configureable
00079  *   name and revision
00080  *
00081  *   Revision 1.1.2.3  2006/03/30 12:34:57  martius
00082  *   documentation updated
00083  *
00084  *   Revision 1.1.2.2  2006/01/10 17:15:44  martius
00085  *   removed wrong comment
00086  *
00087  *   Revision 1.1.2.1  2006/01/10 17:15:16  martius
00088  *   was sphererobotarms
00089  *   moved to osg
00090  *
00091  *   Revision 1.10.4.3  2005/11/16 11:26:53  martius
00092  *   moved to selforg
00093  *
00094  *   Revision 1.10.4.2  2005/11/15 12:29:27  martius
00095  *   new selforg structure and OdeAgent, OdeRobot ...
00096  *
00097  *   Revision 1.10.4.1  2005/11/14 17:37:18  martius
00098  *   moved to selforg
00099  *
00100  *   Revision 1.10  2005/11/09 13:27:07  martius
00101  *   irsensorrange
00102  *
00103  *   Revision 1.9  2005/11/07 17:04:56  martius
00104  *   irsensorscale added
00105  *
00106  *   Revision 1.8  2005/11/04 14:45:18  martius
00107  *   GPL added
00108  *
00109  *                                                                 *
00110  ***************************************************************************/
00111 
00112 #ifndef __SPHEREROBOT3MASSES_H
00113 #define __SPHEREROBOT3MASSES_H
00114 
00115 #include "primitive.h"
00116 #include "joint.h"
00117 #include "oneaxisservo.h"
00118 #include "oderobot.h"
00119 #include "sensor.h"
00120 #include "raysensorbank.h"
00121 
00122 namespace lpzrobots {
00123 
00124   /// configuration object for the Sphererobot3Masses robot.
00125 typedef struct {
00126 public:
00127   double diameter;
00128   double spheremass;
00129   double pendulardiameter; ///< automatically set
00130   double pendularmass;
00131   double motorpowerfactor; ///< power factor for servos w.r.t. pendularmass 
00132   double pendularrange;    ///< fraction of the diameter the pendular masses can move to one side
00133   bool motorsensor;        ///< motor values as sensors
00134   bool irAxis1;
00135   bool irAxis2;
00136   bool irAxis3;
00137   bool irRing;            ///< IR sensors in a ring in x,z plane (collides with irAxis1 and irAxis3)
00138   bool irSide;            ///< 4 IR senors to both side in y direction (collides with irAxis2)
00139   bool drawIRs;
00140   double irsensorscale; ///< range of the ir sensors in units of diameter
00141   double irCharacter;   ///< characteristics of sensor (\f[ x^c \f] where x is the range-distance)
00142   RaySensor* irSensorTempl;  ///< template for creation of the other ir sensors (if 0 then IRSensor(irCharacter))
00143   double motor_ir_before_sensors; ///< if true motor sensors and ir sensors are given before additional sensors
00144   double brake;         ///< if nonzero the robot brakes (deaccelerates actively/magically)
00145 
00146   /// function that deletes sensors
00147   void destroy(); 
00148   /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
00149   std::list<Sensor*> sensors; 
00150   /// adds a sensor to the list of sensors
00151   void addSensor(Sensor* s) { sensors.push_back(s); }    
00152 } Sphererobot3MassesConf;
00153 
00154 /**
00155    A spherical robot with 3 internal masses, which can slide on their orthogonal axes.
00156    This robot was inspired by Julius Popp (http://sphericalrobots.com)
00157 */
00158 class Sphererobot3Masses : public OdeRobot
00159 {
00160 public:
00161   /// enum for the objects of the robot
00162   /* typedef */ enum objects { Base, Pendular1, Pendular2, Pendular3, Last } ;
00163 
00164 protected:
00165   static const int servono=3;
00166   unsigned int numberaxis;
00167 
00168   Primitive* object[Last]; 
00169   SliderServo* servo[servono];
00170   SliderJoint* joint[servono];
00171   OSGPrimitive* axis[servono];
00172 
00173   Sphererobot3MassesConf conf;
00174   RaySensorBank irSensorBank; ///< a collection of ir sensors  
00175   double transparency;
00176   bool created;
00177 
00178 public:
00179 
00180   /**
00181    *constructor
00182    **/ 
00183   Sphererobot3Masses ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00184                        const Sphererobot3MassesConf& conf, const std::string& name, double transparency=0.5 );
00185 
00186 protected:
00187   /**
00188    *constructor for children
00189    **/ 
00190   Sphererobot3Masses ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00191                        const Sphererobot3MassesConf& conf, 
00192                        const std::string& name, const std::string& revision, double transparency);
00193   /// initialises some internal variables
00194   void init();
00195 public:  
00196   virtual ~Sphererobot3Masses();
00197 
00198         
00199   /// default configuration
00200   static Sphererobot3MassesConf getDefaultConf(){
00201     Sphererobot3MassesConf c;
00202     c.diameter     = 1;
00203     c.spheremass   = .3;// 0.1
00204     c.pendularmass  = 1.0;
00205     c.pendularrange  = 0.20; // range of the slider from center in multiple of diameter [-range,range]
00206     c.motorpowerfactor  = 100;
00207     c.motorsensor = true; 
00208     c.irAxis1=false;
00209     c.irAxis2=false;
00210     c.irAxis3=false;
00211     c.irRing=false;
00212     c.irSide=false;
00213     c.drawIRs=true;
00214     c.irsensorscale=1.5;
00215     c.irCharacter=1;  
00216     c.irSensorTempl=0;
00217     c.motor_ir_before_sensors=false;
00218     c.brake=0;
00219    return c;
00220   }
00221 
00222   virtual void update();
00223 
00224   virtual void place(const osg::Matrix& pose);
00225   
00226   virtual void doInternalStuff(GlobalData& globalData);
00227         
00228   virtual int getSensors ( sensor* sensors, int sensornumber );
00229         
00230   virtual void setMotors ( const motor* motors, int motornumber );
00231         
00232   virtual int getMotorNumber();
00233   
00234   virtual int getSensorNumber();
00235         
00236   virtual Primitive* getMainPrimitive() const { return object[Base]; }
00237 
00238 protected:
00239 
00240   virtual void create(const osg::Matrix& pose); 
00241   virtual void destroy(); 
00242 
00243 
00244 };
00245 
00246 }
00247 
00248 #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