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
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
SensorRPCData
Definition: SensorRPCData.h:23
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
MultipleAnalogSensorsServer::~MultipleAnalogSensorsServer
~MultipleAnalogSensorsServer()
yarp::dev::IThreeAxisMagnetometers
Device interface to one or multiple three axis magnetometers.
Definition: MultipleAnalogSensorsInterfaces.h:165
yarp::dev::IThreeAxisGyroscopes
Device interface to one or multiple three axis gyroscopes.
Definition: MultipleAnalogSensorsInterfaces.h:64
yarp::dev::IOrientationSensors
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Definition: MultipleAnalogSensorsInterfaces.h:274
yarp::dev::PolyDriverList
Definition: PolyDriverList.h:22
MultipleAnalogSensorsInterfaces.h
MultipleAnalogSensorsServer::detachAll
bool detachAll() override
Detach the object (you must have first called attach).
Definition: MultipleAnalogSensorsServer.cpp:342
MultipleAnalogSensorsServer::threadRelease
void threadRelease() override
Release method.
Definition: MultipleAnalogSensorsServer.cpp:461
MultipleAnalogSensorsMetadata
Definition: MultipleAnalogSensorsMetadata.h:23
yarp::sig::VectorOf< double >
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::BufferedPort< SensorStreamingData >
yarp::dev::ISkinPatches
Device interface to one or more groups (patches) of tactile sensors (skin).
Definition: MultipleAnalogSensorsInterfaces.h:569
yarp::dev::ISixAxisForceTorqueSensors
Device interface to one or multiple six axis force torque sensor.
Definition: MultipleAnalogSensorsInterfaces.h:419
MultipleAnalogSensorsServer::open
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
Definition: MultipleAnalogSensorsServer.cpp:31
PolyDriver.h
Stamp.h
MultipleAnalogSensorsServer::getMetadata
SensorRPCData getMetadata() override
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
Definition: MultipleAnalogSensorsServer.cpp:356
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
yarp::dev::IThreeAxisLinearAccelerometers
Device interface to one or multiple three axis linear accelerometers.
Definition: MultipleAnalogSensorsInterfaces.h:118
MultipleAnalogSensorsServer
multipleanalogsensorsserver: The server side of the MultipleAnalogSensorsClient, useful to expose dev...
Definition: MultipleAnalogSensorsServer.h:48
MultipleAnalogSensorsServer::close
bool close() override
Close the DeviceDriver.
Definition: MultipleAnalogSensorsServer.cpp:106
yarp::dev::IEncoderArrays
Device interface to one or multiple arrays of encoders.
Definition: MultipleAnalogSensorsInterfaces.h:520
IMultipleWrapper.h
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
SensorStreamingData.h
PeriodicThread.h
MultipleAnalogSensorsServer::attachAll
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
Definition: MultipleAnalogSensorsServer.cpp:251
yarp::os::Stamp
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:25
MultipleAnalogSensorsServer::run
void run() override
Loop function.
Definition: MultipleAnalogSensorsServer.cpp:393
MultipleAnalogSensorsServer::MultipleAnalogSensorsServer
MultipleAnalogSensorsServer()
Definition: MultipleAnalogSensorsServer.cpp:24
MultipleAnalogSensorsMetadata.h
yarp::dev::IMultipleWrapper
Interface for an object that can wrap/attach to to another.
Definition: IMultipleWrapper.h:30
yarp::dev::MAS_status
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
Definition: MultipleAnalogSensorsInterfaces.h:37
yarp::dev::ITemperatureSensors
Device interface to one or multiple temperature sensors.
Definition: MultipleAnalogSensorsInterfaces.h:365
yarp::dev::IPositionSensors
Device interface to one or multiple position sensors, such as UWB localization sensors.
Definition: MultipleAnalogSensorsInterfaces.h:216
yarp::dev::IContactLoadCellArrays
Device interface to one or multiple contact load cell arrays.
Definition: MultipleAnalogSensorsInterfaces.h:467
DeviceDriver.h