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

# soundsensor.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005-2011 LpzRobots development team                    *
    00003  *    Georg Martius  <georg dot martius at web dot de>                     *
    00004  *    Frank Guettler <guettler at informatik dot uni-leipzig dot de        *
    00005  *    Frank Hesse    <frank at nld dot ds dot mpg dot de>                  *
    00006  *    Ralf Der       <ralfder at mis dot mpg dot de>                       *
    00007  *                                                                         *
    00008  *   This program is free software; you can redistribute it and/or modify  *
    00009  *   it under the terms of the GNU General Public License as published by  *
    00010  *   the Free Software Foundation; either version 2 of the License, or     *
    00011  *   (at your option) any later version.                                   *
    00012  *                                                                         *
    00013  *   This program is distributed in the hope that it will be useful,       *
    00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
    00016  *   GNU General Public License for more details.                          *
    00017  *                                                                         *
    00018  *   You should have received a copy of the GNU General Public License     *
    00019  *   along with this program; if not, write to the                         *
    00020  *   Free Software Foundation, Inc.,                                       *
    00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
    00022  *                                                                         *
    00023  ***************************************************************************/
    00024 #ifndef         SOUNDSENSOR_H_
    00025 # define        SOUNDSENSOR_H_
    00026
    00027 #include "sensor.h"
    00028
    00029 namespace lpzrobots {
    00030
    00031   /** Sound sensor
    00032       with possible direction and frequency detection and also
    00033       distance dependence (Not implemented yet)
    00034       This works, but is not very well tested and documented.
    00035       The angle detection also works without sound and so on.
    00036       Take a look at the code before using it.
    00037   */
    00038   class SoundSensor: public Sensor {
    00039   public:
    00040     /* typedef */ enum Measure { Segments, Angle, AngleVel };
    00041
    00042     /** @param dim Up-axis of the robot (sometimes it is not Z)
    00043     */
    00044     SoundSensor(Dimensions dim = Z, Measure measure = Angle,
    00045                 int segments=1, int levels=1, float maxDistance=1000);
    00046     virtual ~SoundSensor();
    00047
    00048     virtual void init(Primitive* own){ this->own = own;}
    00049
    00050     virtual bool sense(const GlobalData& globaldata);
    00051
    00052     virtual int getSensorNumber() const;
    00053
    00054     virtual std::list<sensor> get() const;
    00055
    00056     virtual int get(sensor* sensors, int length) const;
    00057
    00058   private:
    00059     short dim; ///< the axis in which the sensor is selective around
    00060     Measure measure; ///< how to measure
    00061     int segments;
    00062     int levels;
    00063     float maxDistance;
    00064
    00065     double* val;
    00066     double* oldangle;
    00067
    00068     Primitive* own;
    00069
    00070   };
    00071
    00072
    00073
    00074
    00075 }
    00076
    00077 #endif      /* !SOUNDSENSOR_H_ */