randomobstacles.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 #ifndef __RANDOMOBSTACLES_H
00025 #define __RANDOMOBSTACLES_H
00026 
00027 #include "abstractobstacle.h"
00028 #include "abstractground.h"
00029 #include "pos.h"
00030 
00031 namespace lpzrobots {
00032 
00033   struct RandomObstaclesConf {
00034     Pos area; ///< zero centered, use setPose to shift around (z() component is the height)
00035     osg::Matrix pose;
00036     Pos minSize;
00037     Pos maxSize;
00038     double minDensity;
00039     double maxDensity;
00040     int boxRelFreq;   
00041     int sphereRelFreq;
00042     int capRelFreq;
00043   };
00044 
00045   /**
00046    * Passive random obstacles:
00047    * with spawn and remove obstacles can be created and removed.
00048    * Add an instance to global.obstacles to customize the creation
00049    *  otherwise a default version is used (though dependend on the playground)
00050    */
00051   class RandomObstacles : public AbstractObstacle {
00052     
00053     int index;
00054     RandomObstaclesConf conf;
00055   public:
00056     enum OType {Box, Sphere, Caps, ORandom};
00057     enum SType {Metal, Plastic, Rubber, Foam, SRandom};
00058     
00059     /// creates a default configuration, optionally with the size and position of the ground
00060     static RandomObstaclesConf getDefaultConf(AbstractGround* ground = 0){
00061       RandomObstaclesConf c;
00062       if(ground){
00063         c.area  = Pos(ground->getGroundLength()/2, ground->getGroundWidth()/2, 5)*0.95;
00064         c.pose =  ground->getPose();
00065       }else{
00066         c.area    = Pos(10,10,4);
00067         c.pose    = osg::Matrix::translate(0,0,0);
00068       }
00069       c.minSize = Pos(.5,.5,.5);
00070       c.maxSize = Pos(2,2,2);
00071       c.minDensity=1;
00072       c.maxDensity=10;
00073       c.boxRelFreq=5;
00074       c.sphereRelFreq=1;
00075       c.capRelFreq=1;
00076       return c;
00077     }
00078 
00079     RandomObstacles(const OdeHandle& odeHandle, const OsgHandle& osgHandle, 
00080                     const RandomObstaclesConf& conf = getDefaultConf());
00081 
00082   
00083     virtual void setPose(const osg::Matrix& pose);
00084 
00085     virtual Primitive* getMainPrimitive() const;
00086 
00087     virtual void create(){};
00088 
00089     virtual void remove(bool all = false);
00090 
00091     virtual void spawn(OType type = ORandom , SType subtype = SRandom);
00092 
00093   };
00094 
00095 }
00096 
00097 #endif
00098 
00099 
00100 
Generated on Thu Jun 28 14:45:37 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3