Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parametrizable.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 
25 #ifndef __PARAMETRIZABLE_H
26 #define __PARAMETRIZABLE_H
27 
28 #include <selforg/matrix.h>
29 #include <list>
30 #include <functional>
31 
32 typedef std::list<matrix::Matrix> ParameterList;
33 /// using ParameterList = std::list<matrix::Matrix>;
34 
35 /**
36  Interface for parametrizable controller.
37  Which expose a set of parameters that be set from outside.
38 */
40 public:
41 
42  virtual ~Parametrizable() {}
43 
44  /** Returns a list of matrices that parametrize the controller
45  */
46  virtual ParameterList getParameters() const = 0;
47 
48  /** sets the parameters.
49  The list must have the same length as returned by getParameters()
50  The matrix dimensions must fit those given by getParameters()
51  @return 0 for failure, 1 for success and 2 if parameters had been changed during setting (to be valid)
52  such that a get is required to get the actual values
53  */
54  virtual int setParameters(const ParameterList& params) = 0;;
55 
56 };
57 
58 ParameterList lift2PL(const ParameterList& pl1,const ParameterList& pl2,
59  std::function<matrix::Matrix (const matrix::Matrix&, const matrix::Matrix&)> fun);
60 ParameterList liftPL(const ParameterList& pl,std::function<matrix::Matrix (const matrix::Matrix&)> fun);
61 
62 ParameterList mapPL(const ParameterList& pl, double (*fun)(double));
63 ParameterList divCompPL(const ParameterList& pl1,const ParameterList& pl2);
64 
65 // assign values of pls to pld (keeps references to pld valid)
66 void assignPL(ParameterList& pld, const ParameterList& pls);
67 
68 ParameterList addPL(const ParameterList& pl1,const ParameterList& pl2);
70 ParameterList scalePL(const ParameterList& pl,double f);
71 
72 #endif
Matrix type.
Definition: matrix.h:65
std::list< matrix::Matrix > ParameterList
Definition: parametrizable.h:32
ParameterList scalePL(const ParameterList &pl, double f)
Definition: parametrizable.cpp:72
virtual ParameterList getParameters() const =0
Returns a list of matrices that parametrize the controller.
ParameterList divCompPL(const ParameterList &pl1, const ParameterList &pl2)
Definition: parametrizable.cpp:51
ParameterList mapPL(const ParameterList &pl, double(*fun)(double))
Definition: parametrizable.cpp:46
virtual ~Parametrizable()
Definition: parametrizable.h:42
ParameterList lift2PL(const ParameterList &pl1, const ParameterList &pl2, std::function< matrix::Matrix(const matrix::Matrix &, const matrix::Matrix &)> fun)
Definition: parametrizable.cpp:29
ParameterList liftPL(const ParameterList &pl, std::function< matrix::Matrix(const matrix::Matrix &)> fun)
Definition: parametrizable.cpp:39
ParameterList subtractPL(const ParameterList &pl1, const ParameterList &pl2)
Definition: parametrizable.cpp:68
using ParameterList = std::list<matrix::Matrix>;
Definition: parametrizable.h:39
ParameterList addPL(const ParameterList &pl1, const ParameterList &pl2)
Definition: parametrizable.cpp:64
void assignPL(ParameterList &pld, const ParameterList &pls)
Definition: parametrizable.cpp:57
virtual int setParameters(const ParameterList &params)=0
sets the parameters.