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

Generated on Tue Sep 16 22:00:22 2008 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7