YARP
Yet Another Robot Platform
MultipleAnalogSensorsRemapper.cpp
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
7
8#include <map>
9
11#include <yarp/os/LogStream.h>
12#include <yarp/os/Searchable.h>
13
14using namespace yarp::os;
15using namespace yarp::dev;
16
17namespace {
18YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSREMAPPER, "yarp.device.multipleanalogsensorsremapper")
19}
20
21const size_t MAS_NrOfSensorTypes{10};
22static_assert(MAS_SensorType::PositionSensors+1 == MAS_NrOfSensorTypes, "Consistency error between MAS_NrOfSensorTypes and MAS_SensorType");
23
27inline std::string MAS_getTagFromEnum(const MAS_SensorType type)
28{
29 switch(type)
30 {
32 return "ThreeAxisGyroscopes";
33 break;
35 return "ThreeAxisLinearAccelerometers";
36 break;
38 return "ThreeAxisMagnetometers";
39 break;
41 return "OrientationSensors";
42 break;
44 return "TemperatureSensors";
45 break;
47 return "SixAxisForceTorqueSensors";
48 break;
50 return "ContactLoadCellArrays";
51 break;
52 case EncoderArrays:
53 return "EncoderArrays";
54 break;
55 case SkinPatches:
56 return "SkinPatches";
57 break;
58 case PositionSensors:
59 return "PositionSensors";
60 break;
61 default:
62 assert(false);
63 return "MAS_getTagFromEnum_notExpectedEnum";
64 break;
65 }
66}
67
69{
70 return detachAll();
71}
72
74{
75 Property prop;
76 prop.fromString(config.toString());
77
78 m_verbose = (prop.check("verbose","if present, give detailed output"));
79 if (m_verbose)
80 {
81 yCInfo(MULTIPLEANALOGSENSORSREMAPPER, "Running with verbose output\n");
82 }
83
84 if(!parseOptions(prop))
85 {
86 return false;
87 }
88
89 return true;
90}
91
92// Return an empty list if the key is not found, and an error (false) if the key was found but it is not a list of strings
93bool getVectorOfStringFromListInConfig(const std::string& key, const yarp::os::Searchable& config, std::vector<std::string> & vectorOfStrings)
94{
96 prop.fromString(config.toString());
97 bool keyExists = prop.check(key);
98
99 yarp::os::Bottle *propList=prop.find(key).asList();
100 if (!propList && keyExists)
101 {
102 yCError(MULTIPLEANALOGSENSORSREMAPPER) << "Error parsing parameters: if present " << key << " should be followed by a list of strings.\n";
103 return false;
104 }
105
106 if (!propList && !keyExists)
107 {
108 vectorOfStrings.resize(0);
109 return true;
110 }
111
112 vectorOfStrings.resize(propList->size());
113 for (size_t ax=0; ax < propList->size(); ax++)
114 {
115 vectorOfStrings[ax] = propList->get(ax).asString();
116 }
117
118 return true;
119}
120
121bool MultipleAnalogSensorsRemapper::parseOptions(const Property& prop)
122{
123 bool ok = true;
124
125 m_remappedSensors.resize(MAS_NrOfSensorTypes);
126
127 for (size_t i = 0; i < MAS_NrOfSensorTypes; i++)
128 {
129 auto sensType = static_cast<MAS_SensorType>(i);
130 std::string optionName = MAS_getTagFromEnum(sensType) +"Names";
131 ok = getVectorOfStringFromListInConfig(optionName , prop, m_remappedSensors[i]);
132 if (!ok)
133 {
134 yCError(MULTIPLEANALOGSENSORSREMAPPER) << optionName << "should be followed by a list of string.";
135 return false;
136 }
137 }
138
139 return ok;
140}
141
142// Note: as soon as we support only C++17, we can switch to using std::invoke
143// See https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
144#define MAS_CALL_MEMBER_FN(object, ptrToMember) ((*object).*(ptrToMember))
145
146
147template<typename Interface>
148bool MultipleAnalogSensorsRemapper::genericAttachAll(const MAS_SensorType sensorType,
149 std::vector<Interface *>& subDeviceVec,
150 const PolyDriverList &polylist,
151 bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
152 size_t (Interface::*getNrOfSensorsMethodPtr)() const)
153{
154 std::map<std::string, SensorInSubDevice> sensorLocationMap;
155
156 subDeviceVec.resize(polylist.size());
157
158 for(int p=0; p<polylist.size(); p++)
159 {
160 // If this fails it is ok, this just means that this devices does not expose this kind of sensors
161 polylist[p]->poly->view(subDeviceVec[p]);
162
163 if (subDeviceVec[p])
164 {
165 size_t nrOfSensorsInSubDevice = MAS_CALL_MEMBER_FN(subDeviceVec[p], getNrOfSensorsMethodPtr)();
166 for (size_t s=0; s < nrOfSensorsInSubDevice; s++)
167 {
168 std::string name;
169 bool ok = MAS_CALL_MEMBER_FN(subDeviceVec[p], getNameMethodPtr)(s,name);
170 if (!ok)
171 {
172 yCError(MULTIPLEANALOGSENSORSREMAPPER) << "Failure in getting a name in the device " << polylist[p]->key;
173 return false;
174 }
175
176 // If the name is already in the map, raise an error
177 if (sensorLocationMap.find(name) != sensorLocationMap.end())
178 {
179 SensorInSubDevice deviceWithSameName = sensorLocationMap.find(name)->second;
180 yCError(MULTIPLEANALOGSENSORSREMAPPER)
181 << "Sensor ambiguity: sensor with name"
182 << name
183 << "present on both device"
184 << polylist[p]->key
185 << polylist[deviceWithSameName.subDevice]->key;
186 return false;
187 }
188
189 sensorLocationMap[name] = SensorInSubDevice(p, s);
190 }
191 }
192 }
193
194 // Fill the indices map given the name of all the subdevices
195 std::vector<SensorInSubDevice>& sensIndicesMap = m_indicesMap[static_cast<size_t>(sensorType)];
196 sensIndicesMap.resize(m_remappedSensors[sensorType].size());
197 for(size_t i=0; i < m_remappedSensors[sensorType].size(); i++)
198 {
199 std::string name = m_remappedSensors[sensorType][i];
200 if (sensorLocationMap.find(name) == sensorLocationMap.end())
201 {
202 yCError(MULTIPLEANALOGSENSORSREMAPPER) << "Impossible to find sensor name" << name << ", exiting.";
203 return false;
204 }
205
206 sensIndicesMap[i] = sensorLocationMap.find(name)->second;
207 }
208
209 return true;
210}
211
212
213
215{
216 bool ok = true;
217 m_indicesMap.resize(MAS_NrOfSensorTypes);
218 ok = ok && genericAttachAll(ThreeAxisGyroscopes, m_iThreeAxisGyroscopes, polylist,
219 &IThreeAxisGyroscopes::getThreeAxisGyroscopeName, &IThreeAxisGyroscopes::getNrOfThreeAxisGyroscopes);
220 ok = ok && genericAttachAll(ThreeAxisLinearAccelerometers, m_iThreeAxisLinearAccelerometers, polylist,
221 &IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerName, &IThreeAxisLinearAccelerometers::getNrOfThreeAxisLinearAccelerometers);
222 ok = ok && genericAttachAll(ThreeAxisMagnetometers, m_iThreeAxisMagnetometers, polylist,
223 &IThreeAxisMagnetometers::getThreeAxisMagnetometerName, &IThreeAxisMagnetometers::getNrOfThreeAxisMagnetometers);
224 ok = ok && genericAttachAll(PositionSensors, m_iPositionSensors, polylist,
225 &IPositionSensors::getPositionSensorName, &IPositionSensors::getNrOfPositionSensors);
226 ok = ok && genericAttachAll(OrientationSensors, m_iOrientationSensors, polylist,
227 &IOrientationSensors::getOrientationSensorName, &IOrientationSensors::getNrOfOrientationSensors);
228 ok = ok && genericAttachAll(TemperatureSensors, m_iTemperatureSensors, polylist,
229 &ITemperatureSensors::getTemperatureSensorName, &ITemperatureSensors::getNrOfTemperatureSensors);
230 ok = ok && genericAttachAll(SixAxisForceTorqueSensors, m_iSixAxisForceTorqueSensors, polylist,
231 &ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorName, &ISixAxisForceTorqueSensors::getNrOfSixAxisForceTorqueSensors);
232 ok = ok && genericAttachAll(ContactLoadCellArrays, m_iContactLoadCellArrays, polylist,
233 &IContactLoadCellArrays::getContactLoadCellArrayName, &IContactLoadCellArrays::getNrOfContactLoadCellArrays);
234 ok = ok && genericAttachAll(EncoderArrays, m_iEncoderArrays, polylist,
235 &IEncoderArrays::getEncoderArrayName, &IEncoderArrays::getNrOfEncoderArrays);
236 ok = ok && genericAttachAll(SkinPatches, m_iSkinPatches, polylist,
237 &ISkinPatches::getSkinPatchName, &ISkinPatches::getNrOfSkinPatches);
238
239 return ok;
240}
241
243{
244 m_iThreeAxisGyroscopes.resize(0);
245 m_iThreeAxisLinearAccelerometers.resize(0);
246 m_iThreeAxisMagnetometers.resize(0);
247 m_iPositionSensors.resize(0);
248 m_iOrientationSensors.resize(0);
249 m_iTemperatureSensors.resize(0);
250 m_iSixAxisForceTorqueSensors.resize(0);
251 m_iContactLoadCellArrays.resize(0);
252 m_iEncoderArrays.resize(0);
253 m_iSkinPatches.resize(0);
254 m_indicesMap.resize(0);
255 return true;
256}
257
258
259template<typename Interface>
260MAS_status MultipleAnalogSensorsRemapper::genericGetStatus(const MAS_SensorType sensorType,
261 size_t& sens_index,
262 const std::vector<Interface *>& subDeviceVec,
263 MAS_status (Interface::*methodPtr)(size_t) const) const
264{
265 size_t nrOfAvailableSensors = m_indicesMap[sensorType].size();
266 if (sens_index >= nrOfAvailableSensors)
267 {
268 if (m_verbose)
269 {
270 yCError(MULTIPLEANALOGSENSORSREMAPPER, "genericGetStatus sens_index %zu out of range of available sensors (%zu).", sens_index, nrOfAvailableSensors);
271 }
272 return MAS_ERROR;
273 }
274
275 SensorInSubDevice subDeviceSensor = m_indicesMap[sensorType][sens_index];
276 return MAS_CALL_MEMBER_FN(subDeviceVec[subDeviceSensor.subDevice], methodPtr)(subDeviceSensor.indexInSubDevice);
277}
278
279template<typename Interface>
280bool MultipleAnalogSensorsRemapper::genericGetName(const MAS_SensorType sensorType,
281 size_t& sens_index, std::string &name,
282 const std::vector<Interface *>& subDeviceVec,
283 bool (Interface::*methodPtr)(size_t, std::string &) const) const
284{
285 size_t nrOfAvailableSensors = m_indicesMap[sensorType].size();
286 if (sens_index >= nrOfAvailableSensors)
287 {
288 if (m_verbose)
289 {
290 yCError(MULTIPLEANALOGSENSORSREMAPPER, "genericGetName sens_index %zu out of range of available sensors (%zu).", sens_index, nrOfAvailableSensors);
291 }
292 return MAS_ERROR;
293 }
294
295 SensorInSubDevice subDeviceSensor = m_indicesMap[sensorType][sens_index];
296 return MAS_CALL_MEMBER_FN(subDeviceVec[subDeviceSensor.subDevice], methodPtr)(subDeviceSensor.indexInSubDevice, name);
297}
298
299template<typename Interface>
300bool MultipleAnalogSensorsRemapper::genericGetFrameName(const MAS_SensorType sensorType,
301 size_t& sens_index, std::string &name,
302 const std::vector<Interface *>& subDeviceVec,
303 bool (Interface::*methodPtr)(size_t, std::string &) const) const
304{
305 size_t nrOfAvailableSensors = m_indicesMap[sensorType].size();
306 if (sens_index >= nrOfAvailableSensors)
307 {
308 if (m_verbose)
309 {
310 yCError(MULTIPLEANALOGSENSORSREMAPPER, "genericGetFrameName sens_index %zu out of range of available sensors (%zu).", sens_index, nrOfAvailableSensors);
311 }
312 return MAS_ERROR;
313 }
314
315 SensorInSubDevice subDeviceSensor = m_indicesMap[sensorType][sens_index];
316 return MAS_CALL_MEMBER_FN(subDeviceVec[subDeviceSensor.subDevice], methodPtr)(subDeviceSensor.indexInSubDevice, name);
317}
318
319
320template<typename Interface>
321bool MultipleAnalogSensorsRemapper::genericGetMeasure(const MAS_SensorType sensorType,
322 size_t& sens_index, yarp::sig::Vector& out, double& timestamp,
323 const std::vector<Interface *>& subDeviceVec,
324 bool (Interface::*methodPtr)(size_t, yarp::sig::Vector&, double&) const) const
325{
326 size_t nrOfAvailableSensors = m_indicesMap[sensorType].size();
327 if (sens_index >= nrOfAvailableSensors)
328 {
329 if (m_verbose)
330 {
331 yCError(MULTIPLEANALOGSENSORSREMAPPER, "genericGetMeasure sens_index %zu out of range of available sensors (%zu).", sens_index, nrOfAvailableSensors);
332 }
333 return MAS_ERROR;
334 }
335
336 SensorInSubDevice subDeviceSensor = m_indicesMap[sensorType][sens_index];
337 return MAS_CALL_MEMBER_FN(subDeviceVec[subDeviceSensor.subDevice], methodPtr)(subDeviceSensor.indexInSubDevice, out, timestamp);
338}
339
340template<typename Interface>
341size_t MultipleAnalogSensorsRemapper::genericGetSize(const MAS_SensorType sensorType,
342 size_t& sens_index,
343 const std::vector<Interface *>& subDeviceVec,
344 size_t (Interface::*methodPtr)(size_t) const) const
345{
346 size_t nrOfAvailableSensors = m_indicesMap[sensorType].size();
347 if (sens_index >= nrOfAvailableSensors)
348 {
349 if (m_verbose)
350 {
351 yCError(MULTIPLEANALOGSENSORSREMAPPER, "genericGetSize sens_index %zu out of range of available sensors (%zu).", sens_index, nrOfAvailableSensors);
352 }
353 return MAS_ERROR;
354 }
355
356 SensorInSubDevice subDeviceSensor = m_indicesMap[sensorType][sens_index];
357 return MAS_CALL_MEMBER_FN(subDeviceVec[subDeviceSensor.subDevice], methodPtr)(subDeviceSensor.indexInSubDevice);
358}
359
360/*
361All the sensor specific methods (excluding the IOrientationSensor and the ISkinPatches) are just an instantiation of the following template (note: we avoid code generation for the sake of readability):
362
363size_t MultipleAnalogSensorsRemapper::getNrOf{{SensorTag}}s() const
364{
365 return m_indicesMap[{{SensorTag}}s].size();
366}
367
368MAS_status MultipleAnalogSensorsRemapper::get{{SensorTag}}Status(size_t sens_index) const
369{
370 return genericGetStatus({{SensorTag}}s, sens_index, m_i{{SensorTag}}s, &I{{SensorTag}}s::get{{SensorTag}}Status);
371}
372
373bool MultipleAnalogSensorsRemapper::get{{SensorTag}}Name(size_t sens_index, std::string& name) const
374{
375 return genericGetName({{SensorTag}}s, sens_index, name, m_i{{SensorTag}}s, &I{{SensorTag}}s::get{{SensorTag}}Name);
376}
377
378bool MultipleAnalogSensorsRemapper::get{{SensorTag}}Measure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
379{
380 return genericGetMeasure({{SensorTag}}s, sens_index, out, timestamp, m_i{{SensorTag}}s, &I{{SensorTag}}s::get{{SensorTag}}Measure);
381}
382
383For the sensors (EncoderArray and SkinPatch) of which the measurements can change size, we also have:
384size_t MultipleAnalogSensorsRemapper::get{{SensorTag}}Size(size_t sens_index) const
385{
386 return genericGetSize({{SensorTag}}s, sens_index, m_i{{SensorTag}}s, &I{{SensorTag}}s::get{{SensorTag}}Size);
387}
388
389*/
390
392{
393 return m_indicesMap[ThreeAxisGyroscopes].size();
394}
395
397{
398 return genericGetStatus(ThreeAxisGyroscopes, sens_index, m_iThreeAxisGyroscopes, &IThreeAxisGyroscopes::getThreeAxisGyroscopeStatus);
399}
400
401bool MultipleAnalogSensorsRemapper::getThreeAxisGyroscopeName(size_t sens_index, std::string& name) const
402{
403 return genericGetName(ThreeAxisGyroscopes, sens_index, name, m_iThreeAxisGyroscopes, &IThreeAxisGyroscopes::getThreeAxisGyroscopeName);
404}
405
406bool MultipleAnalogSensorsRemapper::getThreeAxisGyroscopeFrameName(size_t sens_index, std::string& frameName) const
407{
408 return genericGetFrameName(ThreeAxisGyroscopes, sens_index, frameName, m_iThreeAxisGyroscopes, &IThreeAxisGyroscopes::getThreeAxisGyroscopeFrameName);
409}
410
411bool MultipleAnalogSensorsRemapper::getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
412{
413 return genericGetMeasure(ThreeAxisGyroscopes, sens_index, out, timestamp, m_iThreeAxisGyroscopes, &IThreeAxisGyroscopes::getThreeAxisGyroscopeMeasure);
414}
415
417{
418 return m_indicesMap[ThreeAxisLinearAccelerometers].size();
419}
420
422{
423 return genericGetStatus(ThreeAxisLinearAccelerometers, sens_index, m_iThreeAxisLinearAccelerometers, &IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerStatus);
424}
425
426bool MultipleAnalogSensorsRemapper::getThreeAxisLinearAccelerometerName(size_t sens_index, std::string& name) const
427{
428 return genericGetName(ThreeAxisLinearAccelerometers, sens_index, name, m_iThreeAxisLinearAccelerometers, &IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerName);
429}
430
431bool MultipleAnalogSensorsRemapper::getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string& frameName) const
432{
433 return genericGetFrameName(ThreeAxisLinearAccelerometers, sens_index, frameName, m_iThreeAxisLinearAccelerometers, &IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerFrameName);
434}
435
437{
438 return genericGetMeasure(ThreeAxisLinearAccelerometers, sens_index, out, timestamp, m_iThreeAxisLinearAccelerometers, &IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerMeasure);
439}
440
442{
443 return m_indicesMap[ThreeAxisMagnetometers].size();
444}
445
447{
448 return genericGetStatus(ThreeAxisMagnetometers, sens_index, m_iThreeAxisMagnetometers, &IThreeAxisMagnetometers::getThreeAxisMagnetometerStatus);
449}
450
451bool MultipleAnalogSensorsRemapper::getThreeAxisMagnetometerName(size_t sens_index, std::string& name) const
452{
453 return genericGetName(ThreeAxisMagnetometers, sens_index, name, m_iThreeAxisMagnetometers, &IThreeAxisMagnetometers::getThreeAxisMagnetometerName);
454}
455
456bool MultipleAnalogSensorsRemapper::getThreeAxisMagnetometerFrameName(size_t sens_index, std::string& frameName) const
457{
458 return genericGetFrameName(ThreeAxisMagnetometers, sens_index, frameName, m_iThreeAxisMagnetometers, &IThreeAxisMagnetometers::getThreeAxisMagnetometerFrameName);
459}
460
461bool MultipleAnalogSensorsRemapper::getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
462{
463 return genericGetMeasure(ThreeAxisMagnetometers, sens_index, out, timestamp, m_iThreeAxisMagnetometers, &IThreeAxisMagnetometers::getThreeAxisMagnetometerMeasure);
464}
465
467{
468 return m_indicesMap[PositionSensors].size();
469}
470
472{
473 return genericGetStatus(PositionSensors, sens_index, m_iPositionSensors, &IPositionSensors::getPositionSensorStatus);
474}
475
476bool MultipleAnalogSensorsRemapper::getPositionSensorName(size_t sens_index, std::string& name) const
477{
478 return genericGetName(PositionSensors, sens_index, name, m_iPositionSensors, &IPositionSensors::getPositionSensorName);
479}
480
481bool MultipleAnalogSensorsRemapper::getPositionSensorFrameName(size_t sens_index, std::string& frameName) const
482{
483 return genericGetFrameName(PositionSensors, sens_index, frameName, m_iPositionSensors, &IPositionSensors::getPositionSensorFrameName);
484}
485
486bool MultipleAnalogSensorsRemapper::getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
487{
488 return genericGetMeasure(PositionSensors, sens_index, out, timestamp, m_iPositionSensors, &IPositionSensors::getPositionSensorMeasure);
489}
490
492{
493 return m_indicesMap[OrientationSensors].size();
494}
495
497{
498 return genericGetStatus(OrientationSensors, sens_index, m_iOrientationSensors, &IOrientationSensors::getOrientationSensorStatus);
499}
500
501bool MultipleAnalogSensorsRemapper::getOrientationSensorName(size_t sens_index, std::string& name) const
502{
503 return genericGetName(OrientationSensors, sens_index, name, m_iOrientationSensors, &IOrientationSensors::getOrientationSensorName);
504}
505
506bool MultipleAnalogSensorsRemapper::getOrientationSensorFrameName(size_t sens_index, std::string& frameName) const
507{
508 return genericGetFrameName(OrientationSensors, sens_index, frameName, m_iOrientationSensors, &IOrientationSensors::getOrientationSensorFrameName);
509}
510
512{
513 return genericGetMeasure(OrientationSensors, sens_index, out, timestamp, m_iOrientationSensors, &IOrientationSensors::getOrientationSensorMeasureAsRollPitchYaw);
514}
515
517{
518 return m_indicesMap[TemperatureSensors].size();
519}
520
522{
523 return genericGetStatus(TemperatureSensors, sens_index, m_iTemperatureSensors, &ITemperatureSensors::getTemperatureSensorStatus);
524}
525
526bool MultipleAnalogSensorsRemapper::getTemperatureSensorName(size_t sens_index, std::string& name) const
527{
528 return genericGetName(TemperatureSensors, sens_index, name, m_iTemperatureSensors, &ITemperatureSensors::getTemperatureSensorName);
529}
530
531bool MultipleAnalogSensorsRemapper::getTemperatureSensorFrameName(size_t sens_index, std::string& frameName) const
532{
533 return genericGetFrameName(TemperatureSensors, sens_index, frameName, m_iTemperatureSensors, &ITemperatureSensors::getTemperatureSensorFrameName);
534}
535
536bool MultipleAnalogSensorsRemapper::getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
537{
538 return genericGetMeasure(TemperatureSensors, sens_index, out, timestamp, m_iTemperatureSensors, &ITemperatureSensors::getTemperatureSensorMeasure);
539}
540
541bool MultipleAnalogSensorsRemapper::getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const
542{
543 yarp::sig::Vector dummy(1);
544 bool ok = genericGetMeasure(TemperatureSensors, sens_index, dummy, timestamp, m_iTemperatureSensors, &ITemperatureSensors::getTemperatureSensorMeasure);
545 out = dummy[0];
546 return ok;
547}
548
550{
551 return m_indicesMap[SixAxisForceTorqueSensors].size();
552}
553
555{
556 return genericGetStatus(SixAxisForceTorqueSensors, sens_index, m_iSixAxisForceTorqueSensors, &ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorStatus);
557}
558
559bool MultipleAnalogSensorsRemapper::getSixAxisForceTorqueSensorName(size_t sens_index, std::string& name) const
560{
561 return genericGetName(SixAxisForceTorqueSensors, sens_index, name, m_iSixAxisForceTorqueSensors, &ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorName);
562}
563
564bool MultipleAnalogSensorsRemapper::getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string& frameName) const
565{
566 return genericGetFrameName(SixAxisForceTorqueSensors, sens_index, frameName, m_iSixAxisForceTorqueSensors, &ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorFrameName);
567}
568
570{
571 return genericGetMeasure(SixAxisForceTorqueSensors, sens_index, out, timestamp, m_iSixAxisForceTorqueSensors, &ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorMeasure);
572}
573
575{
576 return m_indicesMap[ContactLoadCellArrays].size();
577}
578
580{
581 return genericGetStatus(ContactLoadCellArrays, sens_index, m_iContactLoadCellArrays, &IContactLoadCellArrays::getContactLoadCellArrayStatus);
582}
583
584bool MultipleAnalogSensorsRemapper::getContactLoadCellArrayName(size_t sens_index, std::string& name) const
585{
586 return genericGetName(ContactLoadCellArrays, sens_index, name, m_iContactLoadCellArrays, &IContactLoadCellArrays::getContactLoadCellArrayName);
587}
588
589bool MultipleAnalogSensorsRemapper::getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
590{
591 return genericGetMeasure(ContactLoadCellArrays, sens_index, out, timestamp, m_iContactLoadCellArrays, &IContactLoadCellArrays::getContactLoadCellArrayMeasure);
592}
593
595{
596 return genericGetSize(ContactLoadCellArrays, sens_index, m_iContactLoadCellArrays, &IContactLoadCellArrays::getContactLoadCellArraySize);
597}
598
600{
601 return m_indicesMap[EncoderArrays].size();
602}
603
605{
606 return genericGetStatus(EncoderArrays, sens_index, m_iEncoderArrays, &IEncoderArrays::getEncoderArrayStatus);
607}
608
609bool MultipleAnalogSensorsRemapper::getEncoderArrayName(size_t sens_index, std::string& name) const
610{
611 return genericGetName(EncoderArrays, sens_index, name, m_iEncoderArrays, &IEncoderArrays::getEncoderArrayName);
612}
613
614bool MultipleAnalogSensorsRemapper::getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
615{
616 return genericGetMeasure(EncoderArrays, sens_index, out, timestamp, m_iEncoderArrays, &IEncoderArrays::getEncoderArrayMeasure);
617}
618
620{
621 return genericGetSize(EncoderArrays, sens_index, m_iEncoderArrays, &IEncoderArrays::getEncoderArraySize);
622}
623
625{
626 return m_indicesMap[SkinPatches].size();
627}
628
630{
631 return genericGetStatus(SkinPatches, sens_index, m_iSkinPatches, &ISkinPatches::getSkinPatchStatus);
632}
633
634bool MultipleAnalogSensorsRemapper::getSkinPatchName(size_t sens_index, std::string& name) const
635{
636 return genericGetName(SkinPatches, sens_index, name, m_iSkinPatches, &ISkinPatches::getSkinPatchName);
637}
638
639bool MultipleAnalogSensorsRemapper::getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
640{
641 return genericGetMeasure(SkinPatches, sens_index, out, timestamp, m_iSkinPatches, &ISkinPatches::getSkinPatchMeasure);
642}
643
645{
646 return genericGetSize(SkinPatches, sens_index, m_iSkinPatches, &ISkinPatches::getSkinPatchSize);
647}
const size_t MAS_NrOfSensorTypes
#define MAS_CALL_MEMBER_FN(object, ptrToMember)
bool getVectorOfStringFromListInConfig(const std::string &key, const yarp::os::Searchable &config, std::vector< std::string > &vectorOfStrings)
std::string MAS_getTagFromEnum(const MAS_SensorType type)
Internal identifier of the type of sensors.
MAS_SensorType
Internal identifier of the type of sensors.
@ ThreeAxisLinearAccelerometers
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.
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:251
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
A class for storing options and configuration information.
Definition: Property.h:33
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Property.cpp:1051
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1063
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Property.cpp:1041
A base class for nested structures that can be searched.
Definition: Searchable.h:63
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:240
virtual std::string asString() const
Get string value.
Definition: Value.cpp:234
#define yCInfo(component,...)
Definition: LogComponent.h:171
#define yCError(component,...)
Definition: LogComponent.h:213
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:76
For streams capable of holding different kinds of content, check what they actually have.
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_ERROR
The sensor is in generic error state.
An interface to the operating system, including Port based communication.