oneactivemultipassivecontroller.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  *    frankguettler@gmx.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  *   $Log: oneactivemultipassivecontroller.h,v $
00024  *   Revision 1.2  2008/04/17 14:54:45  martius
00025  *   randomGen added, which is a random generator with long period and an
00026  *    internal state. Each Agent has an instance and passed it to the controller
00027  *    and the wiring. This is good for
00028  *   a) repeatability on agent basis,
00029  *   b) parallel execution as done in ode_robots
00030  *
00031  *   Revision 1.1  2007/03/22 08:15:30  robot3
00032  *   Special variant of an multicontroller, which has one main (active) controller
00033  *   and an arbitrary number of passive controllers. These passive controllers are like active controllers, but aren't be able to manipulate the motor values forwarded
00034  *   to the Agent. See ode_robots/simulations/MI_Simu for an example.
00035  *
00036 
00037  *                                                                         *
00038  ***************************************************************************/
00039 #ifndef __ONEACTIVEMULTIPASSIVECONTROLLER_H
00040 #define __ONEACTIVEMULTIPASSIVECONTROLLER_H
00041 
00042 #include "abstractmulticontroller.h"
00043 
00044 /**
00045  * class (interface) for using multiple controller, the first one is
00046  * the active one, which generates motor values. The other controllers
00047  * are passive and cannot affect the motor values.
00048  *
00049  */
00050 class OneActiveMultiPassiveController : public AbstractMultiController {
00051 public:
00052 
00053   /// contructor (hint: use $ID$ for revision)
00054         OneActiveMultiPassiveController(AbstractController* controller, std::string controllerName);
00055 
00056         virtual ~OneActiveMultiPassiveController();
00057 
00058 /****************************************************************************/
00059 /*      AbstractMultiController should implement the following classes:         */
00060 /*      AbstractController, Configurable, Inspectable, Storeable                    */
00061 /****************************************************************************/
00062 
00063 
00064 /****************************************************************************/
00065 /*      BEGIN methods of AbstractController                                     */
00066 /****************************************************************************/
00067 
00068   /** initialisation of the controller with the given sensor/ motornumber
00069    * Must NORMALLY be called before use. For all multicontroller
00070    * call first AbstractMultiController::init(sensornumber,motornumber)
00071    * if you overwrite this method
00072    */
00073         virtual void init(int sensornumber, int motornumber, RandGen* randGen = 0);
00074 
00075 
00076           /** performs one step (includes learning).
00077       Calculates motor commands from sensor inputs.
00078         @param sensors sensors inputs scaled to [-1,1]
00079         @param sensornumber length of the sensor array
00080         @param motors motors outputs. MUST have enough space for motor values!
00081         @param motornumber length of the provided motor array
00082   */
00083         virtual void step(const sensor* sensors, int sensornumber,
00084                           motor* motors, int motornumber);
00085 
00086   /** performs one step without learning.
00087         @see step
00088   */
00089         virtual void stepNoLearning(const sensor* sensors , int sensornumber,
00090                                     motor* motors, int motornumber);
00091 
00092 
00093 /****************************************************************************/
00094 /*      END methods of AbstractController                                           */
00095 /****************************************************************************/
00096 
00097 /****************************************************************************/
00098 /*      BEGIN methods of Configurable                                           */
00099 /****************************************************************************/
00100 
00101 
00102 
00103 /****************************************************************************/
00104 /*      END methods of Configurable                                                 */
00105 /****************************************************************************/
00106 
00107 /****************************************************************************/
00108 /*      BEGIN methods of Inspectable                                            */
00109 /****************************************************************************/
00110 
00111   /** The list of the names of all internal parameters given by getInternalParams().
00112       The naming convention is "v[i]" for vectors
00113        and "A[i][j]" for matrices, where i, j start at 0.
00114         @return: list of keys
00115    */
00116         virtual iparamkeylist getInternalParamNames() const {
00117                 return AbstractMultiController::getInternalParamNames();
00118                 // return all parameters from the other controllers
00119                 // return params from multicontroller itself
00120         }
00121 
00122           /** @return: list of values
00123    */
00124         virtual iparamvallist getInternalParams() const {
00125                 return AbstractMultiController::getInternalParams();
00126                 // return all parameters from the other controllers
00127                 // return params from multicontroller itself
00128         }
00129 
00130 /****************************************************************************/
00131 /*      END methods of Inspectable                                                  */
00132 /****************************************************************************/
00133 
00134 /****************************************************************************/
00135 /*      BEGIN methods of Storeable                                              */
00136 /****************************************************************************/
00137 
00138   /** stores the object to the given file stream (binary).
00139   */
00140         virtual bool store(FILE* f) const {
00141                 return controller->store(f);
00142                 // store the other controllers
00143                 // store values from multicontroller itself
00144         }
00145 
00146   /** loads the object from the given file stream (binary).
00147   */
00148         virtual bool restore(FILE* f) {
00149                 return controller->restore(f);
00150                 // restore the other controllers
00151                 // restore values from multicontroller itself
00152         }
00153 
00154 /****************************************************************************/
00155 /*      END methods of Storeable                                                    */
00156 /****************************************************************************/
00157 
00158 protected:
00159         motor* passiveMotors;
00160 };
00161 
00162 #endif

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7