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
globaldata.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 __GLOBALDATA_H
25 #define __GLOBALDATA_H
26 
27 #include <vector>
28 #include <map>
29 #include "odehandle.h"
30 #include "odeconfig.h"
31 #include "sound.h"
32 #include "tmpobject.h"
33 #include <selforg/plotoption.h>
34 #include <selforg/globaldatabase.h>
35 #include <selforg/backcallervector.h>
36 
37 class Configurable;
38 
39 namespace lpzrobots {
40 
41  class OdeAgent;
42  class AbstractObstacle;
43  class Primitive;
44  class OSGPrimitive;
45 
46  typedef std::vector<AbstractObstacle*> ObstacleList;
49  typedef std::list<Sound> SoundList;
50  typedef std::list<PlotOption> PlotOptionList;
51  typedef std::multimap<double, TmpObject* > TmpObjectMap;
52  typedef std::list< std::pair<double, TmpObject*> > TmpObjectList;
53 
54  /**
55  Data structure holding all essential global information.
56  */
57  class GlobalData : public GlobalDataBase {
58  public:
60  sim_step = 0;
61  environment = 0;
62  }
63 
64  virtual ~GlobalData() {}
65 
69  Primitive* environment; /// < this is used to be able to attach objects to the static environment
70 
71  // Todo: the sound visualization could be done with the new TmpObjects
72  SoundList sounds; ///< sound space
73 
74  PlotOptionList plotoptions; ///< plotoptions used for new agents
75  std::list<Configurable*> globalconfigurables; ///< global configurables plotted by all agents
76 
77  double time;
78  long int sim_step; ///< time steps since start
79 
80  /// returns the list of all agents
81  virtual AgentList& getAgents();
82 
83 
84  /// adds a temporary display item with given life duration in sec
85  virtual void addTmpObject(TmpObject* i, double duration);
86 
87  /// called by Simulation to initialize tmp objects
88  virtual void initializeTmpObjects(const OdeHandle& odeHandle,
89  const OsgHandle& osgHandle);
90  /// called by Simulation to update tmp objects
91  virtual void updateTmpObjects(const OsgHandle& osgHandle);
92 
93  /** called by Simulation to removes all expired sounds and temporary objects.
94  Optionally a time can be specified otherwise the internal time is used.
95  */
96  virtual void removeExpiredObjects(double time = -1);
97 
98  /** removes a particular temporary display item even if it is not yet expired
99  @return true if it was deleted (found) */
100  virtual bool removeTmpObject(TmpObject* i);
101 
102 
103  private:
104 
105  TmpObjectList uninitializedTmpObjects;
106  TmpObjectMap tmpObjects;
107  AgentList baseAgents;
108  };
109 
110 }
111 
112 #endif
Configurable::configurableList ConfigList
Definition: globaldata.h:47
Data structure for accessing the ODE.
Definition: odehandle.h:44
virtual void removeExpiredObjects(double time=-1)
called by Simulation to removes all expired sounds and temporary objects.
Definition: globaldata.cpp:74
std::list< std::pair< double, TmpObject * > > TmpObjectList
Definition: globaldata.h:52
PlotOptionList plotoptions
plotoptions used for new agents
Definition: globaldata.h:74
std::list< Sound > SoundList
Definition: globaldata.h:49
Interface class for graphic primitives like spheres, boxes, and meshes, which can be drawn by OSG...
Definition: osgprimitive.h:62
double time
Definition: globaldata.h:77
std::vector< AbstractObstacle * > ObstacleList
Definition: globaldata.h:44
std::vector< Configurable * > configurableList
Definition: configurable.h:119
SoundList sounds
< this is used to be able to attach objects to the static environment
Definition: globaldata.h:72
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
virtual void addTmpObject(TmpObject *i, double duration)
adds a temporary display item with given life duration in sec
Definition: globaldata.cpp:31
long int sim_step
time steps since start
Definition: globaldata.h:78
virtual AgentList & getAgents()
returns the list of all agents
Definition: globaldata.cpp:98
virtual ~GlobalData()
Definition: globaldata.h:64
The class $name holds the configurable parameters of the simulation environment.
Definition: odeconfig.h:35
std::list< PlotOption > PlotOptionList
Definition: odeagent.h:56
Definition: globaldatabase.h:39
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual void initializeTmpObjects(const OdeHandle &odeHandle, const OsgHandle &osgHandle)
called by Simulation to initialize tmp objects
Definition: globaldata.cpp:38
OdeConfig odeConfig
Definition: globaldata.h:66
Data structure holding all essential global information.
Definition: globaldata.h:57
this is the base-class for objects that exist temporarily like some indicator of manipulation or a me...
Definition: tmpobject.h:37
std::multimap< double, TmpObject * > TmpObjectMap
Definition: globaldata.h:51
virtual void updateTmpObjects(const OsgHandle &osgHandle)
called by Simulation to update tmp objects
Definition: globaldata.cpp:49
Abstact class for configurable objects.
Definition: configurable.h:81
GlobalData()
Definition: globaldata.h:59
BackCallerVector< OdeAgent * > OdeAgentList
Definition: globaldata.h:48
std::vector< Agent * > AgentList
Definition: globaldatabase.h:37
ObstacleList obstacles
Definition: globaldata.h:67
virtual bool removeTmpObject(TmpObject *i)
removes a particular temporary display item even if it is not yet expired
Definition: globaldata.cpp:58
Primitive * environment
Definition: globaldata.h:69
std::list< Configurable * > globalconfigurables
global configurables plotted by all agents
Definition: globaldata.h:75
OdeAgentList agents
Definition: globaldata.h:68