YARP
Yet Another Robot Platform
MultipleAnalogSensorsClient.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_DEV_MULTIPLEANALOGSENSORSCLIENT_MULTIPLEANALOGSENSORSCLIENT_H
10 #define YARP_DEV_MULTIPLEANALOGSENSORSCLIENT_MULTIPLEANALOGSENSORSCLIENT_H
11 
13 
15 #include "SensorStreamingData.h"
16 
17 #include <yarp/os/BufferedPort.h>
18 #include <yarp/os/Network.h>
19 #include <yarp/dev/DeviceDriver.h>
20 
21 #include <mutex>
22 
23 
25  public yarp::os::BufferedPort<SensorStreamingData>
26 {
27 public:
30  mutable std::mutex dataMutex;
31  double timeoutInSeconds{0.01};
33 
35  void onRead(SensorStreamingData &v) override;
36  void updateTimeoutStatus() const;
37 };
38 
69 {
70  SensorStreamingDataInputPort m_streamingPort;
71  yarp::os::Port m_rpcPort;
72  std::string m_localRPCPortName;
73  std::string m_localStreamingPortName;
74  std::string m_remoteRPCPortName;
75  std::string m_remoteStreamingPortName;
76  bool m_RPCConnectionActive{false};
77  bool m_StreamingConnectionActive{false};
78  bool m_externalConnection{false};
79 
80  MultipleAnalogSensorsMetadata m_RPCInterface;
81  SensorRPCData m_sensorsMetadata;
82 
83  size_t genericGetNrOfSensors(const std::vector<SensorMetadata>& metadataVector,
84  const SensorMeasurements& measurementsVector) const;
85  yarp::dev::MAS_status genericGetStatus() const;
86  bool genericGetName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
87  size_t sens_index, std::string &name) const;
88  bool genericGetFrameName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
89  size_t sens_index, std::string &frameName) const;
90  bool genericGetMeasure(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
91  const SensorMeasurements& measurementsVector,
92  size_t sens_index, yarp::sig::Vector& out, double& timestamp) const;
93  size_t genericGetSize(const std::vector<SensorMetadata>& metadataVector,
94  const std::string& tag, const SensorMeasurements& measurementsVector, size_t sens_index) const;
95 
96 
97 public:
98  /* DevideDriver methods */
99  bool open(yarp::os::Searchable& config) override;
100  bool close() override;
101 
102  /* IThreeAxisGyroscopes methods */
103  size_t getNrOfThreeAxisGyroscopes() const override;
104  yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
105  bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
106  bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
107  bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
108 
109  /* IThreeAxisLinearAccelerometers methods */
110  size_t getNrOfThreeAxisLinearAccelerometers() const override;
111  yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
112  bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
113  bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
114  bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
115 
116  /* IThreeAxisMagnetometers methods */
117  size_t getNrOfThreeAxisMagnetometers() const override;
118  yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
119  bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
120  bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
121  bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
122 
123  /* IPositionSensors methods */
124  size_t getNrOfPositionSensors() const override;
125  yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override;
126  bool getPositionSensorName(size_t sens_index, std::string& name) const override;
127  bool getPositionSensorFrameName(size_t sens_index, std::string& frameName) const override;
128  bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
129 
130  /* IOrientationSensors methods */
131  size_t getNrOfOrientationSensors() const override;
132  yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
133  bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
134  bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
135  bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
136 
137  /* ITemperatureSensors methods */
138  size_t getNrOfTemperatureSensors() const override;
139  yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override;
140  bool getTemperatureSensorName(size_t sens_index, std::string &name) const override;
141  bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override;
142  bool getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const override;
143  bool getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
144 
145  /* ISixAxisForceTorqueSensors */
146  size_t getNrOfSixAxisForceTorqueSensors() const override;
147  yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override;
148  bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override;
149  bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override;
150  bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
151 
152  /* IContactLoadCellArrays */
153  size_t getNrOfContactLoadCellArrays() const override;
154  yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override;
155  bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override;
156  bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
157  size_t getContactLoadCellArraySize(size_t sens_index) const override;
158 
159  /* IEncoderArrays */
160  size_t getNrOfEncoderArrays() const override;
161  yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override;
162  bool getEncoderArrayName(size_t sens_index, std::string &name) const override;
163  bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
164  size_t getEncoderArraySize(size_t sens_index) const override;
165 
166  /* ISkinPatches */
167  size_t getNrOfSkinPatches() const override;
168  yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override;
169  bool getSkinPatchName(size_t sens_index, std::string &name) const override;
170  bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
171  size_t getSkinPatchSize(size_t sens_index) const override;
172 };
173 
174 #endif
multipleanalogsensorsclient: The client side of a device exposing MultipleAnalogSensors interfaces.
yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getSkinPatchName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getEncoderArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the position sensor as x y z.
yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
size_t getNrOfTemperatureSensors() const override
Get the number of temperature sensors exposed by this device.
size_t getEncoderArraySize(size_t sens_index) const override
Get the size of the specified encoder array.
size_t getNrOfEncoderArrays() const override
Get the number of encoder arrays exposed by this device.
bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getContactLoadCellArraySize(size_t sens_index) const override
Get the size of the specified contact load cell array.
size_t getNrOfSixAxisForceTorqueSensors() const override
Get the number of six axis force torque sensors exposed by this device.
bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const override
Get the last reading of the specified sensor.
size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch.
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
bool close() override
Close the DeviceDriver.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double &timestamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getTemperatureSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override
Get the name of the frame of the specified sensor.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
size_t getNrOfSkinPatches() const override
Get the number of skin patches exposed by this device.
size_t getNrOfContactLoadCellArrays() const override
Get the number of contact load cell array exposed by this device.
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void onRead(SensorStreamingData &v) override
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
Device interface to one or multiple contact load cell arrays.
Device interface to one or multiple arrays of encoders.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Device interface to one or multiple position sensors, such as UWB localization sensors.
Device interface to one or multiple six axis force torque sensor.
Device interface to one or more groups (patches) of tactile sensors (skin).
Device interface to one or multiple temperature sensors.
Device interface to one or multiple three axis gyroscopes.
Device interface to one or multiple three axis linear accelerometers.
Device interface to one or multiple three axis magnetometers.
A mini-server for performing network communication in the background.
Definition: BufferedPort.h:64
A mini-server for network communication.
Definition: Port.h:50
A base class for nested structures that can be searched.
Definition: Searchable.h:69
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_WAITING_FOR_FIRST_READ
The sensor is read through the network, and the device is waiting to receive the first measurement.