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:
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 
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 
iCub::perception::Model::Model
Model()
Constructor.
Definition: models.cpp:32
iCub::perception::Model::getNode
Node * getNode(const std::string &name) const
Retrieve an attached node by its name.
Definition: models.cpp:80
iCub
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
Definition: emotionInterface.h:17
iCub::perception::Model::getOutput
virtual bool getOutput(yarp::os::Value &out) const =0
Provide the higher layers with the model output computed over the attached sensors.
out
out
Definition: sine.m:8
iCub::perception::Model::toStream
virtual bool toStream(std::ostream &str) const =0
Similar to the toProperty() method but it operates on output streams (e.g.
iCub::perception::Model::~Model
virtual ~Model()
Destructor.
Definition: models.h:159
iCub::perception::Node
Definition: nodes.h:93
iCub::perception::Model::isCalibrated
virtual bool isCalibrated() const =0
Return the internal status of the calibration.
iCub::perception::Model::getName
std::string getName() const
Retrieve the model name.
Definition: models.h:82
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
iCub::perception::Model::attachNode
void attachNode(Node &node)
Attach a node object to the model.
Definition: models.cpp:73
nodes.h
iCub::perception::Model
Definition: models.h:61
iCub::perception::Model::fromProperty
virtual bool fromProperty(const yarp::os::Property &options)=0
Configure the model taking its parameters from a Property object.
iCub::perception::Model::printMessage
virtual void printMessage(const int logtype, const int level, const char *format,...) const
Definition: models.cpp:39
iCub::perception::Model::name
std::string name
Definition: models.h:64
iCub::perception::Model::verbosity
int verbosity
Definition: models.h:65
iCub::perception::Model::nodes
std::map< std::string, Node * > nodes
Definition: models.h:67
iCub::perception::Model::toProperty
virtual void toProperty(yarp::os::Property &options) const =0
Return a Property representation of all the model parameters.
iCub::perception::Model::calibrate
virtual bool calibrate(const yarp::os::Property &options)=0
Some kinds of models need to be calibrated to properly operate.