Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

IRSensor.h

Go to the documentation of this file.
00001 /*
00002     Enki - a fast 2D robot simulator
00003     Copyright (C) 1999-2005 Stephane Magnenat <nct@ysagoon.com>
00004     Copyright (C) 2004-2005 Markus Waibel <markus.waibel@epfl.ch>
00005     Copyright (C) 2005 Laboratory of Intelligent Systems, EPFL, Lausanne
00006     See AUTHORS for details
00007 
00008     This program is free software; the authors of any publication 
00009     arising from research using this software are asked to add the 
00010     following reference:
00011     Enki - a fast 2D robot simulator part of the Teem framework
00012     http://teem.epfl.ch
00013     Stephane Magnenat <stephane.magnenat@epfl.ch>,
00014     Markus Waibel <markus.waibel@epfl.ch>
00015     Laboratory of Intelligent Systems, EPFL, Lausanne.
00016 
00017     You can redistribute this program and/or modify
00018     it under the terms of the GNU General Public License as published by
00019     the Free Software Foundation; either version 2 of the License, or
00020     (at your option) any later version.
00021 
00022     This program is distributed in the hope that it will be useful,
00023     but WITHOUT ANY WARRANTY; without even the implied warranty of
00024     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025     GNU General Public License for more details.
00026 
00027     You should have received a copy of the GNU General Public License
00028     along with this program; if not, write to the Free Software
00029     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030 */
00031 
00032 #ifndef __IRSENSOR_H
00033 #define __IRSENSOR_H
00034 
00035 #include <enki/PhysicalEngine.h>
00036 #include <enki/Interaction.h>
00037 
00038 #include <valarray>
00039 
00044 namespace Enki
00045 {
00050 
00051 
00052     struct SensorResponseFunctor
00053     {
00055         virtual ~SensorResponseFunctor() {}
00057         virtual double operator()(double, const An::Color &) = 0;
00058     };
00059     
00061 
00062     class IRSensor : public LocalInteraction
00063     {
00064     protected:
00066         An::Vector absPos;
00068         double absOrientation;
00070         An::Vector pos;
00072         double height;
00074         double orientation;
00076         double range;
00078         double aperture;
00080         unsigned rayCount;
00082 
00085         std::valarray<SensorResponseFunctor *> sensorResponseKernel;
00086         
00088         double smartRadius;
00090         An::Point smartPos;
00092         An::Vector absSmartPos;
00094         std::valarray<double> rayValues;
00096         std::valarray<An::Color> rayColors;
00098         std::valarray<double> rayAngles;
00100         std::valarray<double> absRayAngles;
00101     
00102     public:
00104         double finalValue;
00105         
00106     public:
00110         IRSensor(Robot *owner, An::Vector pos, double height, double orientation, double range, double aperture, unsigned rayCount, SensorResponseFunctor **sensorResponseKernel);
00112         void init();
00114         void objectStep(double dt, PhysicalObject *po, World *w);
00116         void wallsStep(World *w);
00118         void finalize(double dt);
00119         
00121         An::Point getAbsolutePosition(void) { return absPos; }
00123         double getAbsoluteOrientation(void) { return absOrientation; }
00125         unsigned getRayCount(void) { return rayCount; }
00127         double getAperture(void) { return aperture; }
00129         double getRange(void) { return range; }
00131         double getSmartRadius(void) { return smartRadius; }
00133         An::Point getAbsSmartPos(void) { return absSmartPos; }
00134     
00135     private:
00138         double distanceToPolygon(double rayAngle, const An::Polygone &p) const;
00139     };
00140 }
00141 
00142 #endif

Generated on Mon Oct 24 17:33:58 2005 for Enki by  doxygen 1.4.2