Gazebo

World.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 world; all models are collected here
00022  * Author: Andrew Howard and Nate Koenig
00023  * Date: 3 Apr 2007
00024  * SVN: $Id: World.hh 281 2008-03-06 12:00:34Z robotos $
00025  */
00026 
00027 #ifndef WORLD_HH
00028 #define WORLD_HH
00029 
00030 #include <vector>
00031 #include "SingletonT.hh"
00032 #include "Vector3.hh"
00033 #include "Pose3d.hh"
00034 
00035 namespace gazebo
00036 {
00040 
00041 // Forward declarations
00042   class Server;
00043   class SimulationIface;
00044   class Model;
00045   class Geom;
00046   class PhysicsEngine;
00047   class XMLConfigNode;
00048    
00050 /*
00051  * The world class keps a list of all models, handles loading and saving,
00052  * object dynamics and collision detection for contact joints
00053  */
00054 class World : public SingletonT<World>
00055 {
00057   private: World();
00058 
00060   private: ~World();
00061 
00063   public: void Close();
00064 
00068   public: void Load(XMLConfigNode *rootNode, unsigned int serverId);
00069 
00072   public: void Save(XMLConfigNode *node);
00073 
00076   public: int Init();
00077 
00080   public: int Update();
00081 
00084   public: int Fini();
00085 
00088   public: Server *GetGzServer() const;
00089 
00092   public: PhysicsEngine *GetPhysicsEngine() const;
00093 
00098   public: int LoadEntities(XMLConfigNode *node, Model *parent);
00099 
00102   public: void DeleteEntity(const char *name);
00103 
00105   public: Model *GetModelByName(std::string modelName);
00106 
00108   public: std::vector<Model*> &GetModels();
00109 
00111   public: void Reset();
00112 
00114   public: void RegisterGeom(Geom *geom);
00115 
00116     // User control of how the world is viewed 
00117     // If this section grows it may become a model-view structure ...
00119     public: bool GetShowBoundingBoxes();
00120 
00122     public: void SetShowBoundingBoxes(bool show);
00123 
00125     public: bool GetShowJoints();
00126 
00128     public: void SetShowJoints(bool show);
00129 
00131     public: void SetWireframe( bool wire );
00132 
00134     public: bool GetWireframe();
00135 
00137     public: void SetShowPhysics( bool show );
00138 
00140     public: bool GetShowPhysics();
00141 
00143     private: bool showBoundingBoxes;
00144 
00146     private: bool showJoints;
00147 
00148     private: bool showPhysics;
00149 
00150     private: bool wireframe;
00151 
00152 
00157   private: Model *LoadModel(XMLConfigNode *node, Model *parent);
00158 
00162   private: void SetModelPose(Model *model , Pose3d pose);
00163 
00165   private: void UpdateSimulationIface();
00166 
00168   private: PhysicsEngine *physicsEngine;
00169 
00171   private: std::vector< Model* > models;
00172 
00174   private: std::vector< Geom* > geometries;
00175 
00177   private: std::vector< Model* > toAddModels;
00178 
00180   private: std::vector< Model* > toDeleteModels;
00181 
00183   private: Server *server;
00184 
00186   private: SimulationIface *simIface;
00187 
00188   private: friend class DestroyerT<World>;
00189   private: friend class SingletonT<World>;
00190 };
00191 
00192 
00194 }
00195 
00196 #endif

Last updated Aug 04 2007