Robot Simulator of the Robotics Group for Self-Organization of Control: abstractobstacle.h Source File

# abstractobstacle.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot 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  ***************************************************************************/
    00024 #ifndef __ABSTRACTOBSTACLE_H
    00025 #define __ABSTRACTOBSTACLE_H
    00026
    00027 #include <ode-dbl/ode.h>
    00028
    00029 #include "odehandle.h"
    00030 #include "osghandle.h"
    00031 #include <osg/Matrix>
    00032
    00033 #include <vector>
    00034
    00035 class Position;
    00036 namespace matrix { class Matrix; }
    00037
    00038 namespace lpzrobots {
    00039
    00040 class Primitive;
    00041 class TextureDescr;
    00042
    00043 /**
    00044  *  Abstract class (interface) for obstacles
    00045  */
    00046 class AbstractObstacle{
    00047
    00048
    00049  public:
    00050   /**
    00051    * Constructor
    00052    * @param odeHandle containing ODE stuff like world, space and jointgroup
    00053    * @param osgHandle containing OSG stuff like scene, color...
    00054    * be used for creation of obstacles
    00055    */
    00056   AbstractObstacle(const OdeHandle& odeHandle, const OsgHandle& osgHandle);
    00057
    00058   virtual ~AbstractObstacle();
    00059
    00060   /**
    00061    * updates the position if the scenegraph nodes
    00062    * the default implementation calls update on all primitive on "obst"
    00063    */
    00064   virtual void update();
    00065
    00066   /**
    00067    * sets position of the obstacle and creates/recreates obstacle if necessary
    00068    */
    00069   virtual void setPos(const osg::Vec3& pos);
    00070
    00071     /**
    00072    * sets position of the obstacle and creates/recreates obstacle if necessary
    00073    */
    00074   virtual void setPosition(const osg::Vec3& pos);
    00075
    00076   /**
    00077    * gives actual position of the obstacle
    00078    */
    00079   virtual osg::Vec3 getPos();
    00080
    00081   /**
    00082    * gives actual pose of the obstacle
    00083    */
    00084   virtual osg::Matrix getPose();
    00085
    00086   /**
    00087    * sets position of the obstacle and creates/recreates obstacle if necessary
    00088    */
    00089   virtual void setPose(const osg::Matrix& pose) = 0;
    00090
    00091   /**
    00092    * sets the obstacle color
    00093    * @param color values in RGBA
    00094    */
    00095   virtual void setColor(const Color& color);
    00096
    00097   /*
    00098    * sets the obstacle color from color name
    00099    * @param color name of color in colorschema
    00100    */
    00101   virtual void setColor(const std::string& color);
    00102
    00103
    00104
    00105   /** assigns a texture to the all primitives of this obstactle with repeat -1,-1
    00106       @see Primitive::setTexture()
    00107   */
    00108   virtual void setTexture(const std::string& texturefilename);
    00109   /** assigns a texture to the all primitives of this obstactle
    00110       @see Primitive::setTexture()
    00111   */
    00112   virtual void setTexture(const TextureDescr& texture);
    00113   /** assigns a texture to the x-th surface of each primitive,
    00114       @see Primitive::setTexture()
    00115   */
    00116   virtual void setTexture(int surface, const TextureDescr& texture);
    00117   /** assigns a texture to the x-th surface of the k-th primitive, (The texture setting of the
    00118       last primitve is repeated for the remaining ones)
    00119       @see Primitive::setTexture()
    00120   */
    00121   virtual void setTexture(int primitive, int surface, const TextureDescr& texture);
    00122
    00123   /// returns the texture of the given surface on the given primitive
    00124   virtual TextureDescr getTexture(int primitive, int surface) const ;
    00125
    00126   /// returns the textures of the given primitive
    00127   virtual std::vector<TextureDescr> getTextures(int primitive) const;
    00128
    00129   /// return the "main" primitive of the obtactle. The meaning of "main" is arbitrary
    00130   virtual Primitive* getMainPrimitive() const = 0;
    00131
    00132   /**
    00133    * sets the substance of the obtactle. It is applied to all objects in obj
    00134    * @param substance description of the substance
    00135    */
    00136   virtual void setSubstance(const Substance& substance);
    00137
    00138   /// returns the substance of this obstacle
    00139   virtual const Substance& getSubstance();
    00140
    00141    /*********** BEGIN TRACKABLE INTERFACE *******************/
    00142
    00143    /** returns position of the object
    00144   @return vector of position (x,y,z)
    00145    */
    00146   virtual Position getPosition() const;
    00147
    00148   /** returns linear speed vector of the object
    00149   @return vector  (vx,vy,vz)
    00150    */
    00151   virtual Position getSpeed() const;
    00152
    00153   /** returns angular velocity vector of the object
    00154   @return vector  (wx,wy,wz)
    00155    */
    00156   virtual Position getAngularSpeed() const;
    00157
    00158   /** returns the orientation of the object
    00159   @return 3x3 rotation matrix
    00160    */
    00161   virtual matrix::Matrix getOrientation() const;
    00162
    00163   /*********** END TRACKABLE INTERFACE *******************/
    00164
    00165  protected:
    00166   std::vector<Primitive*> obst; ///< primitives which belong to this obstacle
    00167
    00168   std::vector<std::vector<TextureDescr> > textures; ///< for each primitive the texture settings per surface
    00169
    00170   osg::Matrix pose;
    00171   bool obstacle_exists;
    00172
    00173   OdeHandle odeHandle;
    00174   OsgHandle osgHandle;
    00175
    00176
    00177   /// is called to destroy the object. The default implementation is to delete all primitives in "obst".
    00178   virtual void destroy();
    00179
    00180   /// overload this function to create the obstactle. All primitives should go into the list "obst"
    00181   virtual void create()=0;
    00182
    00183 };
    00184
    00185 }
    00186
    00187 #endif