iCub-main
models.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3  * Author: Ugo Pattacini
4  * email: ugo.pattacini@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
36 #ifndef __PERCEPTIVEMODELS_MODELS_H__
37 #define __PERCEPTIVEMODELS_MODELS_H__
38 
39 #include <string>
40 #include <map>
41 #include <ostream>
42 
43 #include <yarp/os/Value.h>
44 #include <yarp/os/Property.h>
45 
46 #include <iCub/perception/nodes.h>
47 
48 
49 namespace iCub
50 {
51 
52 namespace perception
53 {
54 
61 class Model
62 {
63 protected:
64  std::string name;
65  int verbosity;
66 
67  std::map<std::string,Node*> nodes;
68 
69  virtual void printMessage(const int logtype, const int level,
70  const char *format, ...) const;
71 
72 public:
76  Model();
77 
82  std::string getName() const
83  {
84  return name;
85  }
86 
92  void attachNode(Node &node);
93 
99  Node* getNode(const std::string &name) const;
100 
108  virtual bool fromProperty(const yarp::os::Property &options) = 0;
109 
115  virtual void toProperty(yarp::os::Property &options) const = 0;
116 
125  virtual bool toStream(std::ostream &str) const = 0;
126 
138  virtual bool calibrate(const yarp::os::Property &options) = 0;
139 
146  virtual bool isCalibrated() const = 0;
147 
154  virtual bool getOutput(yarp::os::Value &out) const = 0;
155 
159  virtual ~Model() { }
160 };
161 
162 
163 }
164 
165 }
166 
167 #endif
168 
169 
An abstract class that provides basic methods for interfacing with the data acquisition.
Definition: models.h:62
virtual bool toStream(std::ostream &str) const =0
Similar to the toProperty() method but it operates on output streams (e.g.
virtual void printMessage(const int logtype, const int level, const char *format,...) const
Definition: models.cpp:39
virtual bool getOutput(yarp::os::Value &out) const =0
Provide the higher layers with the model output computed over the attached sensors.
virtual bool isCalibrated() const =0
Return the internal status of the calibration.
Node * getNode(const std::string &name) const
Retrieve an attached node by its name.
Definition: models.cpp:80
void attachNode(Node &node)
Attach a node object to the model.
Definition: models.cpp:73
virtual bool calibrate(const yarp::os::Property &options)=0
Some kinds of models need to be calibrated to properly operate.
virtual ~Model()
Destructor.
Definition: models.h:159
virtual bool fromProperty(const yarp::os::Property &options)=0
Configure the model taking its parameters from a Property object.
std::map< std::string, Node * > nodes
Definition: models.h:67
std::string name
Definition: models.h:64
Model()
Constructor.
Definition: models.cpp:32
virtual void toProperty(yarp::os::Property &options) const =0
Return a Property representation of all the model parameters.
std::string getName() const
Retrieve the model name.
Definition: models.h:82
An abstract class that exposes the basic methods for the handling of data acquired through the attach...
Definition: nodes.h:94
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
out
Definition: sine.m:8