Robotsystem from Robot Group Leipzig: sphererobot.h Source File

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

- File List
- File Members

# sphererobot.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  *   $Log: sphererobot.h,v $
    00023  *   Revision 1.9.4.6  2006/03/30 12:34:57  martius
    00024  *   documentation updated
    00025  *
    00026  *   Revision 1.9.4.5  2006/01/10 15:10:24  martius
    00027  *   fine tuning, fuer controllinterval 1
    00028  *   still not transparent
    00029  *
    00030  *   Revision 1.9.4.4  2005/12/30 22:51:45  martius
    00031  *   moved to osg
    00032  *
    00033  *   Revision 1.9.4.3  2005/11/16 11:26:53  martius
    00034  *   moved to selforg
    00035  *
    00036  *   Revision 1.9.4.2  2005/11/15 12:29:27  martius
    00037  *   new selforg structure and OdeAgent, OdeRobot ...
    00038  *
    00039  *   Revision 1.9.4.1  2005/11/14 17:37:18  martius
    00040  *   moved to selforg
    00041  *
    00042  *   Revision 1.9  2005/11/09 13:24:42  martius
    00043  *   added GPL
    00044  *
    00045  *                                                                 *
    00046  ***************************************************************************/
    00047
    00048 #ifndef __SPHEREROBOT_H
    00049 #define __SPHEREROBOT_H
    00050
    00051 #include "oderobot.h"
    00052 #include "sliderservo.h"
    00053
    00054 namespace lpzrobots {
    00055
    00056   class Primitive;
    00057   class Joint;
    00058   class SliderJoint;
    00059   class SliderServo;
    00060
    00061   typedef struct {
    00062   public:
    00063     double diameter;
    00064     double spheremass;
    00065     double pendulardiameter;
    00066     double pendularmass;
    00067     double slidermass;
    00068     double sliderrange;
    00069
    00070     double force;      // forcefactor of the servo power (1 is usual)
    00071     double hingeRange; //the angle (in rad) of the hinges that connect pendular with poles
    00072   } SphererobotConf;
    00073
    00074
    00075   /**
    00076    *This is a class, which models a snake like robot. It consists of a number of equal elements, each linked
    00077    *by a joint. This class is based upon the class roboter by the same author.
    00078    *@author Marcel Kretschmann
    00079    *@version beta
    00080    **/
    00081   class Sphererobot : public OdeRobot
    00082   {
    00083   public:
    00084     typedef enum objects { Base, Pendular, Pole1Bot, Pole2Bot, Pole3Bot,
    00085                            Pole1Top , Pole2Top, Pole3Top, Last};
    00086
    00087   protected:
    00088     const static int sensorno = 9;
    00089
    00090     SphererobotConf conf;
    00091     bool created;
    00092
    00093   public:
    00094     SliderServo* servo[3];
    00095     Primitive* object[Last];
    00096     SliderJoint* slider[3];
    00097     Joint* joint[6];
    00098
    00099   public:
    00100
    00101     Sphererobot ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00102                   const SphererobotConf& conf, const char* name );
    00103
    00104     virtual ~Sphererobot();
    00105
    00106     static SphererobotConf getDefaultConf(){
    00107       SphererobotConf c;
    00108       c.diameter     = 1;
    00109       c.spheremass   = 0.2;
    00110       c.pendulardiameter = 0.2;
    00111       c.pendularmass = 1.0;
    00112       c.slidermass   = 0.005;
    00113       c.sliderrange  = 0.1; // range of the slider from center in multiple of diameter [-range,range]
    00114       c.force        = 1;
    00115       c.hingeRange   = M_PI/180*30;
    00116       return c;
    00117     }
    00118
    00119     /// update the subcomponents
    00120     virtual void update();
    00121
    00122     /** sets the pose of the vehicle
    00123         @param pose desired 4x4 pose matrix
    00124     */
    00125     virtual void place(const osg::Matrix& pose);
    00126
    00127     /**
    00128      *This is the collision handling function for snake robots.
    00129      *This overwrides the function collisionCallback of the class robot.
    00130      *@param data
    00131      *@param o1 first geometrical object, which has taken part in the collision
    00132      *@param o2 second geometrical object, which has taken part in the collision
    00133      *@return true if the collision was threated  by the robot, false if not
    00134      **/
    00135     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00136     /** this function is called in each timestep. It should perform robot-internal checks,
    00137         like space-internal collision detection, sensor resets/update etc.
    00138         @param globalData structure that contains global data from the simulation environment
    00139     */
    00140     virtual void doInternalStuff(const GlobalData& globalData);
    00141
    00142     /**
    00143      *Writes the sensor values to an array in the memory.
    00144      *@param sensors pointer to the array
    00145      *@param sensornumber length of the sensor array
    00146      *@return number of actually written sensors
    00147      **/
    00148     virtual int getSensors ( sensor* sensors, int sensornumber );
    00149
    00150     /**
    00151      *Reads the actual motor commands from an array, an sets all motors of the snake to this values.
    00152      *It is an linear allocation.
    00153      *@param motors pointer to the array, motor values are scaled to [-1,1]
    00154      *@param motornumber length of the motor array
    00155      **/
    00156     virtual void setMotors ( const motor* motors, int motornumber );
    00157
    00158     /**
    00159      *Returns the number of motors used by the snake.
    00160      *@return number of motors
    00161      **/
    00162     virtual int getMotorNumber();
    00163
    00164     /**
    00165      *Returns the number of sensors used by the robot.
    00166      *@return number of sensors
    00167      **/
    00168     virtual int getSensorNumber();
    00169
    00170     /** returns a vector with the positions of all segments of the robot
    00171     */
    00172     virtual int getSegmentsPosition(vector<Position> &poslist);
    00173
    00174   protected:
    00175     /** the main object of the robot, which is used for position and speed tracking */
    00176     virtual Primitive* getMainPrimitive() const { return object[Base]; }
    00177
    00178     /** creates vehicle at desired pose
    00179         @param pose 4x4 pose matrix
    00180     */
    00181     virtual void create(const osg::Matrix& pose);
    00182     virtual void destroy();
    00183
    00184
    00185
    00186   };
    00187
    00188 }
    00189
    00190 #endif