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.11 2007/12/06 10:02:49 der 00025 * abstractground: returns now cornerpoints 00026 * abstractobstacle: is now trackable 00027 * hudstatistics: supports now AbstractmMeasure 00028 * 00029 * Revision 1.10 2007/03/16 11:01:37 martius 00030 * abstractobstacle gets mor functionallity 00031 * setSubstance 00032 * 00033 * Revision 1.9 2006/07/14 12:23:32 martius 00034 * selforg becomes HEAD 00035 * 00036 * Revision 1.8.4.9 2006/06/29 16:39:55 robot3 00037 * -you can now see bounding shapes if you type ./start -drawboundings 00038 * -includes cleared up 00039 * -abstractobstacle and abstractground have now .cpp-files 00040 * 00041 * Revision 1.8.4.8 2006/06/16 22:27:26 martius 00042 * getMainPrimtive 00043 * 00044 * Revision 1.8.4.7 2006/05/23 13:38:02 robot3 00045 * -fixed some creating bugs 00046 * -setColor,setTexture and createGround must be 00047 * called before setPosition now 00048 * 00049 * Revision 1.8.4.6 2006/05/18 12:54:24 robot3 00050 * -fixed not being able to change the color after positioning 00051 * the obstacle 00052 * -cleared the files up 00053 * 00054 * Revision 1.8.4.5 2006/05/11 08:59:15 robot3 00055 * -fixed a positioning bug (e.g. for passivesphere) 00056 * -some methods moved to abstractobstacle.h for avoiding inconsistencies 00057 * 00058 * Revision 1.8.4.4 2006/03/30 12:34:51 martius 00059 * documentation updated 00060 * 00061 * Revision 1.8.4.3 2006/03/29 15:04:38 martius 00062 * have pose now 00063 * 00064 * Revision 1.8.4.2 2005/12/06 10:13:23 martius 00065 * openscenegraph integration started 00066 * 00067 * Revision 1.8.4.1 2005/11/14 17:37:14 martius 00068 * moved to selforg 00069 * 00070 * Revision 1.8 2005/10/25 19:26:56 fhesse 00071 * comments adjusted and in doxygen style 00072 * 00073 * Revision 1.7 2005/09/22 12:24:36 martius 00074 * removed global variables 00075 * OdeHandle and GlobalData are used instead 00076 * sensor prepared 00077 * 00078 * Revision 1.6 2005/09/13 13:20:12 martius 00079 * initialised color 00080 * 00081 * Revision 1.5 2005/08/29 06:32:25 martius 00082 * added virtual destructor 00083 * 00084 * Revision 1.4 2005/07/18 14:52:33 martius 00085 * world and space are not pointers anymore. 00086 * 00087 * Revision 1.3 2005/06/15 14:22:11 martius 00088 * GPL included 00089 * * 00090 ***************************************************************************/ 00091 #ifndef __ABSTRACTOBSTACLE_H 00092 #define __ABSTRACTOBSTACLE_H 00093 00094 #include <ode/ode.h> 00095 00096 #include "odehandle.h" 00097 #include "osghandle.h" 00098 #include <osg/Matrix> 00099 00100 #include <vector> 00101 00102 class Position; 00103 namespace matrix { class Matrix; } 00104 00105 namespace lpzrobots { 00106 00107 class Primitive; 00108 00109 /** 00110 * Abstract class (interface) for obstacles 00111 */ 00112 class AbstractObstacle{ 00113 00114 00115 public: 00116 /** 00117 * Constructor 00118 * @param odeHandle containing ODE stuff like world, space and jointgroup 00119 * @param osgHandle containing OSG stuff like scene, color... 00120 * be used for creation of obstacles 00121 */ 00122 AbstractObstacle(const OdeHandle& odeHandle, const OsgHandle& osgHandle); 00123 00124 virtual ~AbstractObstacle(); 00125 00126 /** 00127 * updates the position if the scenegraph nodes 00128 * the default implementation calls update on all primitive on "obst" 00129 */ 00130 virtual void update(); 00131 00132 /** 00133 * sets position of the obstacle and creates/recreates obstacle if necessary 00134 */ 00135 virtual void setPos(const osg::Vec3& pos); 00136 00137 /** 00138 * sets position of the obstacle and creates/recreates obstacle if necessary 00139 */ 00140 virtual void setPosition(const osg::Vec3& pos); 00141 00142 /** 00143 * gives actual position of the obstacle 00144 */ 00145 virtual osg::Vec3 getPos(); 00146 00147 /** 00148 * gives actual pose of the obstacle 00149 */ 00150 virtual osg::Matrix getPose(); 00151 00152 /** 00153 * sets position of the obstacle and creates/recreates obstacle if necessary 00154 */ 00155 virtual void setPose(const osg::Matrix& pose) = 0; 00156 00157 /** 00158 * sets the obstacle color 00159 * @param color values in RGBA 00160 */ 00161 virtual void setColor(const Color& color); 00162 00163 /// return the "main" primitive of the obtactle. The meaning of "main" is arbitrary 00164 virtual Primitive* getMainPrimitive() const = 0; 00165 00166 /** 00167 * sets the substance of the obtactle. It is applied to all objects in obj 00168 * @param substance description of the substance 00169 */ 00170 virtual void setSubstance(const Substance& substance); 00171 00172 /*********** BEGIN TRACKABLE INTERFACE *******************/ 00173 00174 /** returns position of the object 00175 @return vector of position (x,y,z) 00176 */ 00177 virtual Position getPosition() const; 00178 00179 /** returns linear speed vector of the object 00180 @return vector (vx,vy,vz) 00181 */ 00182 virtual Position getSpeed() const; 00183 00184 /** returns angular velocity vector of the object 00185 @return vector (wx,wy,wz) 00186 */ 00187 virtual Position getAngularSpeed() const; 00188 00189 /** returns the orientation of the object 00190 @return 3x3 rotation matrix 00191 */ 00192 virtual matrix::Matrix getOrientation() const; 00193 00194 /*********** END TRACKABLE INTERFACE *******************/ 00195 00196 protected: 00197 std::vector<Primitive*> obst; ///< primitives which belong to this obstacle 00198 00199 osg::Matrix pose; 00200 bool obstacle_exists; 00201 00202 OdeHandle odeHandle; 00203 OsgHandle osgHandle; 00204 00205 /// is called to destroy the object. The default implementation is to delete all primitives in "obst". 00206 virtual void destroy(); 00207 00208 /// overload this function to create the obstactle. All primitives should go into the list "obst" 00209 virtual void create()=0; 00210 00211 }; 00212 00213 } 00214 00215 #endif