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