Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimSystem.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
45 #ifndef __SIM_SYSTEM_H__
46 #define __SIM_SYSTEM_H__
47 
48 // Scene graph
49 #include "System.h"
50 #include "MengeException.h"
51 
52 namespace Menge {
53 
54  // forward declarations
55  class VisAgent;
56 
57  namespace Agents {
58  class SimulatorInterface;
59  class SCBWriter;
60  }
61 
62  namespace SceneGraph {
63  class GLScene;
64  }
65 
66  namespace BFSM {
67  class FSM;
68  }
69 
70  // Exceptions for the system
74  class MENGE_API SimSystemException : public virtual Menge::MengeException {
75  public:
80 
86  SimSystemException( const std::string & s ): Menge::MengeException(s) {}
87  };
88 
93  public:
98 
105  };
106 
107 
115  class MENGE_API SimSystem : public SceneGraph::System {
116  public:
117 
124  SimSystem( bool visualize );
125 
134  SimSystem( bool visualize, float duration );
135 
139  ~SimSystem();
140 
148  inline void setMaxDuration( float duration ) {_maxDuration = duration; }
149 
157  virtual bool updateScene( float time );
158 
165  bool isFinished() const;
166 
181  void setSimulator( Agents::SimulatorInterface * sim, BFSM::FSM * fsm );
182 
183  // Sets the simulator/fsm for the visualizer - prepares an scb file for writing (with the provided version)
201  void setSimulator( Agents::SimulatorInterface * sim, BFSM::FSM * fsm, const std::string & outFileName, const std::string & scbVersion );
202 
208  void addObstacleToScene( SceneGraph::GLScene * scene );
209 
215  virtual void addAgentsToScene( SceneGraph::GLScene * scene );
216 
222  void populateScene( SceneGraph::GLScene * scene );
223 
224 
230  virtual void updateAgentPosition( int agtCount );
231 
237  inline VisAgent ** getVisAgents() { return _visAgents; }
238 
244  size_t getAgentCount() const;
245 
246  protected:
247 
252  bool _forVis;
253 
258 
264 
269 
275 
279  float _lastUpdate;
280 
285 
290  };
291 } // namespace Menge
292 #endif // __VIS_RVO_SIM_H__
The mechanism for evolving a scene w.r.t. time.
An animation system. Responsible for updating the scene based based on increasing time values...
Definition: System.h:83
Templated class for performing simulation.
Definition: SimSystem.h:115
BFSM::FSM * _fsm
The behavior finite state machine for the simulator.
Definition: SimSystem.h:268
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
float _maxDuration
Maximum length of simulation time to compute (in simulation time).
Definition: SimSystem.h:289
SimSystemFatalException(const std::string &s)
Constructor with message.
Definition: SimSystem.h:104
Generic exception for the SimSystem.
Definition: SimSystem.h:74
float _lastUpdate
The global time of last system update.
Definition: SimSystem.h:279
bool _forVis
Determines if the system is actually for driving a visual scene.
Definition: SimSystem.h:252
The fatal SimSystem exception.
Definition: SimSystem.h:92
The base definition for exceptions in Menge.
VisAgent ** _visAgents
The visualization agents the system is responsible for updating.
Definition: SimSystem.h:263
SimSystemFatalException()
Default constructor.
Definition: SimSystem.h:97
The basic simulator interface required by the fsm.
Definition: SimulatorInterface.h:66
VisAgent ** getVisAgents()
Returns a pointer to the visualization agents.
Definition: SimSystem.h:237
SimSystemException()
Default constructor.
Definition: SimSystem.h:79
The SceneGraph (SceneGraph) name space, containing all elements to use in a SceneGraph.
Agents::SCBWriter * _scbWriter
The optional scb writer (if an output file has been successfully specified.
Definition: SimSystem.h:274
SimSystemException(const std::string &s)
Constructor with message.
Definition: SimSystem.h:86
Base exception class for menge operations.
Definition: MengeException.h:58
Agents::SimulatorInterface * _sim
Simulator to run and (possibly) visualize.
Definition: SimSystem.h:257
Templated class for the behavior finite state machine.
Definition: FSM.h:126
bool _isRunning
Indicates if the simulation is running.
Definition: SimSystem.h:284
The class which contains the entire drawable scene.
Definition: GLScene.h:72
Base class for fatal exceptions.
Definition: MengeException.h:99
Class responsible for writing the agent state of the simulator and fsm into a file.
Definition: SCBWriter.h:145
The basic agent visualization class: a selectable cylinder.
Definition: VisAgent.h:66
The namespace contains the Behavior Finite State Machine (BFSM) definition.
The namespace that contains the basic simulation mechanisms.
void setMaxDuration(float duration)
Sets the maximum length allowed for the simulation to run.
Definition: SimSystem.h:148