Gazebo logo

Body.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 bodies
00022  * Author: Nate Keonig, Andrew Howard
00023  * Date: 8 May 2003
00024  * CVS: $Id: Body.hh,v 1.31 2006/02/14 03:00:25 natepak Exp $
00025  */
00026 
00027 #ifndef BODY_HH
00028 #define BODY_HH
00029 
00030 #include <ode/ode.h>
00031 #include "Vector.hh"
00032 
00033 #include "GL/gl.h"
00034 
00035 // Forward declarations
00036 class World;
00037 class Geom;
00038 class RenderOptions;
00039 
00040 
00043 class Body
00044 {
00046   public: Body( const World *world, const char *bodyName = NULL, bool dummy = false );
00047 
00049   public: virtual ~Body();
00050   
00051   // Attach a geometry to this body
00052   private: void AttachGeom( Geom *geom );
00053 
00054   // Detach a geometry from this body
00055   private: void DetachGeom( Geom *geom );
00056 
00057   // Update the CoM and mass matrix
00058   public: void UpdateCoM();
00059 
00060   // Get the list of geometries
00061   public: int GetNumGeoms() {return this->geomCount;}
00062   public: Geom **GetGeoms() {return this->geoms;}
00063 
00064   // Enable/disable the body (so it doesnt fall, for example)
00065   public: void Enable(bool enable);
00066 
00068   public: GzPose GetPose( void ) const;
00069 
00071   public: GzVector GetPosition( void ) const;
00072 
00074   public: GzQuatern GetRotation( void ) const;
00075   
00077   public: void SetPose( GzPose pose );
00078 
00080   public: void SetPosition( GzVector pos );
00081 
00083   public: void SetRotation( GzQuatern rot );
00084 
00085   // Get the CoM body pose (global cs)
00086   public: GzPose GetCoMPose( void ) const;
00087 
00088   // Get the body linear velocity (global cs)
00089   public: GzVector GetLinearVel( void ) const;
00090 
00091   // Get the body angular velocity (global cs)
00092   public: GzQuatern GetAngularVel( void ) const;
00093 
00095   public: void SetLinearVel( GzVector vel );
00096 
00098   public: void SetAngularVel( GzVector vel );
00099 
00100   // Get the body id
00101   public: dBodyID GetBodyId() const;
00102   
00103   // Get the default space id
00104   public: dSpaceID GetSpaceId() const;
00105 
00107   public: void SetGravityMode(bool enabled);
00108   
00109   public: int GetGravityMode();
00110   
00111   // To correct the wheel rotation issues in ODE
00112   public: void SetFiniteRotationAxis(double x,double y,double z);
00113   public: void SetFiniteRotationMode(int mode);
00114 
00115   // Set pick id of all the geoms in this body
00116   public: void SetPickId( GLuint id );
00117 
00118   // TODO? // Force/Torque Setting Functions
00119   public: GzVector GetTorque(void);
00120 
00122   public: GzVector GetForce(void);
00123 
00125   public: void SetForce( GzVector f );
00126   
00127   public: void SetTorque( double x, double y, double z);
00128 
00129   public: void AddForce( double x, double y, double z);
00130   public: void AddTorque( double x, double y, double z);
00131   public: void AddRelForce( double x, double y, double z);
00132   public: void AddRelTorque( double x, double y, double z);
00133    
00134   public: void AddForceAtPos( double x, double y, double z, 
00135                               double pos_x,double pos_y,double pos_z); 
00136   public: void AddForceAtRelPos( double x, double y, double z,
00137                                  double pos_x,double pos_y,double pos_z);
00138 
00139   // Draw this body
00140   public: void Render( int pass, RenderOptions *renderOpt );
00141 
00142   // Render a set of axes on a body
00143   private: void RenderAxes(RenderOptions *renderOpt);
00144 
00145   // Draw an axis with the given pose and size
00146   private: void DrawAxis(GzPose pose, double size, const char *text);
00147  
00148   // A name to reference us by
00149   public: char *bodyName;
00150   
00151   // ODE world we belong to
00152   protected: dWorldID worldId;
00153 
00154   // ODE body handle
00155   protected: dBodyID bodyId;
00156 
00157   // Pose of CoM relative to body
00158   private: GzPose comPose;
00159 
00160   // Body pose (for dummy bodies)
00161   protected: GzPose dummyPose;
00162 
00163   // List of geometries attach to this body
00164   private: int geomCount, geomMaxCount;
00165   private: Geom **geoms;
00166 
00167   // Mass properties of the object
00168   protected: dMass mass;
00169 
00170   // Warts
00171   friend class Geom;
00172   friend class BaseGeom;
00173   friend class Camera;
00174 };
00175 
00176 
00177 
00178 #endif
00179 

Last updated 12 September 2005 21:38:45