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_carrier = config.check("carrier", yarp::os::Value("tcp"), "the carrier used for the connection with the server").asString();
43 
44  m_externalConnection = config.check("externalConnection",yarp::os::Value(false)).asBool();
45  if (!config.check("remote"))
46  {
47  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing name parameter, exiting.");
48  return false;
49  }
50 
51  if (!config.check("local"))
52  {
53  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing local parameter, exiting.");
54  return false;
55  }
56 
57  if (config.check("timeout") && !(config.find("timeout").isFloat64()))
58  {
59  yCError(MULTIPLEANALOGSENSORSCLIENT, "'timeout' parameter is present but is not double, exiting.");
60  return false;
61  }
62 
63  std::string remote = config.find("remote").asString();
64  std::string local = config.find("local").asString();
65 
66  // Optional timeout parameter
67  m_streamingPort.timeoutInSeconds = config.check("timeout", yarp::os::Value(0.01), "Timeout parameter").asFloat64();
68 
69  m_localRPCPortName = local + "/rpc:i";
70  m_localStreamingPortName = local + "/measures:i";
71  m_remoteRPCPortName = remote + "/rpc:o";
72  m_remoteStreamingPortName = remote + "/measures:o";
73 
74  // TODO(traversaro) : as soon as the method for checking port names validity
75  // are available in YARP ( https://github.com/robotology/yarp/pull/1508 ) add some checks
76 
77  // Open ports
78  bool ok = m_rpcPort.open(m_localRPCPortName);
79  if (!ok)
80  {
81  yCError(MULTIPLEANALOGSENSORSCLIENT,
82  "Failure to open the port %s.",
83  m_localRPCPortName.c_str());
84  close();
85  return false;
86  }
87 
88  ok = m_streamingPort.open(m_localStreamingPortName);
89  m_streamingPort.useCallback();
90  if (!ok)
91  {
92  yCError(MULTIPLEANALOGSENSORSCLIENT,
93  "Failure to open the port %s.",
94  m_localStreamingPortName.c_str());
95  close();
96  return false;
97  }
98 
99  // Connect ports
100  if (!m_externalConnection) {
101  ok = yarp::os::Network::connect(m_localRPCPortName, m_remoteRPCPortName, m_carrier);
102  if (!ok) {
103  yCError(MULTIPLEANALOGSENSORSCLIENT,
104  "Failure connecting port %s to %s.",
105  m_localRPCPortName.c_str(),
106  m_remoteRPCPortName.c_str());
107  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
108  close();
109  return false;
110  }
111  m_RPCConnectionActive = true;
112 
113  ok = yarp::os::Network::connect(m_remoteStreamingPortName, m_localStreamingPortName, m_carrier);
114  if (!ok) {
115  yCError(MULTIPLEANALOGSENSORSCLIENT,
116  "Failure connecting port %s to %s.",
117  m_remoteStreamingPortName.c_str(),
118  m_localStreamingPortName.c_str());
119  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
120  close();
121  return false;
122  }
123  m_StreamingConnectionActive = true;
124 
125  // Once the connection is active, we just the metadata only once
126  ok = m_RPCInterface.yarp().attachAsClient(m_rpcPort);
127  if (!ok) {
128  yCError(MULTIPLEANALOGSENSORSCLIENT, "Failure opening Thrift-based RPC interface.");
129  return false;
130  }
131 
132  // TODO(traversaro): there is a limitation on the thrift-generated
133  // YARP structures related to how to get connection errors during the call
134  // If this is ever solved at YARP level, we should properly handle errors
135  // here
136  m_sensorsMetadata = m_RPCInterface.getMetadata();
137 
138  }
139 
140  return true;
141 }
142 
144 {
145  if (m_StreamingConnectionActive)
146  {
147  yarp::os::Network::disconnect(m_remoteStreamingPortName, m_localStreamingPortName);
148  }
149  if (m_RPCConnectionActive)
150  {
151  yarp::os::Network::disconnect(m_localRPCPortName, m_remoteRPCPortName);
152  }
153 
154  m_streamingPort.close();
155  m_rpcPort.close();
156 
157  return true;
158 }
159 
160 size_t MultipleAnalogSensorsClient::genericGetNrOfSensors(const std::vector<SensorMetadata>& metadataVector,
161  const SensorMeasurements& measurementsVector) const
162 {
163  if (!m_externalConnection) {
164  return metadataVector.size();
165  } else {
166  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
167  m_streamingPort.updateTimeoutStatus();
168  if (m_streamingPort.status == yarp::dev::MAS_OK) {
169  return measurementsVector.measurements.size();
170  } else {
171  return 0;
172  }
173  }
174 }
175 
176 yarp::dev::MAS_status MultipleAnalogSensorsClient::genericGetStatus() const
177 {
178  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
179  m_streamingPort.updateTimeoutStatus();
180  return m_streamingPort.status;
181 }
182 
183 bool MultipleAnalogSensorsClient::genericGetName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
184  size_t sens_index, std::string& name) const
185 {
186  if (m_externalConnection) {
187  yCError(MULTIPLEANALOGSENSORSCLIENT,
188  "Missing metadata, the device has been configured with the option"
189  "externalConnection set to true.");
190  return false;
191  }
192  if (sens_index >= metadataVector.size())
193  {
194  yCError(MULTIPLEANALOGSENSORSCLIENT,
195  "No sensor of type %s with index %lu (nr of sensors: %lu).",
196  tag.c_str(),
197  sens_index,
198  metadataVector.size());
199  return false;
200  }
201 
202  name = metadataVector[sens_index].name;
203  return true;
204 }
205 
206 bool MultipleAnalogSensorsClient::genericGetFrameName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
207  size_t sens_index, std::string& frameName) const
208 {
209  if (m_externalConnection) {
210  yCError(MULTIPLEANALOGSENSORSCLIENT,
211  "Missing metadata, the device has been configured with the option"
212  "externalConnection set to true.");
213  return false;
214  }
215  if (sens_index >= metadataVector.size())
216  {
217  yCError(MULTIPLEANALOGSENSORSCLIENT,
218  "No sensor of type %s with index %lu (nr of sensors: %lu).",
219  tag.c_str(),
220  sens_index,
221  metadataVector.size());
222  return false;
223  }
224 
225  frameName = metadataVector[sens_index].frameName;
226  return true;
227 }
228 
229 bool MultipleAnalogSensorsClient::genericGetMeasure(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
230  const SensorMeasurements& measurementsVector,
231  size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
232 {
233 
234  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
235  m_streamingPort.updateTimeoutStatus();
236  if (m_streamingPort.status != yarp::dev::MAS_OK)
237  {
238  yCError(MULTIPLEANALOGSENSORSCLIENT,
239  "Sensor of type %s with index %lu has non-MAS_OK status.",
240  tag.c_str(),
241  sens_index);
242  return false;
243  }
244 
245  if (m_streamingPort.status != (sens_index >= measurementsVector.measurements.size()))
246  {
247  yCError(MULTIPLEANALOGSENSORSCLIENT,
248  "No sensor of type %s with index %lu (nr of sensors: %lu).",
249  tag.c_str(),
250  sens_index,
251  metadataVector.size());
252  return false;
253  }
254 
255  if (!m_externalConnection) {
256  assert(metadataVector.size() == measurementsVector.measurements.size());
257  }
258 
259  timestamp = measurementsVector.measurements[sens_index].timestamp;
260  out = measurementsVector.measurements[sens_index].measurement;
261 
262  return true;
263 }
264 
265 size_t MultipleAnalogSensorsClient::genericGetSize(const std::vector<SensorMetadata>& metadataVector,
266  const std::string& tag, const SensorMeasurements& measurementsVector, size_t sens_index) const
267 {
268  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
269  if (m_streamingPort.status != yarp::dev::MAS_OK)
270  {
271  yCError(MULTIPLEANALOGSENSORSCLIENT, "No data received, no information on the size of the specified sensor.");
272  return 0;
273  }
274 
275 
276  if (sens_index >= measurementsVector.measurements.size())
277  {
278  yCError(MULTIPLEANALOGSENSORSCLIENT,
279  "No sensor of type %s with index %lu (nr of sensors: %lu).",
280  tag.c_str(),
281  sens_index,
282  metadataVector.size());
283  return 0;
284  }
285 
286  return measurementsVector.measurements[sens_index].measurement.size();
287 }
288 
289 /*
290 All the sensor specific methods (excluding the IOrientationSensor and the ISkinPatches) are just
291 an instantiation of the following template (note: we avoid code generation for the sake of readability):
292 
293 {{SensorTag}} : ThreeAxisGyroscopes, ThreeAxisLinearAccelerometers, etc
294 {{SensorSingular}} : ThreeAxisGyroscope, ThreeAxisLinearAccelerometer, etc
295 
296 size_t MultipleAnalogSensorsClient::getNrOf{{SensorTag}}() const
297 {
298  return genericGetNrOfSensors(m_sensorsMetadata.{{SensorTag}});
299 }
300 
301 MAS_status MultipleAnalogSensorsClient::get{{SensorSingular}}Status(size_t sens_index) const
302 {
303  return genericGetStatus();
304 }
305 
306 bool MultipleAnalogSensorsClient::get{{SensorSingular}}Name(size_t sens_index, std::string& name) const
307 {
308  return genericGetName(m_sensorsMetadata.{{SensorTag}}, "{{SensorTag}}", sens_index, name);
309 }
310 
311 bool MultipleAnalogSensorsClient::get{{SensorSingular}}Measure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
312 {
313  return genericGetMeasure(m_sensorsMetadata.{{SensorTag}}, "{{SensorTag}}",
314  m_streamingPort.receivedData.{{SensorTag}}, sens_index, out, timestamp);
315 }
316 
317 For the sensors (EncoderArray and SkinPatch) of which the measurements can change size, we also have:
318 size_t MultipleAnalogSensorsClient::get{{SensorSingular}}Size(size_t sens_index) const
319 {
320  return genericGetSize({{SensorTag}}, sens_index, m_i{{SensorTag}}, &I{{SensorTag}}::get{{SensorTag}}Size);
321 }
322 
323 */
324 
326 {
327  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisGyroscopes,
328  m_streamingPort.receivedData.ThreeAxisGyroscopes);
329 }
330 
332 {
333  return genericGetStatus();
334 }
335 
336 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const
337 {
338  return genericGetName(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes", sens_index, name);
339 }
340 
341 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const
342 {
343  return genericGetFrameName(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes", sens_index, frameName);
344 }
345 
346 bool MultipleAnalogSensorsClient::getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
347 {
348  return genericGetMeasure(m_sensorsMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes",
349  m_streamingPort.receivedData.ThreeAxisGyroscopes, sens_index, out, timestamp);
350 }
351 
353 {
354  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisLinearAccelerometers,
356 }
357 
359 {
360  return genericGetStatus();
361 }
362 
363 bool MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const
364 {
365  return genericGetName(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers", sens_index, name);
366 }
367 
368 bool MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const
369 {
370  return genericGetFrameName(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers", sens_index, frameName);
371 }
372 
374 {
375  return genericGetMeasure(m_sensorsMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers",
376  m_streamingPort.receivedData.ThreeAxisLinearAccelerometers, sens_index, out, timestamp);
377 }
378 
380 {
381  return genericGetNrOfSensors(m_sensorsMetadata.ThreeAxisMagnetometers,
382  m_streamingPort.receivedData.ThreeAxisMagnetometers);
383 }
384 
386 {
387  return genericGetStatus();
388 }
389 
390 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerName(size_t sens_index, std::string& name) const
391 {
392  return genericGetName(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers", sens_index, name);
393 }
394 
395 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const
396 {
397  return genericGetFrameName(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers", sens_index, frameName);
398 }
399 
400 bool MultipleAnalogSensorsClient::getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
401 {
402  return genericGetMeasure(m_sensorsMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers",
403  m_streamingPort.receivedData.ThreeAxisMagnetometers, sens_index, out, timestamp);
404 }
405 
407 {
408  return genericGetNrOfSensors(m_sensorsMetadata.OrientationSensors,
409  m_streamingPort.receivedData.OrientationSensors);
410 }
411 
413 {
414  return genericGetStatus();
415 }
416 
417 bool MultipleAnalogSensorsClient::getOrientationSensorName(size_t sens_index, std::string& name) const
418 {
419  return genericGetName(m_sensorsMetadata.OrientationSensors, "OrientationSensors", sens_index, name);
420 }
421 
422 bool MultipleAnalogSensorsClient::getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const
423 {
424  return genericGetFrameName(m_sensorsMetadata.OrientationSensors, "OrientationSensors", sens_index, frameName);
425 }
426 
428 {
429  return genericGetMeasure(m_sensorsMetadata.OrientationSensors, "OrientationSensors",
430  m_streamingPort.receivedData.OrientationSensors, sens_index, out, timestamp);
431 }
432 
434 {
435  return genericGetNrOfSensors(m_sensorsMetadata.PositionSensors,
436  m_streamingPort.receivedData.PositionSensors);
437 }
438 
440 {
441  return genericGetStatus();
442 }
443 
444 bool MultipleAnalogSensorsClient::getPositionSensorName(size_t sens_index, std::string& name) const
445 {
446  return genericGetName(m_sensorsMetadata.PositionSensors, "PositionSensors", sens_index, name);
447 }
448 
449 bool MultipleAnalogSensorsClient::getPositionSensorFrameName(size_t sens_index, std::string& frameName) const
450 {
451  return genericGetFrameName(m_sensorsMetadata.PositionSensors, "PositionSensors", sens_index, frameName);
452 }
453 
454 bool MultipleAnalogSensorsClient::getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
455 {
456  return genericGetMeasure(m_sensorsMetadata.PositionSensors, "PositionSensors", m_streamingPort.receivedData.PositionSensors, sens_index, out, timestamp);
457 }
458 
460 {
461  return genericGetNrOfSensors(m_sensorsMetadata.TemperatureSensors,
462  m_streamingPort.receivedData.TemperatureSensors);
463 }
464 
466 {
467  return genericGetStatus();
468 }
469 
470 bool MultipleAnalogSensorsClient::getTemperatureSensorName(size_t sens_index, std::string& name) const
471 {
472  return genericGetName(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors", sens_index, name);
473 }
474 
475 bool MultipleAnalogSensorsClient::getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const
476 {
477  return genericGetFrameName(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors", sens_index, frameName);
478 }
479 
480 bool MultipleAnalogSensorsClient::getTemperatureSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
481 {
482  return genericGetMeasure(m_sensorsMetadata.TemperatureSensors, "TemperatureSensors",
483  m_streamingPort.receivedData.TemperatureSensors, sens_index, out, timestamp);
484 }
485 
486 bool MultipleAnalogSensorsClient::getTemperatureSensorMeasure(size_t sens_index, double& out, double& timestamp) const
487 {
488  yarp::sig::Vector dummy(1);
489  bool ok = this->getTemperatureSensorMeasure(sens_index, dummy, timestamp);
490  out = dummy[0];
491  return ok;
492 }
493 
495 {
496  return genericGetNrOfSensors(m_sensorsMetadata.SixAxisForceTorqueSensors,
497  m_streamingPort.receivedData.SixAxisForceTorqueSensors);
498 }
499 
501 {
502  return genericGetStatus();
503 }
504 
505 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorName(size_t sens_index, std::string& name) const
506 {
507  return genericGetName(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors", sens_index, name);
508 }
509 
510 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frameName) const
511 {
512  return genericGetFrameName(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors", sens_index, frameName);
513 }
514 
515 bool MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
516 {
517  return genericGetMeasure(m_sensorsMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors",
518  m_streamingPort.receivedData.SixAxisForceTorqueSensors, sens_index, out, timestamp);
519 }
520 
522 {
523  return genericGetNrOfSensors(m_sensorsMetadata.ContactLoadCellArrays,
524  m_streamingPort.receivedData.ContactLoadCellArrays);
525 }
526 
528 {
529  return genericGetStatus();
530 }
531 
532 bool MultipleAnalogSensorsClient::getContactLoadCellArrayName(size_t sens_index, std::string& name) const
533 {
534  return genericGetName(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays", sens_index, name);
535 }
536 
537 bool MultipleAnalogSensorsClient::getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
538 {
539  return genericGetMeasure(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
540  m_streamingPort.receivedData.ContactLoadCellArrays, sens_index, out, timestamp);
541 }
542 
544 {
545  return genericGetSize(m_sensorsMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
546  m_streamingPort.receivedData.ContactLoadCellArrays, sens_index);
547 }
548 
550 {
551  return genericGetNrOfSensors(m_sensorsMetadata.EncoderArrays,
552  m_streamingPort.receivedData.EncoderArrays);
553 }
554 
556 {
557  return genericGetStatus();
558 }
559 
560 bool MultipleAnalogSensorsClient::getEncoderArrayName(size_t sens_index, std::string& name) const
561 {
562  return genericGetName(m_sensorsMetadata.EncoderArrays, "EncoderArrays", sens_index, name);
563 }
564 
565 bool MultipleAnalogSensorsClient::getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
566 {
567  return genericGetMeasure(m_sensorsMetadata.EncoderArrays, "EncoderArrays",
568  m_streamingPort.receivedData.EncoderArrays, sens_index, out, timestamp);
569 }
570 
572 {
573  return genericGetSize(m_sensorsMetadata.EncoderArrays, "EncoderArrays",
574  m_streamingPort.receivedData.EncoderArrays, sens_index);
575 }
576 
578 {
579  return genericGetNrOfSensors(m_sensorsMetadata.SkinPatches,
580  m_streamingPort.receivedData.SkinPatches);
581 }
582 
584 {
585  return genericGetStatus();
586 }
587 
588 bool MultipleAnalogSensorsClient::getSkinPatchName(size_t sens_index, std::string& name) const
589 {
590  return genericGetName(m_sensorsMetadata.SkinPatches, "SkinPatches", sens_index, name);
591 }
592 
593 bool MultipleAnalogSensorsClient::getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
594 {
595  return genericGetMeasure(m_sensorsMetadata.SkinPatches, "SkinPatches",
596  m_streamingPort.receivedData.SkinPatches, sens_index, out, timestamp);
597 }
598 
599 size_t MultipleAnalogSensorsClient::getSkinPatchSize(size_t sens_index) const
600 {
601  return genericGetSize(m_sensorsMetadata.SkinPatches, "SkinPatches",
602  m_streamingPort.receivedData.SkinPatches, sens_index);
603 }
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:363
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:63
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:43
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:28
#define yCError(component,...)
Definition: LogComponent.h:213
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:76
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