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

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

- Search for |

- File List
- File Members

# motornoisewiring.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: motornoisewiring.h,v $
    00023  *   Revision 1.2  2009/03/31 15:47:11  martius
    00024  *   works now
    00025  *
    00026  *   Revision 1.1  2009/03/31 07:36:18  martius
    00027  *   wiring to add noise on motor channels
    00028  *
    00029
    00030  *                                                                         *
    00031  ***************************************************************************/
    00032 #ifndef __MOTORNOISEWIRING_H
    00033 #define __MOTORNOISEWIRING_H
    00034
    00035 #include <selforg/one2onewiring.h>
    00036 #include <selforg/configurable.h>
    00037
    00038 /**
    00039  *   Implements a one to one wiring that adds noise to the motor signals
    00040  *   (the sensors will get no noise)
    00041  */
    00042 class MotorNoiseWiring : public One2OneWiring, public Configurable {
    00043 public:
    00044   /** constructor
    00045       @param noise NoiseGenerator that is used for adding noise to motor values
    00046   */
    00047   MotorNoiseWiring(NoiseGenerator* noise, double noiseStrength)
    00048     : One2OneWiring(0),    // no noise at sensors
    00049       Configurable("MotorNoiseWiring", "$Id: motornoisewiring.h,v 1.2 2009/03/31 15:47:11 martius Exp $"),
    00050       mNoiseGen(noise), noiseStrength(noiseStrength) {
    00051     addParameter("strength",&noiseStrength);
    00052   }
    00053   virtual ~MotorNoiseWiring(){}
    00054
    00055   virtual bool init(int robotsensornumber, int robotmotornumber, RandGen* randGen=0){
    00056     One2OneWiring::init(robotsensornumber, robotmotornumber, randGen);
    00057     if(mNoiseGen)
    00058       mNoiseGen->init(rmotornumber, randGen);
    00059     return true;
    00060   }
    00061
    00062   virtual bool wireMotors(motor* rmotors, int rmotornumber,
    00063                           const motor* cmotors, int cmotornumber){
    00064     One2OneWiring::wireMotors(rmotors, rmotornumber, cmotors, cmotornumber);
    00065     if(mNoiseGen)
    00066       mNoiseGen->add(rmotors, noiseStrength);
    00067     return true;
    00068   }
    00069
    00070 protected:
    00071   NoiseGenerator* mNoiseGen;
    00072   double noiseStrength;
    00073
    00074 };
    00075
    00076 #endif