Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
randomobstacles.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __RANDOMOBSTACLES_H
25 #define __RANDOMOBSTACLES_H
26 
27 #include "abstractobstacle.h"
28 #include "abstractground.h"
29 #include "pos.h"
30 
31 namespace lpzrobots {
32 
34  Pos area; ///< zero centered, use setPose to shift around (z() component is the height)
38  double minDensity;
39  double maxDensity;
40  int boxRelFreq;
43  };
44 
45  /**
46  * Passive random obstacles:
47  * with spawn and remove obstacles can be created and removed.
48  * Add an instance to global.obstacles to customize the creation
49  * otherwise a default version is used (though dependend on the playground)
50  */
52 
53  int index;
55  public:
58 
59  /// creates a default configuration, optionally with the size and position of the ground
62  if(ground){
63  c.area = Pos(ground->getGroundLength()/2, ground->getGroundWidth()/2, 5)*0.95;
64  c.pose = ground->getPose();
65  }else{
66  c.area = Pos(10,10,4);
67  c.pose = osg::Matrix::translate(0,0,0);
68  }
69  c.minSize = Pos(.5,.5,.5);
70  c.maxSize = Pos(2,2,2);
71  c.minDensity=1;
72  c.maxDensity=10;
73  c.boxRelFreq=5;
74  c.sphereRelFreq=1;
75  c.capRelFreq=1;
76  return c;
77  }
78 
80  const RandomObstaclesConf& conf = getDefaultConf());
81 
82 
83  virtual void setPose(const osg::Matrix& pose);
84 
85  virtual Primitive* getMainPrimitive() const;
86 
87  virtual void create(){};
88 
89  virtual void remove(bool all = false);
90 
91  virtual void spawn(OType type = ORandom , SType subtype = SRandom);
92 
93  };
94 
95 }
96 
97 #endif
98 
99 
100 
virtual void spawn(OType type=ORandom, SType subtype=SRandom)
Definition: randomobstacles.cpp:68
Data structure for accessing the ODE.
Definition: odehandle.h:44
OsgHandle osgHandle
Definition: abstractobstacle.h:174
int sphereRelFreq
Definition: randomobstacles.h:41
Abstract class (interface) for obstacles.
Definition: abstractobstacle.h:46
Matrixd Matrix
Definition: osgforwarddecl.h:47
SType
Definition: randomobstacles.h:57
Definition: randomobstacles.h:33
OdeHandle odeHandle
Definition: abstractobstacle.h:173
Definition: pos.h:36
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Definition: randomobstacles.h:56
Definition: randomobstacles.h:57
Definition: randomobstacles.h:57
int boxRelFreq
Definition: randomobstacles.h:40
Pos maxSize
Definition: randomobstacles.h:37
Definition: randomobstacles.h:56
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual void setPose(const osg::Matrix &pose)
sets position of the obstacle and creates/recreates obstacle if necessary
Definition: randomobstacles.cpp:44
osg::Matrix pose
Definition: abstractobstacle.h:170
double maxDensity
Definition: randomobstacles.h:39
Definition: randomobstacles.h:57
Definition: randomobstacles.h:56
int capRelFreq
Definition: randomobstacles.h:42
Definition: randomobstacles.h:57
Pos minSize
Definition: randomobstacles.h:36
osg::Matrix pose
Definition: randomobstacles.h:35
Definition: randomobstacles.h:56
double minDensity
Definition: randomobstacles.h:38
Definition: abstractground.h:36
Pos area
zero centered, use setPose to shift around (z() component is the height)
Definition: randomobstacles.h:34
RandomObstacles(const OdeHandle &odeHandle, const OsgHandle &osgHandle, const RandomObstaclesConf &conf=getDefaultConf())
Definition: randomobstacles.cpp:36
Passive random obstacles: with spawn and remove obstacles can be created and removed.
Definition: randomobstacles.h:51
static RandomObstaclesConf getDefaultConf(AbstractGround *ground=0)
creates a default configuration, optionally with the size and position of the ground ...
Definition: randomobstacles.h:60
OType
Definition: randomobstacles.h:56
Definition: randomobstacles.h:57
int c
Definition: hexapod.cpp:56
virtual Primitive * getMainPrimitive() const
return the "main" primitive of the obtactle. The meaning of "main" is arbitrary
Definition: randomobstacles.cpp:49
virtual void create()
overload this function to create the obstactle. All primitives should go into the list "obst" ...
Definition: randomobstacles.h:87