abstracttracksection.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: abstracttracksection.h,v $ 00024 * Revision 1.4 2005/12/12 13:44:41 martius 00025 * barcodesensor is working 00026 * 00027 * Revision 1.3 2005/12/03 16:57:12 martius 00028 * setWidth is void 00029 * 00030 * Revision 1.2 2005/11/22 15:51:23 robot3 00031 * testing 00032 * 00033 * Revision 1.1 2005/11/15 14:29:25 robot3 00034 * first version 00035 * 00036 * * 00037 ***************************************************************************/ 00038 #ifndef __ABSTRACTTRACKSECTION_H 00039 #define __ABSTRACTTRACKSECTION_H 00040 00041 #include "matrix.h" 00042 using namespace matrix; 00043 #include "position.h" 00044 #include <drawstuff/drawstuff.h> 00045 #include "simulation.h" 00046 #include "mathutils.h" 00047 00048 /** 00049 * Abstract class (interface) for obstacles 00050 */ 00051 class AbstractTrackSection{ 00052 00053 public: 00054 /** 00055 * Constructor, segment is initialized with Position (0,0,0) 00056 * and a rotation angle=0 00057 */ 00058 // AbstractTrackSection() {}; 00059 00060 /** 00061 * Constructor where you can set the position and rotation by: 00062 @param Position& p is the position of the segment 00063 @param double angle is the rotation of the segment 00064 */ 00065 AbstractTrackSection(const Position& p,const double angle) { 00066 setPoseMatrix(getTranslationRotationMatrix(p, angle)); 00067 }; 00068 00069 /** 00070 * Constructor where you can set the pos-matrix by this constructor: 00071 @param Matrix& position is the position AND rotation of the segment 00072 */ 00073 AbstractTrackSection(const Matrix& pose){ 00074 setPoseMatrix(pose); 00075 }; 00076 00077 virtual ~AbstractTrackSection(){} 00078 00079 00080 virtual void create(dSpaceID space) = 0; 00081 00082 virtual void destroy() = 0; 00083 00084 virtual void draw() = 0; 00085 00086 /** 00087 * gives the position and rotation(angle) of the segment at the 00088 * end of the segment so that a new segment could be placed there 00089 * the result is a matrix 00090 */ 00091 virtual Matrix getTransformedEndMatrix() = 0; 00092 00093 /** 00094 * returns true if the real coordinates lay inside of the segment 00095 */ 00096 virtual bool isInside(const Position& p) = 0; 00097 00098 /** 00099 * returns a value between 0 and length that tells at which section 00100 * you are on the segment. 00101 * returns -1 if no IdValue can be given 00102 */ 00103 virtual double getSectionIdValue(const Position& p)=0; 00104 00105 00106 /** 00107 * returns a value between 0 and width that tells at which width 00108 * you are on the segment, 0 means right and width means left. 00109 * returns -1 if no WidthValue can be given 00110 */ 00111 virtual double getWidthIdValue(const Position& p)=0; 00112 00113 00114 00115 /** 00116 * returns the length of the segment, 00117 * here it is the length of the arc 00118 * formula is: radius * angle; 00119 */ 00120 virtual double getLength()=0; 00121 00122 00123 /** 00124 * returns the width of the segment, 00125 */ 00126 virtual double getWidth()=0; 00127 00128 /** 00129 * sets the width of the segment, 00130 */ 00131 virtual void setWidth(double w)=0; 00132 00133 Matrix getPoseMatrix(){ 00134 return pos; 00135 } 00136 00137 Position transformToLocalCoord(const Position& p){ 00138 return getPosition4x1(invpos*getPositionMatrix(p)); 00139 } 00140 00141 Position transformToGlobalCoord(const Position& p){ 00142 return getPosition4x1(pos*getPositionMatrix(p)); 00143 } 00144 00145 Matrix getInversePoseMatrix(){ 00146 return invpos; 00147 } 00148 00149 protected: 00150 00151 void setPoseMatrix(const Matrix& m){ 00152 pos = m; 00153 invpos = invert_4x4PoseMatrix(m); 00154 } 00155 /** 00156 * gives actual position of the obstacle 00157 */ 00158 Position getPosition(){ 00159 return ::getPosition(pos); 00160 } 00161 00162 private: 00163 // saves the actual position AND rotation of the segment 00164 Matrix pos; 00165 Matrix invpos; 00166 }; 00167 00168 #endif

Generated on Tue Jan 16 02:14:34 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8