Robotsystem from Robot Group Leipzig: sphererobot3masses.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# 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.1.2.3  2006/03/30 12:34:57  martius
    00028  *   documentation updated
    00029  *
    00030  *   Revision 1.1.2.2  2006/01/10 17:15:44  martius
    00031  *   removed wrong comment
    00032  *
    00033  *   Revision 1.1.2.1  2006/01/10 17:15:16  martius
    00034  *   was sphererobotarms
    00035  *   moved to osg
    00036  *
    00037  *   Revision 1.10.4.3  2005/11/16 11:26:53  martius
    00038  *   moved to selforg
    00039  *
    00040  *   Revision 1.10.4.2  2005/11/15 12:29:27  martius
    00041  *   new selforg structure and OdeAgent, OdeRobot ...
    00042  *
    00043  *   Revision 1.10.4.1  2005/11/14 17:37:18  martius
    00044  *   moved to selforg
    00045  *
    00046  *   Revision 1.10  2005/11/09 13:27:07  martius
    00047  *   irsensorrange
    00048  *
    00049  *   Revision 1.9  2005/11/07 17:04:56  martius
    00050  *   irsensorscale added
    00051  *
    00052  *   Revision 1.8  2005/11/04 14:45:18  martius
    00053  *   GPL added
    00054  *
    00055  *                                                                 *
    00056  ***************************************************************************/
    00057
    00058 #ifndef __SPHEREROBOT3MASSES_H
    00059 #define __SPHEREROBOT3MASSES_H
    00060
    00061 #include "primitive.h"
    00062 #include "joint.h"
    00063 #include "sliderservo.h"
    00064 #include "oderobot.h"
    00065 #include "raysensorbank.h"
    00066
    00067 namespace lpzrobots {
    00068
    00069 typedef struct {
    00070 public:
    00071   double diameter;
    00072   double spheremass;
    00073   double pendulardiameter; /// automatically set
    00074   double pendularmass;
    00075   double pendularrange;
    00076   bool axisZsensor;
    00077   bool axisXYZsensor;
    00078   bool motorsensor;
    00079   bool irAxis1;
    00080   bool irAxis2;
    00081   bool irAxis3;
    00082   bool drawIRs;
    00083   double irsensorscale; /// range of the ir sensors in units of diameter
    00084 } Sphererobot3MassesConf;
    00085
    00086
    00087 class Sphererobot3Masses : public OdeRobot
    00088 {
    00089 public:
    00090   typedef enum objects { Base, Pendular1, Pendular2, Pendular3, Last } ;
    00091
    00092 protected:
    00093   static const int servono=3;
    00094
    00095   SliderServo* servo[servono];
    00096   SliderJoint* joint[servono];
    00097   OSGPrimitive* axis[servono];
    00098   double transparency;
    00099   bool created;
    00100
    00101   Sphererobot3MassesConf conf;
    00102   RaySensorBank irSensorBank; // a collection of ir sensors
    00103
    00104 public:
    00105   Primitive* object[Last];
    00106
    00107
    00108   /**
    00109    *constructor
    00110    **/
    00111   Sphererobot3Masses ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00112                        const Sphererobot3MassesConf& conf, const char* name, double transparency=0.5 );
    00113
    00114   virtual ~Sphererobot3Masses();
    00115
    00116   static Sphererobot3MassesConf getDefaultConf(){
    00117     Sphererobot3MassesConf c;
    00118     c.diameter     = 1;
    00119     c.spheremass   = 0.1;
    00120     c.pendularmass  = 1.0;
    00121     c.pendularrange  = 0.25; // range of the slider from center in multiple of diameter [-range,range]
    00122     c.axisZsensor = true;
    00123     c.axisXYZsensor = false;
    00124     c.motorsensor = false;
    00125     c.irAxis1=false;
    00126     c.irAxis2=false;
    00127     c.irAxis3=false;
    00128     c.drawIRs=true;
    00129     c.irsensorscale=2;
    00130     return c;
    00131   }
    00132
    00133   /// update all primitives and joints
    00134   virtual void update();
    00135
    00136   /** sets the pose of the vehicle
    00137       @param pose desired 4x4 pose matrix
    00138   */
    00139   virtual void place(const osg::Matrix& pose);
    00140
    00141   /**
    00142    *This is the collision handling function for snake robots.
    00143    *This overwrides the function collisionCallback of the class robot.
    00144    *@param data
    00145    *@param o1 first geometrical object, which has taken part in the collision
    00146    *@param o2 second geometrical object, which has taken part in the collision
    00147    *@return true if the collision was threated  by the robot, false if not
    00148    **/
    00149   virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00150   /** this function is called in each timestep. It should perform robot-internal checks,
    00151       like space-internal collision detection, sensor resets/update etc.
    00152       @param globalData structure that contains global data from the simulation environment
    00153    */
    00154   virtual void doInternalStuff(const GlobalData& globalData);
    00155
    00156   /**
    00157    *Writes the sensor values to an array in the memory.
    00158    *@param sensors pointer to the array
    00159    *@param sensornumber length of the sensor array
    00160    *@return number of actually written sensors
    00161    **/
    00162   virtual int getSensors ( sensor* sensors, int sensornumber );
    00163
    00164   /**
    00165    *Reads the actual motor commands from an array, an sets all motors of the snake to this values.
    00166    *It is an linear allocation.
    00167    *@param motors pointer to the array, motor values are scaled to [-1,1]
    00168    *@param motornumber length of the motor array
    00169    **/
    00170   virtual void setMotors ( const motor* motors, int motornumber );
    00171
    00172   /**
    00173    *Returns the number of motors used by the snake.
    00174    *@return number of motors
    00175    **/
    00176   virtual int getMotorNumber();
    00177
    00178   /**
    00179    *Returns the number of sensors used by the robot.
    00180    *@return number of sensors
    00181    **/
    00182   virtual int getSensorNumber();
    00183
    00184
    00185 protected:
    00186   /** the main object of the robot, which is used for position and speed tracking */
    00187   virtual Primitive* getMainPrimitive() const { return object[Base]; }
    00188
    00189   /** creates vehicle at desired pose
    00190       @param pose 4x4 pose matrix
    00191   */
    00192   virtual void create(const osg::Matrix& pose);
    00193   virtual void destroy();
    00194
    00195
    00196 };
    00197
    00198 }
    00199
    00200 #endif