Model.hh
Go to the documentation of this file.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: Base class for all models 00022 * Author: Andrew Howard 00023 * Date: 8 May 2003 00024 * CVS: $Id: Model.hh,v 1.36 2006/02/22 14:58:57 natepak Exp $ 00025 */ 00026 00027 #ifndef MODEL_HH 00028 #define MODEL_HH 00029 00030 #include <ode/ode.h> 00031 #include "Vector.hh" 00032 00033 #include "GL/gl.h" 00034 00035 // Forward declaraions 00036 class World; 00037 class WorldFile; 00038 class WorldFileNode; 00039 class Body; 00040 class Geom; 00041 class Joint; 00042 class HingeJoint; 00043 class RenderOptions; 00044 00045 00046 class Model 00047 { 00048 // Default constructor 00049 public: Model( World *world ); 00050 00051 // Destructor 00052 public: virtual ~Model(); 00053 00054 // Load default values for the entire model. This calls Model::Load 00055 public: int MasterLoad( WorldFile *file, WorldFileNode *node ); 00056 00057 // Load the model 00058 public: virtual int Load( WorldFile *file, WorldFileNode *node ) = 0; 00059 00060 // Initialize the model 00061 public: virtual int Init( WorldFile *file, WorldFileNode *node ) = 0; 00062 00063 // Finalize the model 00064 public: virtual int Fini() = 0; 00065 00066 // Update the model state 00067 public: virtual void Update( double step ) = 0; 00068 00069 // Called for all models. This calls Update 00070 public: void MasterUpdate( double step ); 00071 00072 // Get the model pose (global frame) 00073 public: GzPose GetPose(); 00074 00075 // Set the model pose (global frame) 00076 public: void SetPose( GzPose pose ); 00077 00078 // Log the current pose of the canonical body 00079 public: void LogPose(); 00080 00081 // Set our parent 00082 public: void SetParent(Model *parent, Body *parentBody); 00083 00084 // Attach this model to another. 00085 public: void Attach(); 00086 00087 // Detach this model from its parent. 00088 public: void Detach(); 00089 00090 // Add a body to this model; exactly one body must be used as the 00091 // canonical body 00092 protected: void AddBody(Body *body, bool canonical = false); 00093 00094 // Get the canonical body for this model (returns canonical body by 00095 // default) 00096 public: Body *GetBody(const char *bodyName = NULL); 00097 00098 // Get the list of bodies 00099 public: int GetNumBodies() {return this->bodyCount;} 00100 public: Body **GetBodies() {return this->bodies;} 00101 00102 // Set the id of the model 00103 public: void SetId(const char* id); 00104 00105 // Get the id of the model 00106 public: const char* GetId() const {return this->id;} 00107 00108 // Set the name of the model 00109 public: void SetName(const char *name); 00110 00111 // Get the name of the model 00112 public: const char* GetName(); 00113 00114 // Set the Pick id of the model 00115 public: void SetPickId( GLuint id ); 00116 00117 // Get the Pick id of the model 00118 public: GLuint GetPickId() const; 00119 00120 // Return the integer ID of this model 00121 public: int GetIntId() const; 00122 00123 // Return the integer ID of this model's parent 00124 public: int GetParentIntId() const; 00125 00126 00127 // Draw this model 00128 public: virtual void Render( int pass, RenderOptions *renderOpt ); 00129 00130 // The world 00131 public: World *world; 00132 00133 // The node this was loaded from 00134 public: WorldFileNode *node; 00135 00136 // Our parent model 00137 public: Model *parent; 00138 00139 // Our parent body 00140 public: Body *parentBody; 00141 00143 public: GzPose initPose; 00144 00145 00146 // The models id 00147 private: char *id; 00148 00149 // The name of this model 00150 private: char *name; 00151 00152 // Joint attaching us to parent body (for ODE bodies) 00153 public: HingeJoint *joint; 00154 00155 // Pose relative to parent body (for dummy bodies) 00156 public: GzPose relPose; 00157 00158 // Flag is true if this is a fixed object 00159 public: bool fixed; 00160 00161 // The space for all the bodies in this model 00162 public: dSpaceID modelSpaceId; 00163 00164 // A list of bodies making up this model 00165 protected: int bodyCount, bodyMaxCount; 00166 protected: Body **bodies; 00167 00168 // The canonical body (reference for the model cs) 00169 private: Body *canonicalBody; 00170 00171 // A list of joints making up this model 00172 private: int jointCount, jointMaxCount; 00173 private: Joint **joints; 00174 00175 private: GLuint pickId; 00176 private: static GLuint pickIdMaster; 00177 00178 private: bool gravityMode; 00179 private: bool enable; 00180 00181 // Integer based ID 00182 private: static int integerIdCounter; 00183 private: int integerId; 00184 00185 // TESTING: 00186 public: bool logPoses; 00187 public: int poseCount, poseMaxCount; 00188 public: GzPose *poses; 00189 }; 00190 00191 #endif 00192