abstractobstacle.h

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

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7