YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
AnalogSensorClient.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_DEV_ANALOGSENSORCLIENT_ANALOGSENSORCLIENT_H
7#define YARP_DEV_ANALOGSENSORCLIENT_ANALOGSENSORCLIENT_H
8
9
10#include <yarp/os/Network.h>
16#include <yarp/sig/Vector.h>
17#include <yarp/os/Time.h>
18#include <yarp/dev/PolyDriver.h>
19
20#include <mutex>
21
23{
24 const int ANALOG_TIMEOUT = 100; // ms
25
26 yarp::sig::Vector lastVector;
27 std::mutex mutex;
28 yarp::os::Stamp lastStamp;
29 double deltaT;
30 double deltaTMax;
31 double deltaTMin;
32 double prev;
33 double now;
34
35 int state;
36 int count;
37
38public:
39 inline void resetStat();
40
42
44 void onRead(yarp::sig::Vector& v) override;
45
47
48 inline int getIterations();
49
50 // time is in ms
51 void getEstFrequency(int& ite, double& av, double& min, double& max);
52
53 int getState();
54
55 int getChannels();
56};
57
58/*
59 * The client side of any IAnalogSensor capable device.
60 * Still single thread! concurrent access is unsafe.
61 */
62
87{
88protected:
91 std::string local;
92 std::string remote;
93 yarp::os::Stamp lastTs; //used by IPreciselyTimed
94 std::string robotName;
95 std::string deviceId;
96 std::string sensorType;
97 std::string portPrefix;
98
99 void removeLeadingTrailingSlashesOnly(std::string &name);
100
101public:
107 ~AnalogSensorClient() override = default;
108
109 /* DeviceDriver methods */
110 bool open(yarp::os::Searchable& config) override;
111 bool close() override;
112
113 /* IAnalogSensor methods*/
114 int read(yarp::sig::Vector &out) override;
115
116 /* Check the state value of a given channel.
117 * @param ch: channel number.
118 * @return status.
119 */
120 int getState(int ch) override;
121
122 /* Get the number of channels of the sensor.
123 * @return number of channels (0 in case of errors).
124 */
125 int getChannels() override;
126
127 /* Calibrates the whole sensor.
128 * @return status.
129 */
130 int calibrateSensor() override;
131
132 /* Calibrates the whole sensor, using a vector of calibration values.
133 * @param value: a vector of calibration values.
134 * @return status.
135 */
136 int calibrateSensor(const yarp::sig::Vector& value) override;
137
138 /* Calibrates one single channel.
139 * @param ch: channel number.
140 * @return status.
141 */
142 int calibrateChannel(int ch) override;
143
144 /* Calibrates one single channel.
145 * @param ch: channel number.
146 * @param value: calibration value.
147 * @return status.
148 */
149 int calibrateChannel(int ch, double value) override;
150
151 /* IPreciselyTimed methods */
157};
158
159#endif // YARP_DEV_ANALOGSENSORCLIENT_ANALOGSENSORCLIENT_H
define control board standard interfaces
analog sensor interface
contains the definition of a Vector type
int getLast(yarp::sig::Vector &data, yarp::os::Stamp &stmp)
void getEstFrequency(int &ite, double &av, double &min, double &max)
void onRead(yarp::sig::Vector &v) override
analogsensorclient deprecated: Device that reads an AnalogSensor (using the IAnalogSensor interface) ...
yarp::os::Stamp lastTs
void removeLeadingTrailingSlashesOnly(std::string &name)
yarp::os::Stamp getLastInputStamp() override
Get the time stamp for the last read data.
bool close() override
Close the DeviceDriver.
~AnalogSensorClient() override=default
AnalogSensorClient(AnalogSensorClient &&)=delete
int calibrateChannel(int ch) override
Calibrates one single channel.
AnalogSensorClient & operator=(AnalogSensorClient &&)=delete
int calibrateSensor() override
Calibrates the whole sensor.
int read(yarp::sig::Vector &out) override
Read a vector from the sensor.
int getState(int ch) override
Check the state value of a given channel.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
AnalogSensorClient()=default
AnalogSensorClient(const AnalogSensorClient &)=delete
AnalogSensorClient_InputPortProcessor inputPort
int getChannels() override
Get the number of channels of the sensor.
AnalogSensorClient & operator=(const AnalogSensorClient &)=delete
Interface implemented by all device drivers.
A generic interface to sensors (gyro, a/d converters).
A mini-server for performing network communication in the background.
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21