Robot Simulator of the Robotics Group for Self-Organization of Control: forcedsphere.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# forcedsphere.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 magically driven                                        *
    00025  *                                                                         *
    00026  *   $Log: forcedsphere.h,v $
    00027  *   Revision 1.7  2007/11/07 13:21:15  martius
    00028  *   doInternal stuff changed signature
    00029  *
    00030  *   Revision 1.6  2006/12/21 11:43:05  martius
    00031  *   commenting style for doxygen //< -> ///<
    00032  *   new sensors for spherical robots
    00033  *
    00034  *   Revision 1.5  2006/08/11 15:44:35  martius
    00035  *   has conf now and arbitrary sensors
    00036  *
    00037  *   Revision 1.4  2006/08/08 17:04:46  martius
    00038  *   added new sensor model
    00039  *
    00040  *   Revision 1.3  2006/07/14 12:23:40  martius
    00041  *   selforg becomes HEAD
    00042  *
    00043  *   Revision 1.2.4.5  2006/03/30 12:34:56  martius
    00044  *   documentation updated
    00045  *
    00046  *   Revision 1.2.4.4  2006/01/10 22:25:09  martius
    00047  *   moved to osg
    00048  *
    00049  *
    00050  *                                                                 *
    00051  ***************************************************************************/
    00052
    00053 #ifndef __FORCESSPHERE_H
    00054 #define __FORCESSPHERE_H
    00055
    00056 #include "oderobot.h"
    00057 #include "sensor.h"
    00058 #include "motor.h"
    00059
    00060 namespace lpzrobots {
    00061
    00062   class Primitive;
    00063
    00064   class ForcedSphereConf {
    00065   public:
    00066     ForcedSphereConf();
    00067     ~ForcedSphereConf();
    00068     /// deletes sensors
    00069     void destroy();
    00070
    00071     double radius; //< radius of the sphere
    00072     double maxForce; ///< maximal force applied to the sphere
    00073     /// if true, the robot is powered to reach the given speed (force is calculated)
    00074     bool speedDriven;
    00075     double maxSpeed; ///< maximum speed of the robot when in speedDriven mode
    00076
    00077     /// bit mask for selecting the dimensions for the forces (see ForcedSphere::Dimensions)
    00078     short drivenDimensions;
    00079     /// whether to use a cylinder as body (like a puck) or the normal sphere
    00080     bool cylinderBody;
    00081     /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
    00082     std::list<Sensor*> sensors;
    00083     /// adds a sensor to the list of sensors
    00084     void addSensor(Sensor* s) { sensors.push_back(s); }
    00085     /// list of motors that are mounted at the robot. (e.g.\ Speaker)
    00086     std::list<Motor*> motors;
    00087     /// adds a motor to the list of motors
    00088     void addMotor(Motor* m) { motors.push_back(m); }
    00089
    00090   };
    00091
    00092   class ForcedSphere : public OdeRobot
    00093   {
    00094   protected:
    00095     Primitive* object[1];
    00096     bool created;
    00097     ForcedSphereConf conf;
    00098
    00099   public:
    00100
    00101     enum Dimensions { X = 1, Y = 2, Z = 4 };
    00102
    00103     /**
    00104      * constructor
    00105      *
    00106      * use getDefaultConf() to obtain a configuration with default values, which can be altered
    00107      *  to personal needs.
    00108      **/
    00109     ForcedSphere ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
    00110                    const ForcedSphereConf& ForcedSphereConf, const std::string& name);
    00111
    00112     virtual ~ForcedSphere();
    00113
    00114     static ForcedSphereConf getDefaultConf(){
    00115       ForcedSphereConf c;
    00116       c.radius = 1;
    00117       c.maxForce = 1;
    00118       c.drivenDimensions = X | Y;
    00119       c.cylinderBody = false;
    00120       c.speedDriven=false;
    00121       c.maxSpeed = 5;
    00122       return c;
    00123     }
    00124
    00125     virtual void update();
    00126
    00127     virtual void place(const osg::Matrix& pose);
    00128
    00129     virtual bool collisionCallback(void *data, dGeomID o1, dGeomID o2);
    00130     virtual void doInternalStuff(GlobalData& globalData);
    00131
    00132     virtual int getSensors ( sensor* sensors, int sensornumber );
    00133     virtual void setMotors ( const motor* motors, int motornumber );
    00134     virtual int getMotorNumber();
    00135     virtual int getSensorNumber();
    00136
    00137     virtual Primitive* getMainPrimitive() const { return object[0]; }
    00138
    00139   protected:
    00140
    00141     virtual void create(const osg::Matrix& pose);
    00142     virtual void destroy();
    00143
    00144
    00145   };
    00146
    00147 }
    00148
    00149 #endif