/***************************************************************************
 *   Copyright (C) 2005 by Robot Group Leipzig                             *
 *    martius@informatik.uni-leipzig.de                                    *
 *    fhesse@informatik.uni-leipzig.de                                     *
 *    der@informatik.uni-leipzig.de                                        *
 *                                                                         *
 *   ANY COMMERCIAL USE FORBIDDEN!                                         *
 *   LICENSE:                                                              *
 *   This work is licensed under the Creative Commons                      *
 *   Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of   *
 *   this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ *
 *   or send a letter to Creative Commons, 543 Howard Street, 5th Floor,   *
 *   San Francisco, California, 94105, USA.                                *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
 *                                                                         *
 *   $Log: invertmotorcontroller.h,v $
 *   Revision 1.33  2009/08/05 23:05:13  martius
 *   comment for the last version:
 *    changed to HomeokinBase type (cleaned version)
 *   this class only adds some additional parameters
 *
 *   Revision 1.32  2009/08/05 23:03:17  martius
 *   changed to more convenient style of Matrix::mapP with normal double param
 *
 *   Revision 1.31  2007/12/11 14:44:28  martius
 *   possible segfault bug in buffer function
 *
 *   Revision 1.30  2007/04/20 12:26:35  martius
 *   *** empty log message ***
 *
 *   Revision 1.29  2007/02/23 09:40:45  der
 *   regularisation used from regularisation.h
 *
 *   Revision 1.28  2007/01/24 14:39:10  martius
 *   use new configurable addParameter feature
 *
 *   Revision 1.27  2006/12/21 11:44:17  martius
 *   commenting style for doxygen //< -> ///<
 *   FOREACH and FOREACHC are macros for collection iteration
 *
 *   Revision 1.26  2006/12/11 18:14:14  martius
 *   delete for BNoise
 *   delete of buffers
 *
 *   Revision 1.25  2006/11/29 16:22:43  martius
 *   name is a variable of configurable and is used as such
 *
 *   Revision 1.24  2006/10/20 13:32:35  der
 *   fantasy
 *
 *   Revision 1.23  2006/08/02 09:30:16  martius
 *   virtualized new calc functions
 *   calcErrorFactor added
 *
 *   Revision 1.22  2006/07/20 17:14:34  martius
 *   removed std namespace from matrix.h
 *   storable interface
 *   abstract model and invertablemodel as superclasses for networks
 *
 *   Revision 1.21  2006/07/18 15:17:16  martius
 *   buffer operations like delayed values and smoothed values moved to invertmotorcontroller
 *
 *   Revision 1.20  2006/07/18 14:47:15  martius
 *   new regularisation of g' and g''/g'
 *   g''/g' uses the same clipped z which used for g'
 *   sqashing function with variable squash size
 *
 *   Revision 1.19  2006/07/14 12:23:58  martius
 *   selforg becomes HEAD
 *
 *   Revision 1.17.6.10  2006/07/10 13:05:16  martius
 *   NON-COMMERICAL LICENSE added to controllers
 *
 *                                                                         *
 ***************************************************************************/

#ifndef __INVERTMOTORCONTROLLER_H
#define __INVERTMOTORCONTROLLER_H

#include "homeokinbase.h"
#include "controller_misc.h"
#include <stdlib.h>
#include <string.h>


/**
 * Extended HomeokinBase class (still abstract) for robot controller work in motorspace
 * and use possibly many steps and adaptive learning rate
 * 
 * Parameters like dampA, adaptrate, noiseY...
 */
class InvertMotorController : public HomeokinBase { 
public:
  InvertMotorController( unsigned short buffersize ,
			 const std::string& name, const std::string& revision)
    : HomeokinBase(buffersize,name, revision){
    addParameterDef("dampA",&dampA,0 ); 
    addParameterDef("adaptrate",&adaptRate,0.000);
    addParameterDef("nomupdate",&nomUpdate,0.005);
    addParameterDef("desens",&desens,0);          
    addParameterDef("steps",&steps,1); 
    addParameterDef("zetaupdate",&zetaupdate,0); 
    addParameterDef("noiseY",&noiseY,0);
    addParameterDef("noiseB",&noiseB,0.001);
    addParameterDef("teacher",&teacher,5);
    addParameterDef("relativeE",&relativeE,0);
  }

protected:
  paramval desens;
  paramval steps; ///< number of timesteps is used for controller learning
  paramval zetaupdate;
  paramval dampA; ///< damping term for model (0: no damping, 0.1 high damping)
  parambool relativeE; ///< if not 0: a relative error signal is used (xsi is normalised in respect to |y|)

  paramval adaptRate;  ///< adaptation rate for learning rate adaptation
  paramval nomUpdate;  ///< nominal update of controller in respect to matrix norm
  paramval noiseB;     ///< size of the additional noise for model bias B
  paramval noiseY;     ///< size of the additional noise for motor values
  paramval teacher;    ///< factor for teaching signal
 
};

#endif
