iCub-main
TrainEventListener.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2010 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 <iostream>
20 
21 #include <yarp/os/Bottle.h>
22 
24 
25 namespace iCub {
26 namespace learningmachine {
27 
28 
30  if(this->verbose) {
31  std::cout << "TrainEvent: " << e.toString() << std::endl;
32  }
33 
34  yarp::os::Bottle b, p;
35  this->vectorToBottle(e.getInput(), b.addList());
36  this->vectorToBottle(e.getDesired(), b.addList());
37  p = b.addList();
38  this->vectorToBottle(e.getPredicted().getPrediction(), p.addList());
39  this->vectorToBottle(e.getPredicted().getVariance(), p.addList());
40  this->port.write(b);
41 }
42 
43 
44 } // learningmachine
45 } // iCub
yarp::os::Port port
The outgoing port for the events.
bool verbose
Verbosity controls whether events are printed to standard output.
yarp::sig::Vector getVariance()
Accessor for the variance of the prediction.
Definition: Prediction.h:125
yarp::sig::Vector getPrediction()
Accessor for the expected value of the prediction.
Definition: Prediction.h:106
void handle(TrainEvent &e)
Handling of a TrainEvent.
void vectorToBottle(const yarp::sig::Vector &vec, yarp::os::Bottle &bot)
A TrainEvent is raised when the machine handles a training sample.
Definition: TrainEvent.h:44
Prediction & getPredicted()
Accessor for the prediction.
Definition: TrainEvent.h:106
yarp::sig::Vector & getDesired()
Accessor for the vector of desired outputs.
Definition: TrainEvent.h:98
yarp::sig::Vector & getInput()
Accessor for the vector of inputs.
Definition: TrainEvent.h:90
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.