YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
11#include <yarp/os/Stamp.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
87 // Helper methods to resize measure buffers
88 template<typename Interface>
89 bool resizeMeasureVectors(Interface* wrappedDeviceInterface,
90 const std::vector< SensorMetadata >& metadataVector,
91 std::vector< SensorMeasurement >& streamingDataVector,
92 size_t (Interface::*getMeasureSizePtr)(size_t) const);
93 template<typename Interface>
94 bool resizeMeasureVectors(Interface* wrappedDeviceInterface,
95 const std::vector< SensorMetadata >& metadataVector,
96 std::vector< SensorMeasurement >& streamingDataVector,
97 size_t measureSize);
98 bool resizeAllMeasureVectors(SensorStreamingData& streamingData);
99
100
101 // Helper method used to copy the sensor measure to the measure buffers
102 template<typename Interface>
103 bool genericStreamData(Interface* wrappedDeviceInterface,
104 const std::vector< SensorMetadata >& metadataVector,
105 std::vector< SensorMeasurement >& streamingDataVector,
106 yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
107 bool (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const,
108 const char* sensorType);
109
110
111public:
114
115 /* DevideDriver methods */
116 bool open(yarp::os::Searchable &params) override;
117 bool close() override;
118
119 /* IMultipleWrapper methods */
120 bool attachAll(const yarp::dev::PolyDriverList &p) override;
121 bool detachAll() override;
122
123 /* RateThread methods */
124 void threadRelease() override;
125 void run() override;
126
127 /* MultipleAnalogSensorsMetadata */
128 SensorRPCData getMetadata() override;
129};
130
131#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 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.
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:23
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:56
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.