iCub-main
LinearScaler.cpp
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 #include <cfloat>
20 #include <sstream>
21 
22 #include <yarp/os/Value.h>
23 
25 
26 namespace iCub {
27 namespace learningmachine {
28 
29 LinearScaler::LinearScaler(double s, double o)
30  : IScaler(s, o) {
31  this->setName("LinearScaler");
32 }
33 
34 std::string LinearScaler::getInfo() {
35  std::ostringstream buffer;
36  buffer << this->IScaler::getInfo();
37  return buffer.str();
38 }
39 
40 void LinearScaler::writeBottle(yarp::os::Bottle& bot) {
41  // make sure to call the superclass's method
42  this->IScaler::writeBottle(bot);
43 }
44 
45 void LinearScaler::readBottle(yarp::os::Bottle& bot) {
46  // make sure to call the superclass's method (will reset transformer)
47  this->IScaler::readBottle(bot);
48 }
49 
50 bool LinearScaler::configure(yarp::os::Searchable& config) {
51  bool success = this->IScaler::configure(config);
52 
53  // set the desired scale (double)
54  if(config.find("scale").isFloat64() || config.find("scale").isInt32()) {
55  this->setScale(1. / config.find("scale").asFloat64());
56  success = true;
57  }
58  // set the desired offset (double)
59  if(config.find("offset").isFloat64() || config.find("offset").isInt32()) {
60  this->setOffset(config.find("offset").asFloat64());
61  success = true;
62  }
63 
64  return success;
65 }
66 
67 } // learningmachine
68 } // iCub
69 
The IScaler is a linear scaler based scaler.
Definition: IScaler.h:41
virtual std::string getInfo()
Asks the learning machine to return a string containing statistics on its operation so far.
Definition: IScaler.cpp:40
virtual void writeBottle(yarp::os::Bottle &bot)
Writes a serialization of the scaler into a bottle.
Definition: IScaler.cpp:61
void setName(std::string name)
Set the name of this machine learning technique.
Definition: IScaler.h:140
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a scaler from a bottle.
Definition: IScaler.cpp:67
virtual bool configure(yarp::os::Searchable &config)
Definition: IScaler.cpp:73
virtual void setOffset(double o)
Mutator for the offset.
Definition: LinearScaler.h:98
virtual void setScale(double s)
Mutator for the scaling factor.
Definition: LinearScaler.h:86
virtual bool configure(yarp::os::Searchable &config)
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a scaler from a bottle.
virtual void writeBottle(yarp::os::Bottle &bot)
Writes a serialization of the scaler into a bottle.
LinearScaler(double s=1, double o=0)
Constructor.
virtual std::string getInfo()
Asks the learning machine to return a string containing statistics on its operation so far.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.