YARP
Yet Another Robot Platform
MultipleAnalogSensorsClient.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 "SensorStreamingData.h"
10 
11 #include <yarp/os/LogComponent.h>
12 
13 namespace {
14 YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSCLIENT, "yarp.device.multipleanalogsensorsclient")
15 }
16 
18 {
19  std::lock_guard<std::mutex> guard(dataMutex);
20  receivedData = v;
23 }
24 
26 {
28  {
29  double now = yarp::os::Time::now();
31  {
32  yCError(MULTIPLEANALOGSENSORSCLIENT,
33  "No data received in the last %lf seconds, timeout enabled.",
36  }
37  }
38 }
39 
41 {
42  m_externalConnection = config.check("externalConnection",yarp::os::Value(false)).asBool();
43  if (!config.check("remote"))
44  {
45  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing name parameter, exiting.");
46  return false;
47  }
48 
49  if (!config.check("local"))
50  {
51  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing local parameter, exiting.");
52  return false;
53  }
54 
55  if (config.check("timeout") && !(config.find("timeout").isFloat64()))
56  {
57  yCError(MULTIPLEANALOGSENSORSCLIENT, "'timeout' parameter is present but is not double, exiting.");
58  return false;
59  }
60 
61  std::string remote = config.find("remote").asString();
62  std::string local = config.find("local").asString();
63 
64  // Optional timeout parameter
65  m_streamingPort.timeoutInSeconds = config.check("timeout", yarp::os::Value(0.01), "Timeout parameter").asFloat64();
66 
67  m_localRPCPortName = local + "/rpc:i";
68  m_localStreamingPortName = local + "/measures:i";
69  m_remoteRPCPortName = remote + "/rpc:o";
70  m_remoteStreamingPortName = remote + "/measures:o";
71 
72  // TODO(traversaro) : as soon as the method for checking port names validity
73  // are available in YARP ( https://github.com/robotology/yarp/pull/1508 ) add some checks
74 
75  // Open ports
76  bool ok = m_rpcPort.open(m_localRPCPortName);
77  if (!ok)
78  {
79  yCError(MULTIPLEANALOGSENSORSCLIENT,
80  "Failure to open the port %s.",
81  m_localRPCPortName.c_str());
82  close();
83  return false;
84  }
85 
86  ok = m_streamingPort.open(m_localStreamingPortName);
87  m_streamingPort.useCallback();
88  if (!ok)
89  {
90  yCError(MULTIPLEANALOGSENSORSCLIENT,
91  "Failure to open the port %s.",
92  m_localStreamingPortName.c_str());
93  close();
94  return false;
95  }
96 
97  // Connect ports
98  if (!m_externalConnection) {
99  ok = yarp::os::Network::connect(m_localRPCPortName, m_remoteRPCPortName);
100  if (!ok) {
101  yCError(MULTIPLEANALOGSENSORSCLIENT,
102  "Failure connecting port %s to %s.",
103  m_localRPCPortName.c_str(),
104  m_remoteRPCPortName.c_str());
105  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
106  close();
107  return false;
108  }
109  m_RPCConnectionActive = true;
110 
111  ok = yarp::os::Network::connect(m_remoteStreamingPortName, m_localStreamingPortName);
112  if (!ok) {
113  yCError(MULTIPLEANALOGSENSORSCLIENT,
114  "Failure connecting port %s to %s.",
115  m_remoteStreamingPortName.c_str(),
116  m_localStreamingPortName.c_str());
117  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
118  close();
119  return false;
120  }
121  m_StreamingConnectionActive = true;
122 
123  // Once the connection is active, we just the metadata only once
124  ok = m_RPCInterface.yarp().attachAsClient(m_rpcPort);
125  if (!ok) {
126  yCError(MULTIPLEANALOGSENSORSCLIENT, "Failure opening Thrift-based RPC interface.");
127  return false;
128  }
129 
130  // TODO(traversaro): there is a limitation on the thrift-generated
131  // YARP structures related to how to get connection errors during the call
132  // If this is ever solved at YARP level, we should properly handle errors
133  // here
134  m_sensorsMetadata = m_RPCInterface.getMetadata();
135 
136  }
137 
138  return true;
139 }
140 
142 {
143  if (m_StreamingConnectionActive)
144  {
145  yarp::os::Network::disconnect(m_remoteStreamingPortName, m_localStreamingPortName);
146  }
147  if (m_RPCConnectionActive)
148  {
149  yarp::os::Network::disconnect(m_localRPCPortName, m_remoteRPCPortName);
150  }
151 
152  m_streamingPort.close();
153  m_rpcPort.close();
154 
155  return true;
156 }
157 
158 size_t MultipleAnalogSensorsClient::genericGetNrOfSensors(const std::vector<SensorMetadata>& metadataVector,
159  const SensorMeasurements& measurementsVector) const
160 {
161  if (!m_externalConnection) {
162  return metadataVector.size();
163  } else {
164  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
165  m_streamingPort.updateTimeoutStatus();
166  if (m_streamingPort.status == yarp::dev::MAS_OK) {
167  return measurementsVector.measurements.size();
168  } else {
169  return 0;
170  }
171  }
172 }
173 
174 yarp::dev::MAS_status MultipleAnalogSensorsClient::genericGetStatus() const
175 {
176  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
177  m_streamingPort.updateTimeoutStatus();
178  return m_streamingPort.status;
179 }
180 
181 bool MultipleAnalogSensorsClient::genericGetName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
182  size_t sens_index, std::string& name) const
183 {
184  if (m_externalConnection) {
185  yCError(MULTIPLEANALOGSENSORSCLIENT,
186  "Missing metadata, the device has been configured with the option"
187  "externalConnection set to true.");
188  return false;
189  }
190  if (sens_index >= metadataVector.size())
191  {
192  yCError(MULTIPLEANALOGSENSORSCLIENT,
193  "No sensor of type %s with index %lu (nr of sensors: %lu).",
194  tag.c_str(),
195  sens_index,
196  metadataVector.size());
197  return false;
198  }
199 
200  name = metadataVector[sens_index].name;
201  return true;
202 }
203 
204 bool MultipleAnalogSensorsClient::genericGetFrameName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
205  size_t sens_index, std::string& frameName) const
206 {
207  if (m_externalConnection) {
208  yCError(MULTIPLEANALOGSENSORSCLIENT,
209  "Missing metadata, the device has been configured with the option"
210  "externalConnection set to true.");
211  return false;
212  }
213  if (sens_index >= metadataVector.size())
214  {
215  yCError(MULTIPLEANALOGSENSORSCLIENT,
216  "No sensor of type %s with index %lu (nr of sensors: %lu).",
217  tag.c_str(),
218  sens_index,
219  metadataVector.size());
220  return false;
221  }
222 
223  frameName = metadataVector[sens_index].frameName;
224  return true;
225 }
226 
227 bool MultipleAnalogSensorsClient::genericGetMeasure(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
228  const SensorMeasurements& measurementsVector,
229  size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
230 {
231 
232  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
233  m_streamingPort.updateTimeoutStatus();
234  if (m_streamingPort.status != yarp::dev::MAS_OK)
235  {
236  yCError(MULTIPLEANALOGSENSORSCLIENT,
237  "Sensor of type %s with index %lu has non-MAS_OK status.",
238  tag.c_str(),
239  sens_index);
240  return false;
241  }
242 
243  if (m_streamingPort.status != (sens_index >= measurementsVector.measurements.size()))
244  {
245  yCError(MULTIPLEANALOGSENSORSCLIENT,
246  "No sensor of type %s with index %lu (nr of sensors: %lu).",
247  tag.c_str(),
248  sens_index,
249  metadataVector.size());
250  return false;
251  }
252 
253  if (!m_externalConnection) {
254  assert(metadataVector.size() == measurementsVector.measurements.size());
255  }
256 
257  timestamp = measurementsVector.measurements[sens_index].timestamp;
258  out = measurementsVector.measurements[sens_index].measurement;
259 
260  return true;
261 }
262 
263 size_t MultipleAnalogSensorsClient::genericGetSize(const std::vector<SensorMetadata>& metadataVector,
264  const std::string& tag, const SensorMeasurements& measurementsVector, size_t sens_index) const
265 {
266  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
267  if (m_streamingPort.status != yarp::dev::MAS_OK)
268  {
269  yCError(MULTIPLEANALOGSENSORSCLIENT, "No data received, no information on the size of the specified sensor.");
270  return 0;
271  }
272 
273 
274  if (sens_index >= measurementsVector.measurements.size())
275  {
276  yCError(MULTIPLEANALOGSENSORSCLIENT,
277  "No sensor of type %s with index %lu (nr of sensors: %lu).",
278  tag.c_str(),
279  sens_index,
280  metadataVector.size());
281  return 0;
282  }
283 
284  return measurementsVector.measurements[sens_index].measurement.size();
285 }
286 
287 /*
288 All the sensor specific methods (excluding the IOrientationSensor and the ISkinPatches) are just
289 an instantiation of the following template (note: we avoid code generation for the sake of readability):
290 
291 {{SensorTag}} : ThreeAxisGyroscopes, ThreeAxisLinearAccelerometers, etc
292 {{SensorSingular}} : ThreeAxisGyroscope, ThreeAxisLinearAccelerometer, etc
293 
294 size_t MultipleAnalogSensorsClient::getNrOf{{SensorTag}}() const
295 {
296  return genericGetNrOfSensors(m_sensorsMetadata.{{SensorTag}});
297 }
298 
299 MAS_status MultipleAnalogSensorsClient::get{{SensorSingular}}Status(size_t sens_index) const
300 {
301  return genericGetStatus();
302 }
303 
304 bool MultipleAnalogSensorsClient::get{{SensorSingular}}Name(size_t sens_index, std::string& name) const
305 {
306  return genericGetName(m_sensorsMetadata.{{SensorTag}}, "{{SensorTag}}", sens_index, name);
307 }
308 
309 bool MultipleAnalogSensorsClient::get{{SensorSingular}}Measure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
310 {
311  return genericGetMeasure(m_sensorsMetadata.{{SensorTag}}, "{{SensorTag}}",
312  m_streamingPort.receivedData.{{SensorTag}}, sens_index, out, timestamp);
313 }
314 
315 For the sensors (EncoderArray and SkinPatch) of which the measurements can change size, we also have:
316 size_t MultipleAnalogSensorsClient::get{{SensorSingular}}Size(size_t sens_index) const
317 {
318  return genericGetSize({{SensorTag}}, sens_index, m_i{{SensorTag}}, &I{{SensorTag}}::get{{SensorTag}}Size);
319 }
320 
321 */
322 
324 {
325  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisGyroscopes,
326  m_streamingPort.receivedData.ThreeAxisGyroscopes);
327 }
328 
330 {
331  return genericGetStatus();
332 }
333 
334 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const
335 {
336  return genericGetName(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes", sens_index, name);
337 }
338 
339 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const
340 {
341  return genericGetFrameName(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes", sens_index, frameName);
342 }
343 
344 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
345 {
346  return genericGetMeasure(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes",
347  m_streamingPort.receivedData.ThreeAxisGyroscopes, sens_index, out, timestamp);
348 }
349 
351 {
352  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisLinearAccelerometers,
354 }
355 
357 {
358  return genericGetStatus();
359 }
360 
361 bool MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const
362 {
363  return genericGetName(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers", sens_index, name);
364 }
365 
366 bool MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const
367 {
368  return genericGetFrameName(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers", sens_index, frameName);
369 }
370 
372 {
373  return genericGetMeasure(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers",
374  m_streamingPort.receivedData.ThreeAxisLinearAccelerometers, sens_index, out, timestamp);
375 }
376 
378 {
379  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisMagnetometers,
380  m_streamingPort.receivedData.ThreeAxisMagnetometers);
381 }
382 
384 {
385  return genericGetStatus();
386 }
387 
388 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerName(size_t sens_index, std::string& name) const
389 {
390  return genericGetName(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers", sens_index, name);
391 }
392 
393 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const
394 {
395  return genericGetFrameName(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers", sens_index, frameName);
396 }
397 
398 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
399 {
400  return genericGetMeasure(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers",
401  m_streamingPort.receivedData.ThreeAxisMagnetometers, sens_index, out, timestamp);
402 }
403 
405 {
406  return genericGetNrOfSensors(m_sensorsMetadata.OrientationSensors,
407  m_streamingPort.receivedData.OrientationSensors);
408 }
409 
411 {
412  return genericGetStatus();
413 }
414 
415 bool MultipleAnalogSensorsClient::getOrientationSensorName(size_t sens_index, std::string& name) const
416 {
417  return genericGetName(m_sensorsMetadata.OrientationSensors, "OrientationSensors", sens_index, name);
418 }
419 
420 bool MultipleAnalogSensorsClient::getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const
421 {
422  return genericGetFrameName(m_sensorsMetadata.OrientationSensors, "OrientationSensors", sens_index, frameName);
423 }
424 
426 {
427  return genericGetMeasure(m_sensorsMetadata.OrientationSensors, "OrientationSensors",
428  m_streamingPort.receivedData.OrientationSensors, sens_index, out, timestamp);
429 }
430 
432 {
433  return genericGetNrOfSensors(m_sensorsMetadata.PositionSensors,
434  m_streamingPort.receivedData.PositionSensors);
435 }
436 
438 {
439  return genericGetStatus();
440 }
441 
442 bool MultipleAnalogSensorsClient::getPositionSensorName(size_t sens_index, std::string& name) const
443 {
444  return genericGetName(m_sensorsMetadata.PositionSensors, "PositionSensors", sens_index, name);
445 }
446 
447 bool MultipleAnalogSensorsClient::getPositionSensorFrameName(size_t sens_index, std::string& frameName) const
448 {
449  return genericGetFrameName(m_sensorsMetadata.PositionSensors, "PositionSensors", sens_index, frameName);
450 }
451 
452 bool MultipleAnalogSensorsClient::getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
453 {
454  return genericGetMeasure(m_sensorsMetadata.PositionSensors, "PositionSensors", m_streamingPort.receivedData.PositionSensors, sens_index, out, timestamp);
455 }
456 
458 {
459  return genericGetNrOfSensors(m_sensorsMetadata.TemperatureSensors,
460  m_streamingPort.receivedData.TemperatureSensors);
461 }
462 
464 {
465  return genericGetStatus();
466 }
467 
468 bool MultipleAnalogSensorsClient::getTemperatureSensorName(size_t sens_index, std::string& name) const
469 {
470  return genericGetName(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors", sens_index, name);
471 }
472 
473 bool MultipleAnalogSensorsClient::getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const
474 {
475  return genericGetFrameName(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors", sens_index, frameName);
476 }
477 
478 bool MultipleAnalogSensorsClient::getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
479 {
480  return genericGetMeasure(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors",
481  m_streamingPort.receivedData.TemperatureSensors, sens_index, out, timestamp);
482 }
483 
484 bool MultipleAnalogSensorsClient::getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const
485 {
486  yarp::sig::Vector dummy(1);
487  bool ok = this->getTemperatureSensorMeasure(sens_index, dummy, timestamp);
488  out = dummy[0];
489  return ok;
490 }
491 
493 {
494  return genericGetNrOfSensors(m_sensorsMetadata.SixAxisForceTorqueSensors,
495  m_streamingPort.receivedData.SixAxisForceTorqueSensors);
496 }
497 
499 {
500  return genericGetStatus();
501 }
502 
503 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorName(size_t sens_index, std::string& name) const
504 {
505  return genericGetName(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors", sens_index, name);
506 }
507 
508 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frameName) const
509 {
510  return genericGetFrameName(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors", sens_index, frameName);
511 }
512 
513 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
514 {
515  return genericGetMeasure(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors",
516  m_streamingPort.receivedData.SixAxisForceTorqueSensors, sens_index, out, timestamp);
517 }
518 
520 {
521  return genericGetNrOfSensors(m_sensorsMetadata.ContactLoadCellArrays,
522  m_streamingPort.receivedData.ContactLoadCellArrays);
523 }
524 
526 {
527  return genericGetStatus();
528 }
529 
530 bool MultipleAnalogSensorsClient::getContactLoadCellArrayName(size_t sens_index, std::string& name) const
531 {
532  return genericGetName(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays", sens_index, name);
533 }
534 
535 bool MultipleAnalogSensorsClient::getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
536 {
537  return genericGetMeasure(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
538  m_streamingPort.receivedData.ContactLoadCellArrays, sens_index, out, timestamp);
539 }
540 
542 {
543  return genericGetSize(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
544  m_streamingPort.receivedData.ContactLoadCellArrays, sens_index);
545 }
546 
548 {
549  return genericGetNrOfSensors(m_sensorsMetadata.EncoderArrays,
550  m_streamingPort.receivedData.EncoderArrays);
551 }
552 
554 {
555  return genericGetStatus();
556 }
557 
558 bool MultipleAnalogSensorsClient::getEncoderArrayName(size_t sens_index, std::string& name) const
559 {
560  return genericGetName(m_sensorsMetadata.EncoderArrays, "EncoderArrays", sens_index, name);
561 }
562 
563 bool MultipleAnalogSensorsClient::getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
564 {
565  return genericGetMeasure(m_sensorsMetadata.EncoderArrays, "EncoderArrays",
566  m_streamingPort.receivedData.EncoderArrays, sens_index, out, timestamp);
567 }
568 
570 {
571  return genericGetSize(m_sensorsMetadata.EncoderArrays, "EncoderArrays",
572  m_streamingPort.receivedData.EncoderArrays, sens_index);
573 }
574 
576 {
577  return genericGetNrOfSensors(m_sensorsMetadata.SkinPatches,
578  m_streamingPort.receivedData.SkinPatches);
579 }
580 
582 {
583  return genericGetStatus();
584 }
585 
586 bool MultipleAnalogSensorsClient::getSkinPatchName(size_t sens_index, std::string& name) const
587 {
588  return genericGetName(m_sensorsMetadata.SkinPatches, "SkinPatches", sens_index, name);
589 }
590 
591 bool MultipleAnalogSensorsClient::getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
592 {
593  return genericGetMeasure(m_sensorsMetadata.SkinPatches, "SkinPatches",
594  m_streamingPort.receivedData.SkinPatches, sens_index, out, timestamp);
595 }
596 
597 size_t MultipleAnalogSensorsClient::getSkinPatchSize(size_t sens_index) const
598 {
599  return genericGetSize(m_sensorsMetadata.SkinPatches, "SkinPatches",
600  m_streamingPort.receivedData.SkinPatches, sens_index);
601 }
yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getSkinPatchName(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.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(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.
yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name 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 getEncoderArrayName(size_t sens_index, std::string &name) const override
Get the name 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 getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
size_t getNrOfTemperatureSensors() const override
Get the number of temperature sensors exposed by this device.
size_t getEncoderArraySize(size_t sens_index) const override
Get the size of the specified encoder array.
size_t getNrOfEncoderArrays() const override
Get the number of encoder arrays exposed by this device.
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 getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status 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 getNrOfSixAxisForceTorqueSensors() const override
Get the number of six axis force torque sensors exposed by this device.
bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const override
Get the last reading of the specified sensor.
size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch.
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
bool close() override
Close the DeviceDriver.
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.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status 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 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.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getTemperatureSensorName(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.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame 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.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
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 getNrOfSkinPatches() const override
Get the number of skin patches exposed by this device.
size_t getNrOfContactLoadCellArrays() const override
Get the number of contact load cell array exposed by this device.
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getSixAxisForceTorqueSensorName(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.
virtual SensorRPCData getMetadata()
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
std::vector< SensorMeasurement > measurements
std::vector< SensorMetadata > SkinPatches
Definition: SensorRPCData.h:31
std::vector< SensorMetadata > ContactLoadCellArrays
Definition: SensorRPCData.h:29
std::vector< SensorMetadata > EncoderArrays
Definition: SensorRPCData.h:30
std::vector< SensorMetadata > PositionSensors
Definition: SensorRPCData.h:32
std::vector< SensorMetadata > ThreeAxisGyroscopes
Definition: SensorRPCData.h:23
std::vector< SensorMetadata > ThreeAxisLinearAccelerometers
Definition: SensorRPCData.h:24
std::vector< SensorMetadata > ThreeAxisMagnetometers
Definition: SensorRPCData.h:25
std::vector< SensorMetadata > OrientationSensors
Definition: SensorRPCData.h:26
std::vector< SensorMetadata > SixAxisForceTorqueSensors
Definition: SensorRPCData.h:28
std::vector< SensorMetadata > TemperatureSensors
Definition: SensorRPCData.h:27
void onRead(SensorStreamingData &v) override
SensorMeasurements EncoderArrays
SensorMeasurements ThreeAxisLinearAccelerometers
SensorMeasurements PositionSensors
SensorMeasurements OrientationSensors
SensorMeasurements ThreeAxisMagnetometers
SensorMeasurements ThreeAxisGyroscopes
SensorMeasurements SixAxisForceTorqueSensors
SensorMeasurements SkinPatches
SensorMeasurements ContactLoadCellArrays
SensorMeasurements TemperatureSensors
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition: Network.cpp:682
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
Definition: Network.cpp:700
void close() override
Stop port activity.
Definition: Port.cpp:354
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:79
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
Definition: Value.h:45
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
Definition: Value.cpp:150
virtual std::string asString() const
Get string value.
Definition: Value.cpp:234
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition: Wire.h:29
#define yCError(component,...)
Definition: LogComponent.h:154
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:77
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_TIMEOUT
The sensor is read through the network, and the latest measurement was received before an implementat...
@ MAS_OK
The sensor is working correctly.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:121