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