/***************************************************************************
 *   Copyright (C) 2005 by Robot Group Leipzig                             *
 *    martius@informatik.uni-leipzig.de                                    *
 *    fhesse@informatik.uni-leipzig.de                                     *
 *    der@informatik.uni-leipzig.de                                        *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   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.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 *                                                                         *
 *   $Log: sinecontroller.h,v $
 *   Revision 1.9  2006/08/02 09:32:03  martius
 *   store and restore according to storable interface
 *
 *   Revision 1.8  2006/07/14 12:23:59  martius
 *   selforg becomes HEAD
 *
 *   Revision 1.6.6.5  2006/06/25 21:56:08  martius
 *   configureable has name and revision
 *
 *   Revision 1.6.6.4  2006/06/25 16:51:36  martius
 *   configureable has name and revision
 *   a robot is configureable by default
 *
 *   Revision 1.6.6.3  2006/03/30 12:35:13  martius
 *   documentation updated
 *
 *   Revision 1.6.6.2  2006/01/18 16:48:35  martius
 *   stored and restore
 *
 *   Revision 1.6.6.1  2005/11/14 15:38:17  martius
 *   moved to selforg
 *
 *   Revision 1.6  2005/11/14 12:46:19  martius
 *   added number of controlled motors
 *
 *   Revision 1.5  2005/11/09 13:56:34  martius
 *   const in instspectable functions
 *
 *   Revision 1.4  2005/10/06 17:06:57  martius
 *   switched to stl lists
 *
 *   Revision 1.3  2005/08/06 20:47:54  martius
 *   Commented
 *
 *   Revision 1.2  2005/07/07 10:25:47  martius
 *   added Phaseshift
 *
 *   Revision 1.1  2005/07/06 13:55:33  fhesse
 *   initial version, realising sine and cosine outputs
 *                                            *
 *                                                                         *
 ***************************************************************************/
#ifndef __SINECONTROLLER_H
#define __SINECONTROLLER_H


#include <stdio.h>
#include "abstractcontroller.h"

/**
 * class for robot control with sine and cosine 
 * 
 * 
 */
class SineController : public AbstractController {
public:

  SineController(int number_controlled=-1);

  /** initialisation of the controller with the given sensor/ motornumber 
      Must be called before use.
  */
  virtual void init(int sensornumber, int motornumber);
  
  /** @return Number of sensors the controller was initialised 
      with or 0 if not initialised */
  virtual int getSensorNumber() const {return number_sensors;}


  /** @return Number of motors the controller was initialised 
      with or 0 if not initialised */
  virtual int getMotorNumber() const {return number_motors;}

  /** performs one step (includes learning). 
      Calculates motor commands from sensor inputs.
      @param sensors sensors inputs scaled to [-1,1]
      @param sensornumber length of the sensor array
      @param motors motors outputs. MUST have enough space for motor values!
      @param motornumber length of the provided motor array
  */
  virtual void step(const sensor* sensors, int sensornumber, 
		    motor* motors, int motornumber);
  /** performs one step without learning. 
      @see step
  */
  virtual void stepNoLearning(const sensor* , int number_sensors, 
			      motor* , int number_motors);
  

  /** The list of the names of all internal parameters given by getInternalParams().
      @return list of names
   */
  virtual std::list<iparamkey> getInternalParamNames()const  { return std::list<iparamkey>(); }

  /** The list of the names of all internal parameters given by getInternalParams().
   */
  virtual std::list<iparamval> getInternalParams() const { return std::list<iparamval>(); }
  

  virtual paramval getParam(const paramkey& key) const;
  virtual bool setParam(const paramkey& key, paramval val);
  virtual paramlist getParamList() const ;

  /********* STORABLE INTERFACE ******/
  /// @see Storable
  virtual bool store(FILE* f) const { return true;};  // FIXME: store Parameter

  /// @see Storable
  virtual bool restore(FILE* f) { return true;}; // FIXME: restore Parameter


protected:

  int t;
  std::string name;
  int number_sensors;
  int number_motors;
  int number_controlled; // number of motors that are controlled. The remaining are set to 0;

  paramval sineRate;
  paramval phaseShift;
};

#endif 
