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: raysensor.h,v $ 00023 * Revision 1.10 2010/03/09 11:53:41 martius 00024 * renamed globally ode to ode-dbl 00025 * 00026 * Revision 1.9 2007/09/06 18:48:29 martius 00027 * clone function (a bit like a factory) 00028 * 00029 * Revision 1.8 2007/08/23 15:39:05 martius 00030 * new IR sensor schema which uses substances and callbacks, very nice 00031 * 00032 * Revision 1.7 2006/09/20 12:56:28 martius 00033 * setRange 00034 * 00035 * Revision 1.6 2006/08/28 12:18:31 martius 00036 * documentation 00037 * 00038 * Revision 1.5 2006/08/08 17:03:27 martius 00039 * new sensors model 00040 * 00041 * Revision 1.4 2006/07/14 12:23:43 martius 00042 * selforg becomes HEAD 00043 * 00044 * Revision 1.3.4.3 2006/01/31 15:46:16 martius 00045 * virtual destructor 00046 * 00047 * Revision 1.3.4.2 2005/12/13 18:11:53 martius 00048 * sensors ported, but not yet finished 00049 * 00050 * Revision 1.3.4.1 2005/11/14 17:37:21 martius 00051 * moved to selforg 00052 * 00053 * Revision 1.3 2005/09/27 13:59:26 martius 00054 * ir sensors are working now 00055 * 00056 * Revision 1.2 2005/09/27 11:03:34 fhesse 00057 * sensorbank added 00058 * 00059 * Revision 1.1 2005/09/22 12:56:47 martius 00060 * ray based sensors 00061 * 00062 * * 00063 ***************************************************************************/ 00064 #ifndef __RAYSENSOR_H 00065 #define __RAYSENSOR_H 00066 00067 #include <ode-dbl/common.h> 00068 #include "osgforwarddecl.h" 00069 #include "odehandle.h" 00070 #include "osghandle.h" 00071 00072 00073 namespace lpzrobots { 00074 class Primitive; 00075 00076 /** Abstract class for Ray-based sensors. 00077 This are sensors which are based on distance measurements using the ODE geom class Ray. 00078 The sensor value is obtained by collisions. 00079 However of no collision is detected the sensor needs to ajust its output as well. 00080 Therefore a reset function is provided. 00081 See also RaySensorBank, which is an object for managing multiple ray sensors. 00082 */ 00083 class RaySensor { 00084 public: 00085 enum rayDrawMode { drawNothing, drawRay, drawSensor, drawAll}; 00086 00087 RaySensor() {} 00088 virtual ~RaySensor(){} 00089 00090 // should create a copy if this, without initialisation 00091 virtual RaySensor* clone() const = 0; 00092 00093 /** providing essential information 00094 @param odeHandle OdeHandle 00095 @param osgHandle OsgHandle 00096 @param body primitive to which the sensor will be attached 00097 @param pose relative pose in respect to body in which the sensor will be placed 00098 @param range length of the sensor 00099 @param drawMode whether to draw nothing, sensor body, ray, or both 00100 */ 00101 virtual void init(const OdeHandle& odeHandle, 00102 const OsgHandle& osgHandle, Primitive* body, 00103 const osg::Matrix pose, float range, 00104 rayDrawMode drawMode = drawSensor) = 0; 00105 00106 /** used for reseting the sensor value to a value of maximal distance. 00107 */ 00108 virtual void reset() = 0; 00109 00110 /** returns the sensor value (usually in the range [-1,1] ) 00111 */ 00112 virtual double get() = 0; 00113 00114 /** set the range of the sensor 00115 @param range new length of the sensor 00116 */ 00117 virtual void setRange(float range) = 0; 00118 00119 /** updates the position of the osg nodes 00120 */ 00121 virtual void update() = 0; 00122 00123 }; 00124 00125 } 00126 00127 #endif