irsensor.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 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 * * 00022 * $Log: irsensor.h,v $ 00023 * Revision 1.10 2006/09/20 12:56:28 martius 00024 * setRange 00025 * 00026 * Revision 1.9 2006/09/11 12:01:31 martius 00027 * *** empty log message *** 00028 * 00029 * Revision 1.8 2006/08/28 12:18:31 martius 00030 * documentation 00031 * 00032 * Revision 1.7 2006/08/08 17:03:27 martius 00033 * new sensors model 00034 * 00035 * Revision 1.6 2006/07/14 12:23:43 martius 00036 * selforg becomes HEAD 00037 * 00038 * Revision 1.5.4.4 2006/03/30 12:34:59 martius 00039 * documentation updated 00040 * 00041 * Revision 1.5.4.3 2006/01/12 15:14:02 martius 00042 * some fwd decl. 00043 * 00044 * Revision 1.5.4.2 2005/12/14 12:43:07 martius 00045 * moved to osg 00046 * 00047 * Revision 1.5.4.1 2005/12/13 18:11:53 martius 00048 * sensors ported, but not yet finished 00049 * 00050 * Revision 1.5 2005/11/09 13:24:20 martius 00051 * added exponent 00052 * 00053 * Revision 1.4 2005/11/09 09:13:47 fhesse 00054 * geom is only enabled in sense function 00055 * there is no external collision detection anymore 00056 * 00057 * Revision 1.3 2005/09/27 13:59:26 martius 00058 * ir sensors are working now 00059 * 00060 * Revision 1.2 2005/09/27 11:03:34 fhesse 00061 * sensorbank added 00062 * 00063 * Revision 1.1 2005/09/22 12:56:47 martius 00064 * ray based sensors 00065 * 00066 * * 00067 ***************************************************************************/ 00068 #ifndef __IRSENSOR_H 00069 #define __IRSENSOR_H 00070 00071 #include "raysensor.h" 00072 00073 namespace lpzrobots { 00074 00075 class OSGCylinder; 00076 class OSGBox; 00077 00078 /** Class for IR sensors. 00079 IR sensors are based on distance measurements using the ODE geom class Ray. 00080 The sensor value is obtained by collisions. 00081 However of no collision is detected the sensor needs to ajust its output as well. 00082 Therefore a reset function is provided. 00083 */ 00084 class IRSensor : public RaySensor { 00085 public: 00086 /** 00087 @param exponent exponent of the sensor characteritic (default: 1 (linear)) 00088 */ 00089 IRSensor(double exponent = 1); 00090 00091 virtual ~IRSensor(); 00092 00093 virtual void init(const OdeHandle& odeHandle, 00094 const OsgHandle& osgHandle, 00095 Primitive* body, 00096 const osg::Matrix pose, double range, 00097 rayDrawMode drawMode = drawSensor); 00098 00099 virtual void reset(); 00100 virtual bool sense(dGeomID object); 00101 00102 /** returns the sensor value in the range [0,1]; 00103 0 means nothing no object in the sensor distance range 00104 1 means contact with another object 00105 @see characteritic() 00106 */ 00107 virtual double get(); 00108 virtual void update(); 00109 00110 virtual void setRange(double range); 00111 00112 virtual dGeomID getGeomID(); 00113 00114 /// returns the exponent of the sensor characteritic (default: 1 (linear)) 00115 double getExponent () const { return exponent;} 00116 00117 /// sets the exponent of the sensor characteritic (default: 1 (linear)) 00118 void setExponent (double exp) { exponent = exp;} 00119 00120 protected: 00121 /** describes the sensor characteritic 00122 An exponential curve is used. 00123 @see setExponent() 00124 */ 00125 virtual double characteritic(double len); 00126 00127 protected: 00128 dGeomID transform; 00129 dGeomID ray; 00130 double range; // max length 00131 double len; // last measured length 00132 double value; // actual sensor value 00133 double exponent; // exponent of the sensor characteritic 00134 00135 OSGCylinder* sensorBody; 00136 OSGBox* sensorRay; 00137 OsgHandle osgHandle; 00138 00139 bool initialised; 00140 }; 00141 00142 } 00143 00144 #endif

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