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