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
boundingshape.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 __BOUNDINGSHAPE_H
25 #define __BOUNDINGSHAPE_H
26 
27 #include "primitive.h"
28 #include "odehandle.h"
29 
30 #include <string>
31 #include <vector>
32 
33 
34 namespace lpzrobots {
35 
36  /**
37  class for reading bounding shape description files (.bbox) and to create appropriate geoms
38 
39  File Format: Lines wise, every line stands for one primitive.
40 
41  Possible lines are:
42  - sphere radius (x,y,z)
43  - cylinder radius height (x,y,z) (alpha, beta, gamma)
44  - capsule radius height (x,y,z) (alpha, beta, gamma)
45  - box length width height (x,y,z) (alpha, beta, gamma)
46 
47  (x,y,z) is the position vector and (alpha, beta, gamma) are
48  the rotation angles about x,y,z axis respectively
49 
50  Example:
51  \code
52 cylinder 6.5 50 (0,0,25) (0,0,0)
53 cylinder 50 15 (0,0,28) (0,0,0)
54 cylinder 40 30 (0,0,50) (0,0,0)
55 cylinder 30 20 (0,0,75) (0,0,0)
56 cylinder 20 30 (0,0,100) (0,0,0)
57 cylinder 13 30 (0,0,125) (0,0,0)
58 cylinder 8 30 (0,0,150) (0,0,0)
59 cylinder 5 30 (0,0,175) (0,0,0)
60  \endcode
61  */
62 
64 
65  public:
66  /**
67  @param filename path and name of bbox file. It is located using OsgDB search path
68  @param parent primitive to which the bbox is assoziated
69  */
70  BoundingShape(const std::string& filename, Mesh* parent);
71 
72  virtual ~BoundingShape();
73 
74  /// tries to open the bbox file and greates all geoms
75  virtual bool init(const OdeHandle& odeHandle, const OsgHandle& osgHandle,
76  double scale, char mode);
77 
78  virtual bool isActive();
79 
80  /**
81  * updates all Primitives of the BoundingShape if only in geom mode (no Body)
82  * @param pose
83  */
84  virtual void setPose(const osg::Matrix& pose);
85 
86  private:
87  bool readBBoxFile(std::string& filename, const OdeHandle& odeHandle, const OsgHandle& osgHandle,
88  double scale, char mode);
89 
90  protected:
91  std::string filename;
92  bool active;
94  bool attachedToParentBody; // true as default, false not yet implemented by BoundingShape
95  std::vector<Primitive*> boundingPrimitiveList; // used if not attached to a body
96  std::vector<osg::Matrix> boundingPrimitivePoseList; // stores the relative pose of each primitive
98  dSpaceID parentSpace;
99  };
100 
101 }
102 
103 #endif
Data structure for accessing the ODE.
Definition: odehandle.h:44
virtual ~BoundingShape()
Definition: boundingshape.cpp:52
Matrixd Matrix
Definition: osgforwarddecl.h:47
virtual bool isActive()
Definition: boundingshape.cpp:129
Primitive * parent
Definition: boundingshape.h:93
std::string filename
Definition: boundingshape.h:91
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
bool attachedToParentBody
Definition: boundingshape.h:94
std::vector< Primitive * > boundingPrimitiveList
Definition: boundingshape.h:95
class for reading bounding shape description files (.bbox) and to create appropriate geoms ...
Definition: boundingshape.h:63
virtual void setPose(const osg::Matrix &pose)
updates all Primitives of the BoundingShape if only in geom mode (no Body)
Definition: boundingshape.cpp:56
dSpaceID parentSpace
Definition: boundingshape.h:98
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
std::vector< osg::Matrix > boundingPrimitivePoseList
Definition: boundingshape.h:96
Mesh primitive.
Definition: primitive.h:374
BoundingShape(const std::string &filename, Mesh *parent)
class for reading bounding shape description files (.bbox) and to create appropriate geoms File Forma...
Definition: boundingshape.cpp:47
OdeHandle odeHandle
Definition: boundingshape.h:97
bool active
Definition: boundingshape.h:92
virtual bool init(const OdeHandle &odeHandle, const OsgHandle &osgHandle, double scale, char mode)
tries to open the bbox file and greates all geoms
Definition: boundingshape.cpp:123