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:
118  std::string name;
120  void *source;
121 
122 public:
126  Sensor();
127 
132  std::string getName() const
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 
202 {
203 protected:
207 
208 public:
221  bool configure(void *source, const yarp::os::Property &options);
222 
228  bool getOutput(yarp::os::Value &in) const;
229 };
230 
231 
237 class SensorPort : public Sensor
238 {
239 protected:
240  int index;
241 
242 public:
253  bool configure(void *source, const yarp::os::Property &options);
254 
260  bool getOutput(yarp::os::Value &in) const;
261 };
262 
263 
264 }
265 
266 }
267 
268 #endif
269 
270 
This class implements the reading of encoders through MultipleAnalogSensors (MAS) interfaces.
Definition: sensors.h:202
bool configure(void *source, const yarp::os::Property &options)
Configure the sensor.
Definition: sensors.cpp:74
bool getOutput(yarp::os::Value &in) const
Retrieve the sensor encoder value.
Definition: sensors.cpp:91
This class implements the reading of joints encoders.
Definition: sensors.h:167
bool configure(void *source, const yarp::os::Property &options)
Configure the sensor.
Definition: sensors.cpp:44
bool getOutput(yarp::os::Value &in) const
Retrieve the sensor joint value.
Definition: sensors.cpp:60
This class implements the reading of a value from a port.
Definition: sensors.h:238
bool getOutput(yarp::os::Value &in) const
Retrieve the sensor output.
Definition: sensors.cpp:130
bool configure(void *source, const yarp::os::Property &options)
Configure the sensor.
Definition: sensors.cpp:116
An abstract class that exposes the basic methods for sensors handling.
Definition: sensors.h:116
virtual ~Sensor()
Destructor.
Definition: sensors.h:157
Sensor()
Constructor.
Definition: sensors.cpp:35
std::string getName() const
Retrieve the sensor name.
Definition: sensors.h:132
virtual bool configure(void *source, const yarp::os::Property &options)=0
Configure the sensor.
virtual bool getOutput(yarp::os::Value &in) const =0
Retrieve the sensor raw output.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.