YARP
Yet Another Robot Platform
MultipleAnalogSensorsRemapper.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_MULTIPLEANALOGSENSORSREMAPPER_MULTIPLEANALOGSENSORSREMAPPER_H
8#define YARP_DEV_MULTIPLEANALOGSENSORSREMAPPER_MULTIPLEANALOGSENSORSREMAPPER_H
9
12
13#include <vector>
14#include <map>
15
16
21{
32};
33
97{
98private:
99 bool m_verbose{false};
100
101 bool parseOptions(const yarp::os::Property& prop);
102
103 // Map from remapped indices to underlyng subdevice indices
104 class SensorInSubDevice
105 {
106 public:
107 SensorInSubDevice(): subDevice(0), indexInSubDevice(0)
108 {}
109 SensorInSubDevice(size_t p_subDevice, size_t p_indexInSubDevice):
110 subDevice(p_subDevice), indexInSubDevice(p_indexInSubDevice) {}
111
112 size_t subDevice;
113 size_t indexInSubDevice;
114 };
115
116 std::vector< std::vector<std::string> > m_remappedSensors;
117 std::vector< std::vector<SensorInSubDevice> > m_indicesMap;
118
119 std::vector<yarp::dev::IThreeAxisGyroscopes*> m_iThreeAxisGyroscopes;
120 std::vector<yarp::dev::IThreeAxisLinearAccelerometers*> m_iThreeAxisLinearAccelerometers;
121 std::vector<yarp::dev::IThreeAxisMagnetometers*> m_iThreeAxisMagnetometers;
122 std::vector<yarp::dev::IOrientationSensors*> m_iOrientationSensors;
123 std::vector<yarp::dev::ITemperatureSensors*> m_iTemperatureSensors;
124 std::vector<yarp::dev::ISixAxisForceTorqueSensors*> m_iSixAxisForceTorqueSensors;
125 std::vector<yarp::dev::IContactLoadCellArrays*> m_iContactLoadCellArrays;
126 std::vector<yarp::dev::IEncoderArrays*> m_iEncoderArrays;
127 std::vector<yarp::dev::ISkinPatches*> m_iSkinPatches;
128 std::vector<yarp::dev::IPositionSensors*> m_iPositionSensors;
129
130
131 // Templated methods to streamline of the function implementation for all the different sensors
132 // This part is complicated, but is useful to avoid a huge code duplication
133 // To understand this code, make sure that you are familiar with:
134 // * Method templates ( http://en.cppreference.com/w/cpp/language/member_template )
135 // * Pointer to method functions ( http://en.cppreference.com/w/cpp/language/pointer#Pointers_to_member_functions )
136 template<typename Interface>
137 yarp::dev::MAS_status genericGetStatus(const MAS_SensorType sensorType,
138 size_t& sens_index,
139 const std::vector<Interface *>& subDeviceVec,
140 yarp::dev::MAS_status (Interface::*methodPtr)(size_t) const) const;
141 template<typename Interface>
142 bool genericGetName(const MAS_SensorType sensorType,
143 size_t& sens_index, std::string &name,
144 const std::vector<Interface *>& subDeviceVec,
145 bool (Interface::*methodPtr)(size_t, std::string&) const) const;
146 template<typename Interface>
147 bool genericGetFrameName(const MAS_SensorType sensorType,
148 size_t& sens_index, std::string &name,
149 const std::vector<Interface *>& subDeviceVec,
150 bool (Interface::*methodPtr)(size_t, std::string&) const) const;
151 template<typename Interface>
152 bool genericGetMeasure(const MAS_SensorType sensorType,
153 size_t& sens_index, yarp::sig::Vector& out, double& timestamp,
154 const std::vector<Interface *>& subDeviceVec,
155 bool (Interface::*methodPtr)(size_t, yarp::sig::Vector&, double&) const) const;
156 template<typename Interface>
157 size_t genericGetSize(const MAS_SensorType sensorType,
158 size_t& sens_index,
159 const std::vector<Interface *>& subDeviceVec,
160 size_t (Interface::*methodPtr)(size_t) const) const;
161
162 template<typename Interface>
163 bool genericAttachAll(const MAS_SensorType sensorType,
164 std::vector<Interface *>& subDeviceVec,
165 const yarp::dev::PolyDriverList &polylist,
166 bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
167 size_t (Interface::*getNrOfSensorsMethodPtr)() const);
168
169public:
170 /* DeviceDriver methods */
171 bool open(yarp::os::Searchable& config) override;
172 bool close() override;
173
175 bool attachAll(const yarp::dev::PolyDriverList &p) override;
176 bool detachAll() override;
177
178 /* IThreeAxisGyroscopes methods */
179 size_t getNrOfThreeAxisGyroscopes() const override;
180 yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
181 bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
182 bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
183 bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
184
185 /* IThreeAxisLinearAccelerometers methods */
186 size_t getNrOfThreeAxisLinearAccelerometers() const override;
187 yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
188 bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
189 bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
190 bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
191
192 /* IThreeAxisMagnetometers methods */
193 size_t getNrOfThreeAxisMagnetometers() const override;
194 yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
195 bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
196 bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
197 bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
198
199 /* IOrientationSensors methods */
200 size_t getNrOfOrientationSensors() const override;
201 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
202 bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
203 bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
204 bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
205
206 /* ITemperatureSensors methods */
207 size_t getNrOfTemperatureSensors() const override;
208 yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override;
209 bool getTemperatureSensorName(size_t sens_index, std::string &name) const override;
210 bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override;
211 bool getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const override;
212 bool getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
213
214 /* ISixAxisForceTorqueSensors */
215 size_t getNrOfSixAxisForceTorqueSensors() const override;
216 yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override;
217 bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override;
218 bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override;
219 bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
220
221 /* IContactLoadCellArrays */
222 size_t getNrOfContactLoadCellArrays() const override;
223 yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override;
224 bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override;
225 bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
226 size_t getContactLoadCellArraySize(size_t sens_index) const override;
227
228 /* IEncoderArrays */
229 size_t getNrOfEncoderArrays() const override;
230 yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override;
231 bool getEncoderArrayName(size_t sens_index, std::string &name) const override;
232 bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
233 size_t getEncoderArraySize(size_t sens_index) const override;
234
235 /* ISkinPatches */
236 size_t getNrOfSkinPatches() const override;
237 yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override;
238 bool getSkinPatchName(size_t sens_index, std::string &name) const override;
239 bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
240 size_t getSkinPatchSize(size_t sens_index) const override;
241
242 /* IPositionSensors methods */
243 size_t getNrOfPositionSensors() const override;
244 yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override;
245 bool getPositionSensorName(size_t sens_index, std::string& name) const override;
246 bool getPositionSensorFrameName(size_t sens_index, std::string& frameName) const override;
247 bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
248};
249
250
251#endif
MAS_SensorType
Internal identifier of the type of sensors.
@ ThreeAxisLinearAccelerometers
multipleanalogsensorsremapper : device that takes a list of sensor from multiple analog sensors devic...
size_t getNrOfEncoderArrays() const override
Get the number of encoder arrays exposed by this device.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading 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 getNrOfSkinPatches() const override
Get the number of skin patches exposed by this device.
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const override
Get the last reading 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 close() override
Close the DeviceDriver.
bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool detachAll() override
Detach the object (you must have first called attach).
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool attachAll(const yarp::dev::PolyDriverList &p) override
MultipeWrapper methods.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisGyroscopeName(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.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) 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.
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getEncoderArraySize(size_t sens_index) const override
Get the size of the specified encoder array.
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfContactLoadCellArrays() const override
Get the number of contact load cell array exposed by this device.
yarp::dev::MAS_status getEncoderArrayStatus(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.
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 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.
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 getSixAxisForceTorqueSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfTemperatureSensors() const override
Get the number of temperature sensors exposed by this device.
bool getTemperatureSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
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 getNrOfSixAxisForceTorqueSensors() const override
Get the number of six axis force torque sensors exposed by this device.
bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch.
bool getEncoderArrayName(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.
bool getSkinPatchName(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.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status 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.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame 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.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
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 class for storing options and configuration information.
Definition: Property.h:33
A base class for nested structures that can be searched.
Definition: Searchable.h:56
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.