YARP
Yet Another Robot Platform
MultipleAnalogSensorsServer.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 
10 #ifndef YARP_DEV_MULTIPLEANALOGSENSORSSERVER_MULTIPLEANALOGSENSORSSERVER_H
11 #define YARP_DEV_MULTIPLEANALOGSENSORSSERVER_MULTIPLEANALOGSENSORSSERVER_H
12 
13 #include <yarp/os/PeriodicThread.h>
14 #include <yarp/os/Stamp.h>
15 #include <yarp/dev/DeviceDriver.h>
16 #include <yarp/dev/PolyDriver.h>
19 
20 // Thrift-generated classes
21 #include "SensorStreamingData.h"
23 
24 
48 {
49  double m_periodInS{0.01};
50  yarp::os::Stamp m_stamp;
51  std::string m_streamingPortName;
52  std::string m_RPCPortName;
54  yarp::os::Port m_rpcPort;
55  // Generic vector buffer
56  yarp::sig::Vector m_buffer;
57 
58  // Wrapped subdevices, if any
59  yarp::dev::PolyDriver m_subdevice;
60  bool m_isDeviceOwned{false};
61 
62  // Interface of the wrapped device
63  yarp::dev::IThreeAxisGyroscopes* m_iThreeAxisGyroscopes{nullptr};
64  yarp::dev::IThreeAxisLinearAccelerometers* m_iThreeAxisLinearAccelerometers{nullptr};
65  yarp::dev::IThreeAxisMagnetometers* m_iThreeAxisMagnetometers{nullptr};
66  yarp::dev::IPositionSensors* m_iPositionSensors{nullptr};
67  yarp::dev::IOrientationSensors* m_iOrientationSensors{nullptr};
68  yarp::dev::ITemperatureSensors* m_iTemperatureSensors{nullptr};
69  yarp::dev::ISixAxisForceTorqueSensors* m_iSixAxisForceTorqueSensors{nullptr};
70  yarp::dev::IContactLoadCellArrays* m_iContactLoadCellArrays{nullptr};
71  yarp::dev::IEncoderArrays* m_iEncoderArrays{nullptr};
72  yarp::dev::ISkinPatches* m_iSkinPatches{nullptr};
73 
74  // Metadata to be server via the RPC port
75  SensorRPCData m_sensorMetadata;
76  bool populateAllSensorsMetadata();
77  template<typename Interface>
78  bool populateSensorsMetadata(Interface * wrappedDeviceInterface,
79  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
80  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
81  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
82  bool (Interface::*getFrameNameMethodPtr)(size_t, std::string&) const);
83  template<typename Interface>
84  bool populateSensorsMetadataNoFrameName(Interface * wrappedDeviceInterface,
85  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
86  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
87  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const);
88 
89  template<typename Interface>
90  bool genericStreamData(Interface* wrappedDeviceInterface,
91  const std::vector< SensorMetadata >& metadataVector,
92  std::vector< SensorMeasurement >& streamingDataVector,
93  yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
94  bool (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const);
95 
96 public:
99 
100  /* DevideDriver methods */
101  bool open(yarp::os::Searchable &params) override;
102  bool close() override;
103 
104  /* IMultipleWrapper methods */
105  bool attachAll(const yarp::dev::PolyDriverList &p) override;
106  bool detachAll() override;
107 
108  /* RateThread methods */
109  void threadRelease() override;
110  void run() override;
111 
112  /* MultipleAnalogSensorsMetadata */
113  SensorRPCData getMetadata() override;
114 };
115 
116 #endif
The server side of the MultipleAnalogSensorsClient, useful to expose device implementing MultipleAnal...
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:38
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:27
An abstraction for a periodic thread.
A mini-server for network communication.
Definition: Port.h:50
A base class for nested structures that can be searched.
Definition: Searchable.h:69
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.