YARP
Yet Another Robot Platform
MultipleAnalogSensorsServer.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 
7 #ifndef YARP_DEV_MULTIPLEANALOGSENSORSSERVER_MULTIPLEANALOGSENSORSSERVER_H
8 #define YARP_DEV_MULTIPLEANALOGSENSORSSERVER_MULTIPLEANALOGSENSORSSERVER_H
9 
10 #include <yarp/os/PeriodicThread.h>
11 #include <yarp/os/Stamp.h>
12 #include <yarp/dev/DeviceDriver.h>
13 #include <yarp/dev/PolyDriver.h>
16 
17 // Thrift-generated classes
18 #include "SensorStreamingData.h"
20 
21 
45 {
46  double m_periodInS{0.01};
47  yarp::os::Stamp m_stamp;
48  std::string m_streamingPortName;
49  std::string m_RPCPortName;
51  yarp::os::Port m_rpcPort;
52  // Generic vector buffer
53  yarp::sig::Vector m_buffer;
54 
55  // Wrapped subdevices, if any
56  yarp::dev::PolyDriver m_subdevice;
57  bool m_isDeviceOwned{false};
58 
59  // Interface of the wrapped device
60  yarp::dev::IThreeAxisGyroscopes* m_iThreeAxisGyroscopes{nullptr};
61  yarp::dev::IThreeAxisLinearAccelerometers* m_iThreeAxisLinearAccelerometers{nullptr};
62  yarp::dev::IThreeAxisMagnetometers* m_iThreeAxisMagnetometers{nullptr};
63  yarp::dev::IPositionSensors* m_iPositionSensors{nullptr};
64  yarp::dev::IOrientationSensors* m_iOrientationSensors{nullptr};
65  yarp::dev::ITemperatureSensors* m_iTemperatureSensors{nullptr};
66  yarp::dev::ISixAxisForceTorqueSensors* m_iSixAxisForceTorqueSensors{nullptr};
67  yarp::dev::IContactLoadCellArrays* m_iContactLoadCellArrays{nullptr};
68  yarp::dev::IEncoderArrays* m_iEncoderArrays{nullptr};
69  yarp::dev::ISkinPatches* m_iSkinPatches{nullptr};
70 
71  // Metadata to be server via the RPC port
72  SensorRPCData m_sensorMetadata;
73  bool populateAllSensorsMetadata();
74  template<typename Interface>
75  bool populateSensorsMetadata(Interface * wrappedDeviceInterface,
76  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
77  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
78  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
79  bool (Interface::*getFrameNameMethodPtr)(size_t, std::string&) const);
80  template<typename Interface>
81  bool populateSensorsMetadataNoFrameName(Interface * wrappedDeviceInterface,
82  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
83  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
84  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const);
85 
86  template<typename Interface>
87  bool genericStreamData(Interface* wrappedDeviceInterface,
88  const std::vector< SensorMetadata >& metadataVector,
89  std::vector< SensorMeasurement >& streamingDataVector,
90  yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
91  bool (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const);
92 
93 public:
96 
97  /* DevideDriver methods */
98  bool open(yarp::os::Searchable &params) override;
99  bool close() override;
100 
101  /* IMultipleWrapper methods */
102  bool attachAll(const yarp::dev::PolyDriverList &p) override;
103  bool detachAll() override;
104 
105  /* RateThread methods */
106  void threadRelease() override;
107  void run() override;
108 
109  /* MultipleAnalogSensorsMetadata */
110  SensorRPCData getMetadata() override;
111 };
112 
113 #endif
multipleanalogsensorsserver: The server side of the MultipleAnalogSensorsClient, useful to expose dev...
bool detachAll() override
Detach the object (you must have first called attach).
SensorRPCData getMetadata() override
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
void run() override
Loop function.
void threadRelease() override
Release method.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
Device interface to one or multiple contact load cell arrays.
Device interface to one or multiple arrays of encoders.
Interface for an object that can wrap/attach to to another.
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 container for a device driver.
Definition: PolyDriver.h:24
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:47
A base class for nested structures that can be searched.
Definition: Searchable.h:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.