Home
FAQ
Player
Utilities
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

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.29 2005/03/23 03:04:30 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 
00044 
00045 class Model
00046 {
00047   // Default constructor
00048   public: Model( World *world );
00049 
00050   // Destructor
00051   public: virtual ~Model();
00052 
00053   // Load the model
00054   public: virtual int Load( WorldFile *file, WorldFileNode *node ) = 0;
00055   
00056   // Initialize the model
00057   public: virtual int Init( WorldFile *file, WorldFileNode *node ) = 0;
00058 
00059   // Finalize the model
00060   public: virtual int Fini() = 0;
00061 
00062   // Update the model state
00063   public: virtual void Update( double step ) = 0;
00064 
00065   // Get the model pose (global frame)
00066   public: GzPose GetPose();
00067 
00068   // Set the model pose (global frame)
00069   public: void SetPose( GzPose pose );
00070 
00071   // Set our parent
00072   public: void SetParent(Model *parent, Body *parentBody);
00073 
00074   // Attach this model to another. 
00075   public: void Attach();
00076 
00077   // Detach this model from its parent.
00078   public: void Detach();
00079 
00080   // Add a body to this model; exactly one body must be used as the
00081   // canonical body
00082   protected: void AddBody(Body *body, bool canonical = false);
00083 
00084   // Get the canonical body for this model (returns canonical body by
00085   // default)
00086   public: Body *GetBody(const char *bodyName = NULL);
00087 
00088   // Get the list of bodies
00089   public: int GetNumBodies() {return this->bodyCount;}
00090   public: Body **GetBodies() {return this->bodies;}
00091 
00092   // Set the id of the model
00093   public: void SetId(const char* id);
00094 
00095   // Get the id of the model
00096   public: const char* GetId() const {return this->id;}
00097 
00098   // Set the name of the model
00099   public: void SetName(const char *name);
00100 
00101   // Get the name of the model
00102   public: const char* GetName();
00103 
00104   // Set the Pick id of the model
00105   public: void SetPickId( GLuint id ); 
00106 
00107   // Get the Pick id of the model
00108   public: GLuint GetPickId() const {return this->pickId;}
00109 
00110   // The world
00111   public: World *world;
00112 
00113   // The node this was loaded from
00114   public: WorldFileNode *node;
00115 
00116   // Our parent model
00117   public: Model *parent;
00118 
00119   // Our parent body
00120   public: Body *parentBody;
00121 
00123   public: GzPose initPose;
00124 
00125   // The models id
00126   private: char *id;
00127 
00128   // The name of this model
00129   private: char *name;
00130 
00131   // Joint attaching us to parent body (for ODE bodies)
00132   public: HingeJoint *joint;
00133 
00134   // Pose relative to parent body (for dummy bodies)
00135   public: GzPose relPose;
00136 
00137   // Flag is true if this is a fixed object
00138   public: bool fixed;
00139 
00140   // The space for all the bodies in this model
00141   public: dSpaceID modelSpaceId;
00142 
00143   // A list of bodies making up this model
00144   private: int bodyCount, bodyMaxCount;
00145   private: Body **bodies;
00146 
00147   // The canonical body (reference for the model cs)
00148   private: Body *canonicalBody;
00149 
00150   // A list of joints making up this model
00151   private: int jointCount, jointMaxCount;
00152   private: Joint **joints;
00153 
00154   private: GLuint pickId;
00155   private: static GLuint pickIdMaster;
00156 };
00157 
00158 #endif
00159 


Last updated $Date: 2004/12/21 01:49:15 $
Generated on Sun May 22 18:39:08 2005 for Gazebo by doxygen 1.4.2