iCub-main
IFixedSizeTransformer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2011 RobotCub Consortium, European Commission FP6 Project IST-004370
3  * author: Arjan Gijsberts
4  * email: arjan.gijsberts@iit.it
5  * website: www.robotcub.org
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17  */
18 
19 #ifndef LM_IFIXEDSIZETRANSFORMER__
20 #define LM_IFIXEDSIZETRANSFORMER__
21 
23 
24 
25 namespace iCub {
26 namespace learningmachine {
27 
40 protected:
44  unsigned int domainSize;
45 
49  unsigned int coDomainSize;
50 
57  virtual bool checkDomainSize(const yarp::sig::Vector& input) {
58  return ((unsigned int) input.size() == this->getDomainSize());
59  }
60 
67  virtual bool checkCoDomainSize(const yarp::sig::Vector& output) {
68  return ((unsigned int) output.size() == this->getCoDomainSize());
69  }
70 
78  void validateDomainSizes(const yarp::sig::Vector& input, const yarp::sig::Vector& output);
79 
80  /*
81  * Inherited from ITransformer.
82  */
83  virtual void writeBottle(yarp::os::Bottle& bot) const;
84 
85  /*
86  * Inherited from ITransformer.
87  */
88  virtual void readBottle(yarp::os::Bottle& bot);
89 
90 public:
97  IFixedSizeTransformer(unsigned int dom = 1, unsigned int cod = 1) : domainSize(dom), coDomainSize(cod) { }
98 
99  /*
100  * Inherited from ITransformer.
101  */
102  virtual yarp::sig::Vector transform(const yarp::sig::Vector& input);
103 
109  unsigned int getDomainSize() const {
110  return this->domainSize;
111  }
112 
118  unsigned int getCoDomainSize() const {
119  return this->coDomainSize;
120  }
121 
127  virtual void setDomainSize(unsigned int size) {
128  this->domainSize = size;
129  }
130 
136  virtual void setCoDomainSize(unsigned int size) {
137  this->coDomainSize = size;
138  }
139 
140  /*
141  * Inherited from ITransformer.
142  */
143  virtual std::string getInfo();
144 
145  /*
146  * Inherited from ITransformer.
147  */
148  virtual std::string getConfigHelp();
149 
150  /*
151  * Inherited from ITransformer.
152  */
153  virtual bool configure(yarp::os::Searchable& config);
154 
155 };
156 
157 } // learningmachine
158 } // iCub
159 
160 #endif
An generalized interface for an ITransformer with a fixed domain and codomain size.
virtual std::string getConfigHelp()
Asks the transformer to return a string containing the list of configuration options that it supports...
virtual yarp::sig::Vector transform(const yarp::sig::Vector &input)
Transforms an input vector.
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a transformer from a bottle.
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
IFixedSizeTransformer(unsigned int dom=1, unsigned int cod=1)
Constructor.
virtual bool checkDomainSize(const yarp::sig::Vector &input)
Checks whether the input is of the desired dimensionality.
unsigned int getCoDomainSize() const
Returns the size (dimensionality) of the output domain (codomain).
unsigned int coDomainSize
The dimensionality of the output domain (codomain).
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the transformer into a bottle.
void validateDomainSizes(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Validates whether the input and output are of the desired dimensionality.
virtual bool configure(yarp::os::Searchable &config)
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
virtual std::string getInfo()
Asks the transformer to return a string containing statistics on its operation so far.
unsigned int getDomainSize() const
Returns the size (dimensionality) of the input domain.
unsigned int domainSize
The dimensionality of the input domain.
virtual bool checkCoDomainSize(const yarp::sig::Vector &output)
Checks whether the output is of the desired dimensionality.
A class that provides a preprocessing interface, which can be used to preprocess the data samples tha...
Definition: ITransformer.h:57
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.