iCub-main
Prediction.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 <cassert>
20 
21 //#include "iCub/learningMachine/Prediction.h"
22 
23 namespace iCub {
24 namespace learningmachine {
25 // whole implementation is moved to header
26 // move back here in case of problems
27 /*
28 void Prediction::setVariance(const yarp::sig::Vector& variance) {
29  assert(prediction.size() == variance.size() || variance.size() == 0);
30  this->variance = variance;
31  this->varianceSet = (variance.size() > 0);
32 }
33 
34 std::string Prediction::toString() {
35  std::string out = this->prediction.toString().c_str();
36  if(this->hasVariance()) {
37  out += std::string(" +/- ") + this->variance.toString().c_str();
38  }
39  return out;
40 }
41 
42 bool Prediction::write(yarp::os::ConnectionWriter& connection) {
43  // follows PortablePair implementation
44  connection.appendInt32(BOTTLE_TAG_LIST);
45  connection.appendInt32(2);
46 
47  bool ok = this->prediction.write(connection);
48  if (ok) {
49  ok = this->variance.write(connection);
50  }
51 
52  if (ok) {
53  connection.convertTextMode();
54  }
55 
56  return ok;
57 }
58 
59 bool Prediction::read(yarp::os::ConnectionReader& connection) {
60  // follows PortablePair implementation
61  connection.convertTextMode();
62 
63  int header = connection.expectInt32();
64  if(header != BOTTLE_TAG_LIST) {
65  return false;
66  }
67 
68  int len = connection.expectInt32();
69  if(len != 2) {
70  return false;
71  }
72 
73  bool ok = this->prediction.read(connection);
74  if (ok) {
75  ok = this->variance.read(connection);
76  }
77  this->varianceSet = (this->variance.size() > 0);
78  return ok;
79 }
80 
81 void Prediction::onCompletion() {
82  this->prediction.onCompletion();
83  this->variance.onCompletion();
84 }
85 */
86 
87 } // learningmachine
88 } // iCub
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.