raysensor.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: raysensor.h,v $
00023  *   Revision 1.4  2006/07/14 12:23:43  martius
00024  *   selforg becomes HEAD
00025  *
00026  *   Revision 1.3.4.3  2006/01/31 15:46:16  martius
00027  *   virtual destructor
00028  *
00029  *   Revision 1.3.4.2  2005/12/13 18:11:53  martius
00030  *   sensors ported, but not yet finished
00031  *
00032  *   Revision 1.3.4.1  2005/11/14 17:37:21  martius
00033  *   moved to selforg
00034  *
00035  *   Revision 1.3  2005/09/27 13:59:26  martius
00036  *   ir sensors are working now
00037  *
00038  *   Revision 1.2  2005/09/27 11:03:34  fhesse
00039  *   sensorbank added
00040  *
00041  *   Revision 1.1  2005/09/22 12:56:47  martius
00042  *   ray based sensors
00043  *
00044  *                                                                         *
00045  ***************************************************************************/
00046 #ifndef __RAYSENSOR_H
00047 #define __RAYSENSOR_H
00048 
00049 #include <ode/common.h>
00050 #include "osgforwarddecl.h"
00051 #include "odehandle.h"
00052 #include "osghandle.h"
00053 
00054 
00055 namespace lpzrobots {
00056   class Primitive;
00057 
00058 /** Abstract class for Ray-based sensors. 
00059     This are sensors which are based on distance measurements using the ODE geom class Ray. 
00060     The sensor value is obtained by collisions. 
00061     However of no collision is detected the sensor needs to ajust its output as well. 
00062     Therefore a reset function is provided.
00063  */
00064 class RaySensor {
00065 public:  
00066   enum rayDrawMode { drawNothing, drawRay, drawSensor, drawAll};
00067 
00068   RaySensor() {}
00069   virtual ~RaySensor(){}
00070   
00071   /** providing essential information
00072    */
00073   virtual void init(const OdeHandle& odeHandle,
00074                     const OsgHandle& osgHandle, Primitive* body, 
00075                     const osg::Matrix pose, double range,
00076                     rayDrawMode drawMode = drawSensor) = 0;  
00077 
00078   /** used for reseting the sensor value to a value of maximal distance. 
00079    */
00080   virtual void reset() = 0;  
00081   
00082   /** performs sense action by checking collision with the given object
00083       @return true for collision handled (sensed) and false for no interaction
00084    */
00085   virtual bool sense(dGeomID object) = 0;
00086 
00087   /** returns the sensor value (usually in the range [-1,1] )
00088    */
00089   virtual double get() = 0;
00090 
00091   /** updates the position of the osg nodes 
00092    */
00093   virtual void update() = 0;
00094   
00095   /** returns the geomID of the ray geom (used for optimisation)
00096    */
00097   virtual dGeomID getGeomID() =0;
00098 
00099 };
00100 
00101 }
00102 
00103 #endif

Generated on Mon Aug 7 16:40:14 2006 for Robotsystem of the Robot Group Leipzig by  doxygen 1.4.7