Gazebo

Simulator.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: The Simulator; Top level managing object
00022  * Author: Jordi Polo
00023  * Date: 3 Jan 2008
00024  */
00025 
00026 #ifndef SIMULATOR_HH
00027 #define SIMULATOR_HH
00028 
00029 #include <string>
00030 
00031 #include "SingletonT.hh"
00032 
00033 namespace gazebo
00034 {
00038 
00039 // Forward declarations
00040   class Gui;
00041   class Server;
00042   class SimulationIface;
00043   class XMLConfig;
00044   class XMLConfigNode;
00045 
00047 /*
00048  * Top level class: Takes care of World Gui SimulatorIface and Server
00049  * 
00050  */
00051   class Simulator : public SingletonT<Simulator>
00052   {
00054     private: Simulator();
00055 
00057     private: ~Simulator();
00058 
00060     public: void Close();
00061 
00063     public: void Load(const std::string &worldFileName, unsigned int serverId );
00064 
00066     public: void Save(const std::string& filename=std::string());
00067 
00069     public: int Init( );
00070 
00072     public: void Fini( );
00073 
00075     public: void MainLoop();
00076 
00078     public: Gui *GetUI();
00079 
00081     public: bool IsPaused() const;
00082 
00084     public: unsigned long GetIterations();
00085 /*
00087     public: static void SetIterations(unsigned long count);
00088 
00090     public: static void IncIterations();
00091 */
00094     public: double GetSimTime() const;
00095 
00098     public: double GetPauseTime() const;
00099 
00102     public: double GetStartTime() const;
00103 
00106     public: double GetRealTime() const;
00107 
00110     public: double GetWallTime() const;
00111 
00112     public: void LoadGui(XMLConfigNode *rootNode);
00113     public: void SaveGui(XMLConfigNode *node);
00114 
00115 
00116     //User Iteractions
00118     public: void SetUserQuit();
00119 
00121     public: bool GetUserPause();
00122 
00124     public: void SetUserPause(bool pause);
00125     
00127     public: bool GetUserStep();
00128 
00130     public: void SetUserStep( bool step );
00131 
00133     public: bool GetUserStepInc();
00134 
00136     public: void SetUserStepInc(bool step);
00137 
00138   
00140     private:gazebo::XMLConfig *xmlFile;
00141 
00143     private: Gui *gui;
00144 
00145 
00147     private: bool loaded;
00148 
00150     private: bool pause;
00151 
00153     private: unsigned long iterations;
00154 
00156     private: double simTime, pauseTime, startTime;
00157     private: double prevPhysicsTime, prevRenderTime;
00158 
00159     // UserIteractions 
00161     private: bool userPause;
00162 
00164     private: bool userStep;
00165 
00168     private: bool userStepInc;
00169 
00170     //The user has somewhat signaled the end of the program
00171     private: bool userQuit;
00172 
00173     //Singleton implementation
00174     private: friend class DestroyerT<Simulator>;
00175     private: friend class SingletonT<Simulator>;
00176 };
00177 
00179 }
00180 
00181 #endif

Last updated Aug 04 2007