YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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
35
101{
102private:
103 bool m_verbose{false};
104
105 bool parseOptions(const yarp::os::Property& prop);
106
107 // Map from remapped indices to underlyng subdevice indices
108 class SensorInSubDevice
109 {
110 public:
111 SensorInSubDevice(): subDevice(0), indexInSubDevice(0)
112 {}
113 SensorInSubDevice(size_t p_subDevice, size_t p_indexInSubDevice):
114 subDevice(p_subDevice), indexInSubDevice(p_indexInSubDevice) {}
115
116 size_t subDevice;
117 size_t indexInSubDevice;
118 };
119
120 std::vector< std::vector<std::string> > m_remappedSensors;
121 std::vector< std::vector<SensorInSubDevice> > m_indicesMap;
122
123 std::vector<yarp::dev::IThreeAxisGyroscopes*> m_iThreeAxisGyroscopes;
124 std::vector<yarp::dev::IThreeAxisLinearAccelerometers*> m_iThreeAxisLinearAccelerometers;
125 std::vector<yarp::dev::IThreeAxisAngularAccelerometers*> m_iThreeAxisAngularAccelerometers;
126 std::vector<yarp::dev::IThreeAxisMagnetometers*> m_iThreeAxisMagnetometers;
127 std::vector<yarp::dev::IOrientationSensors*> m_iOrientationSensors;
128 std::vector<yarp::dev::ITemperatureSensors*> m_iTemperatureSensors;
129 std::vector<yarp::dev::ISixAxisForceTorqueSensors*> m_iSixAxisForceTorqueSensors;
130 std::vector<yarp::dev::IContactLoadCellArrays*> m_iContactLoadCellArrays;
131 std::vector<yarp::dev::IEncoderArrays*> m_iEncoderArrays;
132 std::vector<yarp::dev::ISkinPatches*> m_iSkinPatches;
133 std::vector<yarp::dev::IPositionSensors*> m_iPositionSensors;
134 std::vector<yarp::dev::ILinearVelocitySensors*> m_iLinearVelocitySensors;
135
136
137 // Templated methods to streamline of the function implementation for all the different sensors
138 // This part is complicated, but is useful to avoid a huge code duplication
139 // To understand this code, make sure that you are familiar with:
140 // * Method templates ( http://en.cppreference.com/w/cpp/language/member_template )
141 // * Pointer to method functions ( http://en.cppreference.com/w/cpp/language/pointer#Pointers_to_member_functions )
142 template<typename Interface>
143 yarp::dev::MAS_status genericGetStatus(const MAS_SensorType sensorType,
144 size_t& sens_index,
145 const std::vector<Interface *>& subDeviceVec,
146 yarp::dev::MAS_status (Interface::*methodPtr)(size_t) const) const;
147 template<typename Interface>
148 bool genericGetName(const MAS_SensorType sensorType,
149 size_t& sens_index, std::string &name,
150 const std::vector<Interface *>& subDeviceVec,
151 bool (Interface::*methodPtr)(size_t, std::string&) const) const;
152 template<typename Interface>
153 bool genericGetFrameName(const MAS_SensorType sensorType,
154 size_t& sens_index, std::string &name,
155 const std::vector<Interface *>& subDeviceVec,
156 bool (Interface::*methodPtr)(size_t, std::string&) const) const;
157 template<typename Interface>
158 bool genericGetMeasure(const MAS_SensorType sensorType,
159 size_t& sens_index, yarp::sig::Vector& out, double& timestamp,
160 const std::vector<Interface *>& subDeviceVec,
161 bool (Interface::*methodPtr)(size_t, yarp::sig::Vector&, double&) const) const;
162 template<typename Interface>
163 size_t genericGetSize(const MAS_SensorType sensorType,
164 size_t& sens_index,
165 const std::vector<Interface *>& subDeviceVec,
166 size_t (Interface::*methodPtr)(size_t) const) const;
167
168 template<typename Interface>
169 bool genericAttachAll(const MAS_SensorType sensorType,
170 std::vector<Interface *>& subDeviceVec,
171 const yarp::dev::PolyDriverList &polylist,
172 bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
173 size_t (Interface::*getNrOfSensorsMethodPtr)() const);
174
175public:
176 /* DeviceDriver methods */
177 bool open(yarp::os::Searchable& config) override;
178 bool close() override;
179
181 bool attachAll(const yarp::dev::PolyDriverList &p) override;
182 bool detachAll() override;
183
184 /* IThreeAxisGyroscopes methods */
185 size_t getNrOfThreeAxisGyroscopes() const override;
186 yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
187 bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
188 bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
189 bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
190
191 /* IThreeAxisLinearAccelerometers methods */
192 size_t getNrOfThreeAxisLinearAccelerometers() const override;
193 yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
194 bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
195 bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
196 bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
197
198 /* IThreeAxisAngularAccelerometers methods */
199 size_t getNrOfThreeAxisAngularAccelerometers() const override;
200 yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const override;
201 bool getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const override;
202 bool getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
203 bool getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
204
205 /* IThreeAxisMagnetometers methods */
206 size_t getNrOfThreeAxisMagnetometers() const override;
207 yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
208 bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
209 bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
210 bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
211
212 /* IOrientationSensors methods */
213 size_t getNrOfOrientationSensors() const override;
214 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
215 bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
216 bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
217 bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
218
219 /* ITemperatureSensors methods */
220 size_t getNrOfTemperatureSensors() const override;
221 yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override;
222 bool getTemperatureSensorName(size_t sens_index, std::string &name) const override;
223 bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override;
224 bool getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const override;
225 bool getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
226
227 /* ISixAxisForceTorqueSensors */
228 size_t getNrOfSixAxisForceTorqueSensors() const override;
229 yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override;
230 bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override;
231 bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override;
232 bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
233
234 /* IContactLoadCellArrays */
235 size_t getNrOfContactLoadCellArrays() const override;
236 yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override;
237 bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override;
238 bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
239 size_t getContactLoadCellArraySize(size_t sens_index) const override;
240
241 /* IEncoderArrays */
242 size_t getNrOfEncoderArrays() const override;
243 yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override;
244 bool getEncoderArrayName(size_t sens_index, std::string &name) const override;
245 bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
246 size_t getEncoderArraySize(size_t sens_index) const override;
247
248 /* ISkinPatches */
249 size_t getNrOfSkinPatches() const override;
250 yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override;
251 bool getSkinPatchName(size_t sens_index, std::string &name) const override;
252 bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
253 size_t getSkinPatchSize(size_t sens_index) const override;
254
255 /* IPositionSensors methods */
256 size_t getNrOfPositionSensors() const override;
257 yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override;
258 bool getPositionSensorName(size_t sens_index, std::string& name) const override;
259 bool getPositionSensorFrameName(size_t sens_index, std::string& frameName) const override;
260 bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
261
262 /* ILinearVelocitySensors methods */
263 size_t getNrOfLinearVelocitySensors() const override;
264 yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const override;
265 bool getLinearVelocitySensorName(size_t sens_index, std::string& name) const override;
266 bool getLinearVelocitySensorFrameName(size_t sens_index, std::string& frameName) const override;
267 bool getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
268};
269
270
271#endif
size_t size_t
MAS_SensorType
Internal identifier of the type of sensors.
@ ThreeAxisAngularAccelerometers
@ ThreeAxisLinearAccelerometers
multipleanalogsensorsremapper : device that takes a list of sensors from multiple analog sensors devi...
bool getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
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 getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getLinearVelocitySensorName(size_t sens_index, std::string &name) const override
Get the name 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.
size_t getNrOfLinearVelocitySensors() const override
Get the number of linear velocity sensors exposed by this device.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const override
Get the status 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 getNrOfThreeAxisAngularAccelerometers() const override
Get the number of three axis angular accelerometers exposed by this device.
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.
bool getLinearVelocitySensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
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 getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the linear velocity sensor as x y z.
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.
bool getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const override
Get the name 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.
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:31
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.