forcedsphere.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
00003  *    Georg Martius  <georg dot martius at web dot de>                     *
00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #ifndef __FORCESSPHERE_H
00026 #define __FORCESSPHERE_H
00027 
00028 #include "oderobot.h"
00029 #include "sensor.h"
00030 #include "motor.h"
00031 
00032 namespace lpzrobots {
00033 
00034   class Primitive;
00035 
00036   class ForcedSphereConf {
00037   public:
00038     ForcedSphereConf();
00039     ~ForcedSphereConf();
00040     /// deletes sensors
00041     void destroy();
00042     
00043     double radius; //< radius of the sphere
00044     double maxForce; ///< maximal force applied to the sphere
00045     /// if true, the robot is powered to reach the given speed (force is calculated)
00046     bool speedDriven;     
00047     double maxSpeed; ///< maximum speed of the robot when in speedDriven mode
00048     
00049     /// bit mask for selecting the dimensions for the forces (see ForcedSphere::Dimensions)
00050     short drivenDimensions; 
00051     /// whether to use a cylinder as body (like a puck) or the normal sphere
00052     bool cylinderBody; 
00053     /// list of sensors that are mounted at the robot. (e.g.\ AxisOrientationSensor)
00054     std::list<Sensor*> sensors; 
00055     /// adds a sensor to the list of sensors
00056     void addSensor(Sensor* s) { sensors.push_back(s); }    
00057     /// list of motors that are mounted at the robot. (e.g.\ Speaker)
00058     std::list<Motor*> motors; 
00059     /// adds a motor to the list of motors
00060     void addMotor(Motor* m) { motors.push_back(m); }    
00061     
00062   };
00063 
00064   class ForcedSphere : public OdeRobot
00065   {
00066   protected:
00067     Primitive* object[1];
00068     bool created;
00069     ForcedSphereConf conf;
00070 
00071   public:
00072   
00073     enum Dimensions { X = 1, Y = 2, Z = 4 };
00074 
00075     /**
00076      * constructor
00077      * 
00078      * use getDefaultConf() to obtain a configuration with default values, which can be altered 
00079      *  to personal needs.
00080      **/ 
00081     ForcedSphere ( const OdeHandle& odeHandle, const OsgHandle& osgHandle,
00082                    const ForcedSphereConf& ForcedSphereConf, const std::string& name);
00083   
00084     virtual ~ForcedSphere();
00085         
00086     static ForcedSphereConf getDefaultConf(){
00087       ForcedSphereConf c;
00088       c.radius = 1;
00089       c.maxForce = 1;     
00090       c.drivenDimensions = X | Y;
00091       c.cylinderBody = false;
00092       c.speedDriven=false;
00093       c.maxSpeed = 5;
00094       return c;      
00095     }
00096 
00097     virtual void update();
00098 
00099     virtual void place(const osg::Matrix& pose);
00100   
00101     virtual void doInternalStuff(GlobalData& globalData);
00102         
00103     virtual int getSensors ( sensor* sensors, int sensornumber );
00104     virtual void setMotors ( const motor* motors, int motornumber );
00105     virtual int getMotorNumber();
00106     virtual int getSensorNumber();
00107          
00108     virtual Primitive* getMainPrimitive() const { return object[0]; }
00109 
00110   protected:
00111 
00112     virtual void create(const osg::Matrix& pose); 
00113     virtual void destroy(); 
00114 
00115 
00116   };
00117 
00118 }
00119 
00120 #endif
Generated on Thu Jun 28 14:45:36 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3