iCub-main
sensors.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 
94 #ifndef __PERCEPTIVEMODELS_SENSORS_H__
95 #define __PERCEPTIVEMODELS_SENSORS_H__
96 
97 #include <string>
98 
99 #include <yarp/os/Value.h>
100 #include <yarp/os/Property.h>
101 
102 
103 namespace iCub
104 {
105 
106 namespace perception
107 {
108 
115 class Sensor
116 {
117 protected:
120  void *source;
121 
122 public:
126  Sensor();
127 
133  {
134  return name;
135  }
136 
145  virtual bool configure(void *source, const yarp::os::Property &options) = 0;
146 
152  virtual bool getOutput(yarp::os::Value &in) const = 0;
153 
157  virtual ~Sensor() { }
158 };
159 
160 
166 class SensorEncoders : public Sensor
167 {
168 protected:
169  int size;
170  int index;
171 
172 public:
184  bool configure(void *source, const yarp::os::Property &options);
185 
191  bool getOutput(yarp::os::Value &in) const;
192 };
193 
194 
200 class SensorPort : public Sensor
201 {
202 protected:
203  int index;
204 
205 public:
216  bool configure(void *source, const yarp::os::Property &options);
217 
223  bool getOutput(yarp::os::Value &in) const;
224 };
225 
226 
227 }
228 
229 }
230 
231 #endif
232 
233 
iCub::perception::SensorEncoders::configure
bool configure(void *source, const yarp::os::Property &options)
Configure the sensor.
Definition: sensors.cpp:43
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::SensorEncoders::index
int index
Definition: sensors.h:170
iCub::perception::Sensor
Definition: sensors.h:115
iCub::perception::SensorEncoders
Definition: sensors.h:166
iCub::perception::Sensor::source
void * source
Definition: sensors.h:120
iCub::perception::SensorPort
Definition: sensors.h:200
iCub::perception::Sensor::Sensor
Sensor()
Constructor.
Definition: sensors.cpp:34
iCub::perception::SensorEncoders::size
int size
Definition: sensors.h:169
iCub::perception::Sensor::configure
virtual bool configure(void *source, const yarp::os::Property &options)=0
Configure the sensor.
iCub::perception::SensorPort::configure
bool configure(void *source, const yarp::os::Property &options)
Configure the sensor.
Definition: sensors.cpp:73
iCub::perception::Sensor::configured
bool configured
Definition: sensors.h:119
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
iCub::perception::Sensor::getOutput
virtual bool getOutput(yarp::os::Value &in) const =0
Retrieve the sensor raw output.
iCub::perception::SensorPort::getOutput
bool getOutput(yarp::os::Value &in) const
Retrieve the sensor output.
Definition: sensors.cpp:87
iCub::perception::Sensor::getName
std::string getName() const
Retrieve the sensor name.
Definition: sensors.h:132
iCub::perception::SensorEncoders::getOutput
bool getOutput(yarp::os::Value &in) const
Retrieve the sensor joint value.
Definition: sensors.cpp:59
iCub::perception::Sensor::name
std::string name
Definition: sensors.h:118
iCub::perception::SensorPort::index
int index
Definition: sensors.h:203
iCub::perception::Sensor::~Sensor
virtual ~Sensor()
Destructor.
Definition: sensors.h:157