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