Robot Simulator of the Robotics Group for Self-Organization of Control: irsensor.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- 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.14  2009/01/20 17:29:52  martius
    00024  *   cvs commit
    00025  *
    00026  *   Revision 1.13  2007/09/06 18:48:29  martius
    00027  *   clone function (a bit like a factory)
    00028  *
    00029  *   Revision 1.12  2007/08/24 11:57:48  martius
    00030  *   some forward declaration
    00031  *
    00032  *   Revision 1.11  2007/08/23 15:39:05  martius
    00033  *   new IR sensor schema which uses substances and callbacks, very nice
    00034  *
    00035  *   Revision 1.10  2006/09/20 12:56:28  martius
    00036  *   setRange
    00037  *
    00038  *   Revision 1.9  2006/09/11 12:01:31  martius
    00039  *   *** empty log message ***
    00040  *
    00041  *   Revision 1.8  2006/08/28 12:18:31  martius
    00042  *   documentation
    00043  *
    00044  *   Revision 1.7  2006/08/08 17:03:27  martius
    00045  *   new sensors model
    00046  *
    00047  *   Revision 1.6  2006/07/14 12:23:43  martius
    00048  *   selforg becomes HEAD
    00049  *
    00050  *   Revision 1.5.4.4  2006/03/30 12:34:59  martius
    00051  *   documentation updated
    00052  *
    00053  *   Revision 1.5.4.3  2006/01/12 15:14:02  martius
    00054  *   some fwd decl.
    00055  *
    00056  *   Revision 1.5.4.2  2005/12/14 12:43:07  martius
    00057  *   moved to osg
    00058  *
    00059  *   Revision 1.5.4.1  2005/12/13 18:11:53  martius
    00060  *   sensors ported, but not yet finished
    00061  *
    00062  *   Revision 1.5  2005/11/09 13:24:20  martius
    00063  *   added exponent
    00064  *
    00065  *   Revision 1.4  2005/11/09 09:13:47  fhesse
    00066  *   geom is only enabled in sense function
    00067  *   there is no external collision detection anymore
    00068  *
    00069  *   Revision 1.3  2005/09/27 13:59:26  martius
    00070  *   ir sensors are working now
    00071  *
    00072  *   Revision 1.2  2005/09/27 11:03:34  fhesse
    00073  *   sensorbank added
    00074  *
    00075  *   Revision 1.1  2005/09/22 12:56:47  martius
    00076  *   ray based sensors
    00077  *
    00078  *                                                                         *
    00079  ***************************************************************************/
    00080 #ifndef __IRSENSOR_H
    00081 #define __IRSENSOR_H
    00082
    00083 #include "raysensor.h"
    00084
    00085 namespace lpzrobots {
    00086
    00087   class OSGCylinder;
    00088   class OSGBox;
    00089   class Transform;
    00090   class Ray;
    00091
    00092
    00093   /** Class for IR sensors.
    00094       IR sensors are based on distance measurements using the ODE geom class Ray.
    00095       The sensor value is obtained by collisions, which are handled by the simulation
    00096       environement. The information of a collision comes to the sensor via the
    00097       collision callback of the substance used for the ray (actually for the transform).
    00098       However of no collision is detected the sensor needs to ajust its output as well.
    00099       Therefore a reset function is provided.
    00100   */
    00101   class IRSensor : public RaySensor {
    00102   public:
    00103     /**
    00104        @param exponent exponent of the sensor characteritic (default: 1 (linear))
    00105     */
    00106     IRSensor(float exponent = 1, double size = 0.05);
    00107
    00108     virtual ~IRSensor();
    00109
    00110     virtual void init(const OdeHandle& odeHandle,
    00111                       const OsgHandle& osgHandle,
    00112                       Primitive* body,
    00113                       const osg::Matrix pose, float range,
    00114                       rayDrawMode drawMode = drawSensor);
    00115
    00116     virtual void reset();
    00117
    00118     /** returns the sensor value in the range [0,1];
    00119         0 means nothing no object in the sensor distance range
    00120         1 means contact with another object
    00121         @see characteritic()
    00122      */
    00123     virtual double get();
    00124     virtual void update();
    00125
    00126     virtual void setRange(float range);
    00127
    00128     virtual void setLength(float len);
    00129
    00130     virtual RaySensor* clone() const;
    00131
    00132     /// returns the exponent of the sensor characteritic (default: 1 (linear))
    00133     double getExponent () const { return exponent;}
    00134
    00135     /// sets the exponent of the sensor characteritic (default: 1 (linear))
    00136     void   setExponent (float exp) { exponent = exp;}
    00137
    00138   protected:
    00139     /** describes the sensor characteritic
    00140         An exponential curve is used.
    00141         @see setExponent()
    00142     */
    00143     virtual float characteritic(float len);
    00144
    00145   protected:
    00146     float range; // max length
    00147     float len;   // last measured length
    00148     float value; // actual sensor value
    00149     float exponent; // exponent of the sensor characteritic
    00150
    00151     double size; // size of graphical sensor
    00152
    00153     OSGCylinder* sensorBody;
    00154     //    OSGBox* sensorRay;
    00155     OsgHandle osgHandle;
    00156
    00157     Transform* transform;
    00158     Ray* ray;
    00159     bool initialised;
    00160   };
    00161
    00162 }
    00163
    00164 #endif