YARP
Yet Another Robot Platform
fakeAnalogSensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEVICE_FAKE_ANALOGSENSOR
10 #define YARP_DEVICE_FAKE_ANALOGSENSOR
11 
12 #include <yarp/os/PeriodicThread.h>
13 
14 #include <yarp/dev/all.h>
15 #include <yarp/dev/IAnalogSensor.h>
16 
17 #include <mutex>
18 
34 {
35 private:
36 
37  std::mutex mutex;
38 
39  std::string name; // device name
40  unsigned int channelsNum;
41  short status;
42  double timeStamp;
43  yarp::sig::Vector data;
44 
45 public:
46  FakeAnalogSensor(double period = 0.02);
47 
49 
50  bool open(yarp::os::Searchable& config) override;
51  bool close() override;
52 
53  //IAnalogSensor interface
54  int getChannels() override;
55  int getState(int ch) override;
56  int read(yarp::sig::Vector &out) override;
57 
58  int calibrateSensor() override;
59  int calibrateSensor(const yarp::sig::Vector& v) override;
60 
61  int calibrateChannel(int ch) override;
62  int calibrateChannel(int ch, double v) override;
63 
64  // RateThread interface
65  void run() override;
66  bool threadInit() override;
67  void threadRelease() override;
68 };
69 
70 
71 #endif // YARP_DEVICE_FAKE_ANALOGSENSOR
analog sensor interface
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:38
A generic interface to sensors (gyro, a/d converters).
Definition: IAnalogSensor.h:31
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:69