iCub-main
PredictEventListener.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 
29  if(this->verbose) {
30  std::cout << "PredictEvent: " << e.toString() << std::endl;
31  }
32  yarp::os::Bottle b, p;
33  this->vectorToBottle(e.getInput(), b.addList());
34  p = b.addList();
35  this->vectorToBottle(e.getPredicted().getPrediction(), p.addList());
36  this->vectorToBottle(e.getPredicted().getVariance(), p.addList());
37  this->port.write(b);
38 }
39 
40 } // learningmachine
41 } // iCub
yarp::os::Port port
The outgoing port for the events.
bool verbose
Verbosity controls whether events are printed to standard output.
void vectorToBottle(const yarp::sig::Vector &vec, yarp::os::Bottle &bot)
void handle(PredictEvent &e)
Handling of a PredictEvent.
yarp::sig::Vector & getInput()
Accessor for the vector of inputs.
Definition: PredictEvent.h:85
Prediction & getPredicted()
Accessor for the prediction.
Definition: PredictEvent.h:93
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
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.