00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * frankguettler@gmx.de * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 * $Log: abstractobstacle.h,v $ 00024 * Revision 1.13 2010/03/09 11:53:41 martius 00025 * renamed globally ode to ode-dbl 00026 * 00027 * Revision 1.12 2009/04/02 10:12:25 martius 00028 * Texture handling changed 00029 * 00030 * Revision 1.11 2007/12/06 10:02:49 der 00031 * abstractground: returns now cornerpoints 00032 * abstractobstacle: is now trackable 00033 * hudstatistics: supports now AbstractmMeasure 00034 * 00035 * Revision 1.10 2007/03/16 11:01:37 martius 00036 * abstractobstacle gets mor functionallity 00037 * setSubstance 00038 * 00039 * Revision 1.9 2006/07/14 12:23:32 martius 00040 * selforg becomes HEAD 00041 * 00042 * Revision 1.8.4.9 2006/06/29 16:39:55 robot3 00043 * -you can now see bounding shapes if you type ./start -drawboundings 00044 * -includes cleared up 00045 * -abstractobstacle and abstractground have now .cpp-files 00046 * 00047 * Revision 1.8.4.8 2006/06/16 22:27:26 martius 00048 * getMainPrimtive 00049 * 00050 * Revision 1.8.4.7 2006/05/23 13:38:02 robot3 00051 * -fixed some creating bugs 00052 * -setColor,setTexture and createGround must be 00053 * called before setPosition now 00054 * 00055 * Revision 1.8.4.6 2006/05/18 12:54:24 robot3 00056 * -fixed not being able to change the color after positioning 00057 * the obstacle 00058 * -cleared the files up 00059 * 00060 * Revision 1.8.4.5 2006/05/11 08:59:15 robot3 00061 * -fixed a positioning bug (e.g. for passivesphere) 00062 * -some methods moved to abstractobstacle.h for avoiding inconsistencies 00063 * 00064 * Revision 1.8.4.4 2006/03/30 12:34:51 martius 00065 * documentation updated 00066 * 00067 * Revision 1.8.4.3 2006/03/29 15:04:38 martius 00068 * have pose now 00069 * 00070 * Revision 1.8.4.2 2005/12/06 10:13:23 martius 00071 * openscenegraph integration started 00072 * 00073 * Revision 1.8.4.1 2005/11/14 17:37:14 martius 00074 * moved to selforg 00075 * 00076 * Revision 1.8 2005/10/25 19:26:56 fhesse 00077 * comments adjusted and in doxygen style 00078 * 00079 * Revision 1.7 2005/09/22 12:24:36 martius 00080 * removed global variables 00081 * OdeHandle and GlobalData are used instead 00082 * sensor prepared 00083 * 00084 * Revision 1.6 2005/09/13 13:20:12 martius 00085 * initialised color 00086 * 00087 * Revision 1.5 2005/08/29 06:32:25 martius 00088 * added virtual destructor 00089 * 00090 * Revision 1.4 2005/07/18 14:52:33 martius 00091 * world and space are not pointers anymore. 00092 * 00093 * Revision 1.3 2005/06/15 14:22:11 martius 00094 * GPL included 00095 * * 00096 ***************************************************************************/ 00097 #ifndef __ABSTRACTOBSTACLE_H 00098 #define __ABSTRACTOBSTACLE_H 00099 00100 #include <ode-dbl/ode.h> 00101 00102 #include "odehandle.h" 00103 #include "osghandle.h" 00104 #include <osg/Matrix> 00105 00106 #include <vector> 00107 00108 class Position; 00109 namespace matrix { class Matrix; } 00110 00111 namespace lpzrobots { 00112 00113 class Primitive; 00114 00115 /** 00116 * Abstract class (interface) for obstacles 00117 */ 00118 class AbstractObstacle{ 00119 00120 00121 public: 00122 /** 00123 * Constructor 00124 * @param odeHandle containing ODE stuff like world, space and jointgroup 00125 * @param osgHandle containing OSG stuff like scene, color... 00126 * be used for creation of obstacles 00127 */ 00128 AbstractObstacle(const OdeHandle& odeHandle, const OsgHandle& osgHandle); 00129 00130 virtual ~AbstractObstacle(); 00131 00132 /** 00133 * updates the position if the scenegraph nodes 00134 * the default implementation calls update on all primitive on "obst" 00135 */ 00136 virtual void update(); 00137 00138 /** 00139 * sets position of the obstacle and creates/recreates obstacle if necessary 00140 */ 00141 virtual void setPos(const osg::Vec3& pos); 00142 00143 /** 00144 * sets position of the obstacle and creates/recreates obstacle if necessary 00145 */ 00146 virtual void setPosition(const osg::Vec3& pos); 00147 00148 /** 00149 * gives actual position of the obstacle 00150 */ 00151 virtual osg::Vec3 getPos(); 00152 00153 /** 00154 * gives actual pose of the obstacle 00155 */ 00156 virtual osg::Matrix getPose(); 00157 00158 /** 00159 * sets position of the obstacle and creates/recreates obstacle if necessary 00160 */ 00161 virtual void setPose(const osg::Matrix& pose) = 0; 00162 00163 /** 00164 * sets the obstacle color 00165 * @param color values in RGBA 00166 */ 00167 virtual void setColor(const Color& color); 00168 00169 /** assigns a texture to the all primitives of this obstactle 00170 @see Primitive::setTexture() 00171 */ 00172 virtual void setTexture(const std::string& filename, double repeatOnX=1, double repeatOnY=1); 00173 /** assigns a texture to the x-th surface of each primitive, 00174 @see Primitive::setTexture() 00175 */ 00176 virtual void setTexture(int surface, const std::string& filename, double repeatOnX, double repeatOnY); 00177 00178 /// return the "main" primitive of the obtactle. The meaning of "main" is arbitrary 00179 virtual Primitive* getMainPrimitive() const = 0; 00180 00181 /** 00182 * sets the substance of the obtactle. It is applied to all objects in obj 00183 * @param substance description of the substance 00184 */ 00185 virtual void setSubstance(const Substance& substance); 00186 00187 /*********** BEGIN TRACKABLE INTERFACE *******************/ 00188 00189 /** returns position of the object 00190 @return vector of position (x,y,z) 00191 */ 00192 virtual Position getPosition() const; 00193 00194 /** returns linear speed vector of the object 00195 @return vector (vx,vy,vz) 00196 */ 00197 virtual Position getSpeed() const; 00198 00199 /** returns angular velocity vector of the object 00200 @return vector (wx,wy,wz) 00201 */ 00202 virtual Position getAngularSpeed() const; 00203 00204 /** returns the orientation of the object 00205 @return 3x3 rotation matrix 00206 */ 00207 virtual matrix::Matrix getOrientation() const; 00208 00209 /*********** END TRACKABLE INTERFACE *******************/ 00210 00211 protected: 00212 std::vector<Primitive*> obst; ///< primitives which belong to this obstacle 00213 00214 osg::Matrix pose; 00215 bool obstacle_exists; 00216 00217 OdeHandle odeHandle; 00218 OsgHandle osgHandle; 00219 00220 /// is called to destroy the object. The default implementation is to delete all primitives in "obst". 00221 virtual void destroy(); 00222 00223 /// overload this function to create the obstactle. All primitives should go into the list "obst" 00224 virtual void create()=0; 00225 00226 }; 00227 00228 } 00229 00230 #endif