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
abstracttracksection.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 __ABSTRACTTRACKSECTION_H
25 #define __ABSTRACTTRACKSECTION_H
26 
27 #include "matrix.h"
28 using namespace matrix;
29 #include "position.h"
30 #include <drawstuff/drawstuff.h>
31 #include "simulation.h"
32 #include "mathutils.h"
33 
34 /**
35  * Abstract class (interface) for obstacles
36  */
38 
39  public:
40  /**
41  * Constructor, segment is initialized with Position (0,0,0)
42  * and a rotation angle=0
43  */
44  // AbstractTrackSection() {};
45 
46  /**
47  * Constructor where you can set the position and rotation by:
48  @param p is the position of the segment
49  @param angle is the rotation of the segment
50  */
51  AbstractTrackSection(const Position& p,const double angle) {
52  setPoseMatrix(getTranslationRotationMatrix(p, angle));
53  };
54 
55  /**
56  * Constructor where you can set the pos-matrix by this constructor:
57  @param position is the position AND rotation of the segment
58  */
60  setPoseMatrix(pose);
61  };
62 
64 
65 
66  virtual void create(dSpaceID space) = 0;
67 
68  virtual void destroy() = 0;
69 
70  virtual void draw() = 0;
71 
72  /**
73  * gives the position and rotation(angle) of the segment at the
74  * end of the segment so that a new segment could be placed there
75  * the result is a matrix
76  */
77  virtual Matrix getTransformedEndMatrix() = 0;
78 
79  /**
80  * returns true if the real coordinates lay inside of the segment
81  */
82  virtual bool isInside(const Position& p) = 0;
83 
84  /**
85  * returns a value between 0 and length that tells at which section
86  * you are on the segment.
87  * returns -1 if no IdValue can be given
88  */
89  virtual double getSectionIdValue(const Position& p)=0;
90 
91 
92 /**
93  * returns a value between 0 and width that tells at which width
94  * you are on the segment, 0 means right and width means left.
95  * returns -1 if no WidthValue can be given
96  */
97 virtual double getWidthIdValue(const Position& p)=0;
98 
99 
100 
101 /**
102  * returns the length of the segment,
103  * here it is the length of the arc
104  * formula is: radius * angle;
105  */
106  virtual double getLength()=0;
107 
108 
109 /**
110  * returns the width of the segment,
111  */
112  virtual double getWidth()=0;
113 
114 /**
115  * sets the width of the segment,
116  */
117  virtual void setWidth(double w)=0;
118 
120  return pos;
121  }
122 
124  return getPosition4x1(invpos*getPositionMatrix(p));
125  }
126 
128  return getPosition4x1(pos*getPositionMatrix(p));
129  }
130 
132  return invpos;
133  }
134 
135 protected:
136 
137  void setPoseMatrix(const Matrix& m){
138  pos = m;
139  invpos = invert_4x4PoseMatrix(m);
140  }
141  /**
142  * gives actual position of the obstacle
143  */
145  return ::getPosition(pos);
146  }
147 
148 private:
149  // saves the actual position AND rotation of the segment
150  Matrix pos;
151  Matrix invpos;
152 };
153 
154 #endif
Matrix type.
Definition: matrix.h:65
Abstract class (interface) for obstacles.
Definition: abstracttracksection.h:37
AbstractTrackSection(const Matrix &pose)
Constructor where you can set the pos-matrix by this constructor:
Definition: abstracttracksection.h:59
void setPoseMatrix(const Matrix &m)
Definition: abstracttracksection.h:137
Position transformToGlobalCoord(const Position &p)
Definition: abstracttracksection.h:127
AbstractTrackSection(const Position &p, const double angle)
Constructor, segment is initialized with Position (0,0,0) and a rotation angle=0. ...
Definition: abstracttracksection.h:51
Definition: position.h:30
Matrix getInversePoseMatrix()
Definition: abstracttracksection.h:131
virtual ~AbstractTrackSection()
Definition: abstracttracksection.h:63
Matrix getPoseMatrix()
Definition: abstracttracksection.h:119
Position getPosition()
gives actual position of the obstacle
Definition: abstracttracksection.h:144
Position transformToLocalCoord(const Position &p)
Definition: abstracttracksection.h:123