Robotsystem of the Robot Group Leipzig: irsensor.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Examples

- Search for |

- File List
- File Members

# 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.6  2006/07/14 12:23:43  martius
    00024  *   selforg becomes HEAD
    00025  *
    00026  *   Revision 1.5.4.4  2006/03/30 12:34:59  martius
    00027  *   documentation updated
    00028  *
    00029  *   Revision 1.5.4.3  2006/01/12 15:14:02  martius
    00030  *   some fwd decl.
    00031  *
    00032  *   Revision 1.5.4.2  2005/12/14 12:43:07  martius
    00033  *   moved to osg
    00034  *
    00035  *   Revision 1.5.4.1  2005/12/13 18:11:53  martius
    00036  *   sensors ported, but not yet finished
    00037  *
    00038  *   Revision 1.5  2005/11/09 13:24:20  martius
    00039  *   added exponent
    00040  *
    00041  *   Revision 1.4  2005/11/09 09:13:47  fhesse
    00042  *   geom is only enabled in sense function
    00043  *   there is no external collision detection anymore
    00044  *
    00045  *   Revision 1.3  2005/09/27 13:59:26  martius
    00046  *   ir sensors are working now
    00047  *
    00048  *   Revision 1.2  2005/09/27 11:03:34  fhesse
    00049  *   sensorbank added
    00050  *
    00051  *   Revision 1.1  2005/09/22 12:56:47  martius
    00052  *   ray based sensors
    00053  *
    00054  *                                                                         *
    00055  ***************************************************************************/
    00056 #ifndef __IRSENSOR_H
    00057 #define __IRSENSOR_H
    00058
    00059 #include "raysensor.h"
    00060
    00061 namespace lpzrobots {
    00062
    00063   class OSGCylinder;
    00064   class OSGBox;
    00065
    00066 /** Class for IR sensors.
    00067     IR sensors are based on distance measurements using the ODE geom class Ray.
    00068     The sensor value is obtained by collisions.
    00069     However of no collision is detected the sensor needs to ajust its output as well.
    00070     Therefore a reset function is provided.
    00071  */
    00072 class IRSensor : public RaySensor {
    00073 public:
    00074   /**
    00075      @param exponent exponent of the sensor characteritic (default: 1 (linear))
    00076   */
    00077   IRSensor(double exponent = 1);
    00078
    00079   virtual ~IRSensor();
    00080
    00081   /** providing essential informations
    00082    */
    00083   virtual void init(const OdeHandle& odeHandle,
    00084                     const OsgHandle& osgHandle,
    00085                     Primitive* body,
    00086                     const osg::Matrix pose, double range,
    00087                     rayDrawMode drawMode = drawSensor);
    00088
    00089   /** used for reseting the sensor value to a value of maximal distance.
    00090    */
    00091   virtual void reset();
    00092
    00093   /** performs sense action by checking collision with the given object
    00094       @return true for collision handled (sensed) and false for no interaction
    00095    */
    00096   virtual bool sense(dGeomID object);
    00097
    00098   /** returns the sensor value (usually in the range [-1,1] )
    00099    */
    00100   virtual double get();
    00101
    00102   /** draws the sensor ray
    00103    */
    00104   virtual void update();
    00105
    00106   /** returns the geomID of the ray geom (used for optimisation)
    00107    */
    00108   virtual dGeomID getGeomID();
    00109
    00110   /// returns the exponent of the sensor characteritic (default: 1 (linear))
    00111   double getExponent () const { return exponent;}
    00112
    00113   /// sets the exponent of the sensor characteritic (default: 1 (linear))
    00114   void   setExponent (double exp) { exponent = exp;}
    00115
    00116 protected:
    00117   /** describes the sensor characteritic
    00118       linear curve used here
    00119   */
    00120   virtual double characteritic(double len);
    00121
    00122 protected:
    00123   dGeomID transform;
    00124   dGeomID ray;
    00125   double range; // max length
    00126   double len;   // last measured length
    00127   double value; // actual sensor value
    00128   double exponent; // exponent of the sensor characteritic
    00129
    00130   OSGCylinder* sensorBody;
    00131   OSGBox* sensorRay;
    00132   OsgHandle osgHandle;
    00133
    00134   bool initialised;
    00135 };
    00136
    00137 }
    00138
    00139 #endif