Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
abstractobstacle.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __ABSTRACTOBSTACLE_H
25 #define __ABSTRACTOBSTACLE_H
26 
27 #include <ode-dbl/ode.h>
28 
29 #include "odehandle.h"
30 #include "osghandle.h"
31 #include <osg/Matrix>
32 
33 #include <vector>
34 
35 class Position;
36 namespace matrix { class Matrix; }
37 
38 namespace lpzrobots {
39 
40 class Primitive;
41 class TextureDescr;
42 
43 /**
44  * Abstract class (interface) for obstacles
45  */
47 
48 
49  public:
50  /**
51  * Constructor
52  * @param odeHandle containing ODE stuff like world, space and jointgroup
53  * @param osgHandle containing OSG stuff like scene, color...
54  * be used for creation of obstacles
55  */
57 
58  virtual ~AbstractObstacle();
59 
60  /**
61  * updates the position if the scenegraph nodes
62  * the default implementation calls update on all primitive on "obst"
63  */
64  virtual void update();
65 
66  /**
67  * sets position of the obstacle and creates/recreates obstacle if necessary
68  */
69  virtual void setPos(const osg::Vec3& pos);
70 
71  /**
72  * sets position of the obstacle and creates/recreates obstacle if necessary
73  */
74  virtual void setPosition(const osg::Vec3& pos);
75 
76  /**
77  * gives actual position of the obstacle
78  */
79  virtual osg::Vec3 getPos();
80 
81  /**
82  * gives actual pose of the obstacle
83  */
84  virtual osg::Matrix getPose();
85 
86  /**
87  * sets position of the obstacle and creates/recreates obstacle if necessary
88  */
89  virtual void setPose(const osg::Matrix& pose) = 0;
90 
91  /**
92  * sets the obstacle color
93  * @param color values in RGBA
94  */
95  virtual void setColor(const Color& color);
96 
97  /*
98  * sets the obstacle color from color name
99  * @param color name of color in colorschema
100  */
101  virtual void setColor(const std::string& color);
102 
103 
104 
105  /** assigns a texture to the all primitives of this obstactle with repeat -1,-1
106  @see Primitive::setTexture()
107  */
108  virtual void setTexture(const std::string& texturefilename);
109  /** assigns a texture to the all primitives of this obstactle
110  @see Primitive::setTexture()
111  */
112  virtual void setTexture(const TextureDescr& texture);
113  /** assigns a texture to the x-th surface of each primitive,
114  @see Primitive::setTexture()
115  */
116  virtual void setTexture(int surface, const TextureDescr& texture);
117  /** assigns a texture to the x-th surface of the k-th primitive, (The texture setting of the
118  last primitve is repeated for the remaining ones)
119  @see Primitive::setTexture()
120  */
121  virtual void setTexture(int primitive, int surface, const TextureDescr& texture);
122 
123  /// returns the texture of the given surface on the given primitive
124  virtual TextureDescr getTexture(int primitive, int surface) const ;
125 
126  /// returns the textures of the given primitive
127  virtual std::vector<TextureDescr> getTextures(int primitive) const;
128 
129  /// return the "main" primitive of the obtactle. The meaning of "main" is arbitrary
130  virtual Primitive* getMainPrimitive() const = 0;
131 
132  /**
133  * sets the substance of the obtactle. It is applied to all objects in obj
134  * @param substance description of the substance
135  */
136  virtual void setSubstance(const Substance& substance);
137 
138  /// returns the substance of this obstacle
139  virtual const Substance& getSubstance();
140 
141  /*********** BEGIN TRACKABLE INTERFACE *******************/
142 
143  /** returns position of the object
144  @return vector of position (x,y,z)
145  */
146  virtual Position getPosition() const;
147 
148  /** returns linear speed vector of the object
149  @return vector (vx,vy,vz)
150  */
151  virtual Position getSpeed() const;
152 
153  /** returns angular velocity vector of the object
154  @return vector (wx,wy,wz)
155  */
156  virtual Position getAngularSpeed() const;
157 
158  /** returns the orientation of the object
159  @return 3x3 rotation matrix
160  */
161  virtual matrix::Matrix getOrientation() const;
162 
163  /*********** END TRACKABLE INTERFACE *******************/
164 
165  protected:
166  std::vector<Primitive*> obst; ///< primitives which belong to this obstacle
167 
168  std::vector<std::vector<TextureDescr> > textures; ///< for each primitive the texture settings per surface
169 
172 
175 
176 
177  /// is called to destroy the object. The default implementation is to delete all primitives in "obst".
178  virtual void destroy();
179 
180  /// overload this function to create the obstactle. All primitives should go into the list "obst"
181  virtual void create()=0;
182 
183 };
184 
185 }
186 
187 #endif
virtual TextureDescr getTexture(int primitive, int surface) const
returns the texture of the given surface on the given primitive
Definition: abstractobstacle.cpp:137
Matrix type.
Definition: matrix.h:65
virtual void setColor(const Color &color)
sets the obstacle color
Definition: abstractobstacle.cpp:89
Data structure for accessing the ODE.
Definition: odehandle.h:44
OsgHandle osgHandle
Definition: abstractobstacle.h:174
virtual matrix::Matrix getOrientation() const
returns the orientation of the object
Definition: abstractobstacle.cpp:208
virtual std::vector< TextureDescr > getTextures(int primitive) const
returns the textures of the given primitive
Definition: abstractobstacle.cpp:147
virtual void setTexture(const std::string &texturefilename)
assigns a texture to the all primitives of this obstactle with repeat -1,-1
Definition: abstractobstacle.cpp:107
Physical substance definition, used for collision detection/treatment What we need is mu...
Definition: substance.h:103
Abstract class (interface) for obstacles.
Definition: abstractobstacle.h:46
virtual Primitive * getMainPrimitive() const =0
return the "main" primitive of the obtactle. The meaning of "main" is arbitrary
virtual Position getAngularSpeed() const
returns angular velocity vector of the object
Definition: abstractobstacle.cpp:201
Matrixd Matrix
Definition: osgforwarddecl.h:47
virtual const Substance & getSubstance()
returns the substance of this obstacle
Definition: abstractobstacle.cpp:166
std::vector< std::vector< TextureDescr > > textures
for each primitive the texture settings per surface
Definition: abstractobstacle.h:168
virtual Position getPosition() const
returns position of the object
Definition: abstractobstacle.cpp:182
virtual void update()
updates the position if the scenegraph nodes the default implementation calls update on all primitive...
Definition: abstractobstacle.cpp:54
bool obstacle_exists
Definition: abstractobstacle.h:171
virtual Position getSpeed() const
returns linear speed vector of the object
Definition: abstractobstacle.cpp:194
OdeHandle odeHandle
Definition: abstractobstacle.h:173
virtual void create()=0
overload this function to create the obstactle. All primitives should go into the list "obst" ...
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
Definition: position.h:30
Vec3f Vec3
Definition: osgforwarddecl.h:42
holds texture file and repeat information.
Definition: osgprimitive.h:42
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
std::vector< Primitive * > obst
primitives which belong to this obstacle
Definition: abstractobstacle.h:166
Definition: color.h:32
osg::Matrix pose
Definition: abstractobstacle.h:170
AbstractObstacle(const OdeHandle &odeHandle, const OsgHandle &osgHandle)
Constructor.
Definition: abstractobstacle.cpp:43
virtual osg::Matrix getPose()
gives actual pose of the obstacle
Definition: abstractobstacle.cpp:87
virtual void setSubstance(const Substance &substance)
sets the substance of the obtactle.
Definition: abstractobstacle.cpp:157
virtual osg::Vec3 getPos()
gives actual position of the obstacle
Definition: abstractobstacle.cpp:80
virtual void destroy()
is called to destroy the object. The default implementation is to delete all primitives in "obst"...
Definition: abstractobstacle.cpp:171
virtual void setPosition(const osg::Vec3 &pos)
sets position of the obstacle and creates/recreates obstacle if necessary
Definition: abstractobstacle.cpp:73
virtual void setPos(const osg::Vec3 &pos)
sets position of the obstacle and creates/recreates obstacle if necessary
Definition: abstractobstacle.cpp:65
virtual void setPose(const osg::Matrix &pose)=0
sets position of the obstacle and creates/recreates obstacle if necessary
virtual ~AbstractObstacle()
Definition: abstractobstacle.cpp:50