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