YARP
Yet Another Robot Platform
fakeAnalogSensor.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_DEVICE_FAKE_ANALOGSENSOR
7 #define YARP_DEVICE_FAKE_ANALOGSENSOR
8 
10 
11 #include <yarp/dev/all.h>
12 #include <yarp/dev/IAnalogSensor.h>
13 
14 #include <mutex>
15 
32 {
33 private:
34 
35  std::mutex mutex;
36 
37  std::string name; // device name
38  unsigned int channelsNum;
39  short status;
40  double timeStamp;
41  yarp::sig::Vector data;
42 
43 public:
44  FakeAnalogSensor(double period = 0.02);
45 
47 
48  bool open(yarp::os::Searchable& config) override;
49  bool close() override;
50 
51  //IAnalogSensor interface
52  int getChannels() override;
53  int getState(int ch) override;
54  int read(yarp::sig::Vector &out) override;
55 
56  int calibrateSensor() override;
57  int calibrateSensor(const yarp::sig::Vector& v) override;
58 
59  int calibrateChannel(int ch) override;
60  int calibrateChannel(int ch, double v) override;
61 
62  // RateThread interface
63  void run() override;
64  bool threadInit() override;
65  void threadRelease() override;
66 };
67 
68 
69 #endif // YARP_DEVICE_FAKE_ANALOGSENSOR
analog sensor interface
fakeAnalogSensor: Fake analog sensor device for testing purpose and reference for new analog devices
bool threadInit() override
Initialization method.
void run() override
Loop function.
int calibrateChannel(int ch) override
Calibrates one single channel.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
int getChannels() override
Get the number of channels of the sensor.
int calibrateSensor() override
Calibrates the whole sensor.
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
void threadRelease() override
Release method.
int getState(int ch) override
Check the state value of a given channel.
FakeAnalogSensor(double period=0.02)
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
A generic interface to sensors (gyro, a/d converters).
Definition: IAnalogSensor.h:28
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:66