YARP
Yet Another Robot Platform
MultipleAnalogSensorsClient.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 "SensorStreamingData.h"
13 
14 #include <yarp/os/LogComponent.h>
15 
16 namespace {
17 YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSCLIENT, "yarp.device.multipleanalogsensorsclient")
18 }
19 
21 {
22  std::lock_guard<std::mutex> guard(dataMutex);
23  receivedData = v;
26 }
27 
29 {
31  {
32  double now = yarp::os::Time::now();
34  {
35  yCError(MULTIPLEANALOGSENSORSCLIENT,
36  "No data received in the last %lf seconds, timeout enabled.",
39  }
40  }
41 }
42 
44 {
45  m_externalConnection = config.check("externalConnection",yarp::os::Value(false)).asBool();
46  if (!config.check("remote"))
47  {
48  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing name parameter, exiting.");
49  return false;
50  }
51 
52  if (!config.check("local"))
53  {
54  yCError(MULTIPLEANALOGSENSORSCLIENT, "Missing local parameter, exiting.");
55  return false;
56  }
57 
58  if (config.check("timeout") && !(config.find("timeout").isFloat64()))
59  {
60  yCError(MULTIPLEANALOGSENSORSCLIENT, "'timeout' parameter is present but is not double, exiting.");
61  return false;
62  }
63 
64  std::string remote = config.find("remote").asString();
65  std::string local = config.find("local").asString();
66 
67  // Optional timeout parameter
68  m_streamingPort.timeoutInSeconds = config.check("timeout", yarp::os::Value(0.01), "Timeout parameter").asFloat64();
69 
70  m_localRPCPortName = local + "/rpc:i";
71  m_localStreamingPortName = local + "/measures:i";
72  m_remoteRPCPortName = remote + "/rpc:o";
73  m_remoteStreamingPortName = remote + "/measures:o";
74 
75  // TODO(traversaro) : as soon as the method for checking port names validity
76  // are available in YARP ( https://github.com/robotology/yarp/pull/1508 ) add some checks
77 
78  // Open ports
79  bool ok = m_rpcPort.open(m_localRPCPortName);
80  if (!ok)
81  {
82  yCError(MULTIPLEANALOGSENSORSCLIENT,
83  "Failure to open the port %s.",
84  m_localRPCPortName.c_str());
85  close();
86  return false;
87  }
88 
89  ok = m_streamingPort.open(m_localStreamingPortName);
90  m_streamingPort.useCallback();
91  if (!ok)
92  {
93  yCError(MULTIPLEANALOGSENSORSCLIENT,
94  "Failure to open the port %s.",
95  m_localStreamingPortName.c_str());
96  close();
97  return false;
98  }
99 
100  // Connect ports
101  if (!m_externalConnection) {
102  ok = yarp::os::Network::connect(m_localRPCPortName, m_remoteRPCPortName);
103  if (!ok) {
104  yCError(MULTIPLEANALOGSENSORSCLIENT,
105  "Failure connecting port %s to %s.",
106  m_localRPCPortName.c_str(),
107  m_remoteRPCPortName.c_str());
108  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
109  close();
110  return false;
111  }
112  m_RPCConnectionActive = true;
113 
114  ok = yarp::os::Network::connect(m_remoteStreamingPortName, m_localStreamingPortName);
115  if (!ok) {
116  yCError(MULTIPLEANALOGSENSORSCLIENT,
117  "Failure connecting port %s to %s.",
118  m_remoteStreamingPortName.c_str(),
119  m_localStreamingPortName.c_str());
120  yCError(MULTIPLEANALOGSENSORSCLIENT, "Check that the specified MultipleAnalogSensorsServer is up.");
121  close();
122  return false;
123  }
124  m_StreamingConnectionActive = true;
125 
126  // Once the connection is active, we just the metadata only once
127  ok = m_RPCInterface.yarp().attachAsClient(m_rpcPort);
128  if (!ok) {
129  yCError(MULTIPLEANALOGSENSORSCLIENT, "Failure opening Thrift-based RPC interface.");
130  return false;
131  }
132 
133  // TODO(traversaro): there is a limitation on the thrift-generated
134  // YARP structures related to how to get connection errors during the call
135  // If this is ever solved at YARP level, we should properly handle errors
136  // here
137  m_sensorsMetadata = m_RPCInterface.getMetadata();
138 
139  }
140 
141  return true;
142 }
143 
145 {
146  if (m_StreamingConnectionActive)
147  {
148  yarp::os::Network::disconnect(m_remoteStreamingPortName, m_localStreamingPortName);
149  }
150  if (m_RPCConnectionActive)
151  {
152  yarp::os::Network::disconnect(m_localRPCPortName, m_remoteRPCPortName);
153  }
154 
155  m_streamingPort.close();
156  m_rpcPort.close();
157 
158  return true;
159 }
160 
161 size_t MultipleAnalogSensorsClient::genericGetNrOfSensors(const std::vector<SensorMetadata>& metadataVector,
162  const SensorMeasurements& measurementsVector) const
163 {
164  if (!m_externalConnection) {
165  return metadataVector.size();
166  } else {
167  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
168  m_streamingPort.updateTimeoutStatus();
169  if (m_streamingPort.status == yarp::dev::MAS_OK) {
170  return measurementsVector.measurements.size();
171  } else {
172  return 0;
173  }
174  }
175 }
176 
177 yarp::dev::MAS_status MultipleAnalogSensorsClient::genericGetStatus() const
178 {
179  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
180  m_streamingPort.updateTimeoutStatus();
181  return m_streamingPort.status;
182 }
183 
184 bool MultipleAnalogSensorsClient::genericGetName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
185  size_t sens_index, std::string& name) const
186 {
187  if (m_externalConnection) {
188  yCError(MULTIPLEANALOGSENSORSCLIENT,
189  "Missing metadata, the device has been configured with the option"
190  "externalConnection set to true.");
191  return false;
192  }
193  if (sens_index >= metadataVector.size())
194  {
195  yCError(MULTIPLEANALOGSENSORSCLIENT,
196  "No sensor of type %s with index %lu (nr of sensors: %lu).",
197  tag.c_str(),
198  sens_index,
199  metadataVector.size());
200  return false;
201  }
202 
203  name = metadataVector[sens_index].name;
204  return true;
205 }
206 
207 bool MultipleAnalogSensorsClient::genericGetFrameName(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
208  size_t sens_index, std::string& frameName) const
209 {
210  if (m_externalConnection) {
211  yCError(MULTIPLEANALOGSENSORSCLIENT,
212  "Missing metadata, the device has been configured with the option"
213  "externalConnection set to true.");
214  return false;
215  }
216  if (sens_index >= metadataVector.size())
217  {
218  yCError(MULTIPLEANALOGSENSORSCLIENT,
219  "No sensor of type %s with index %lu (nr of sensors: %lu).",
220  tag.c_str(),
221  sens_index,
222  metadataVector.size());
223  return false;
224  }
225 
226  frameName = metadataVector[sens_index].frameName;
227  return true;
228 }
229 
230 bool MultipleAnalogSensorsClient::genericGetMeasure(const std::vector<SensorMetadata>& metadataVector, const std::string& tag,
231  const SensorMeasurements& measurementsVector,
232  size_t sens_index, yarp::sig::Vector& out, double& timestamp) const
233 {
234 
235  std::lock_guard<std::mutex> guard(m_streamingPort.dataMutex);
236  m_streamingPort.updateTimeoutStatus();
237  if (m_streamingPort.status != yarp::dev::MAS_OK)
238  {
239  yCError(MULTIPLEANALOGSENSORSCLIENT,
240  "Sensor of type %s with index %lu has non-MAS_OK status.",
241  tag.c_str(),
242  sens_index);
243  return false;
244  }
245 
246  if (m_streamingPort.status != (sens_index >= measurementsVector.measurements.size()))
247  {
248  yCError(MULTIPLEANALOGSENSORSCLIENT,
249  "No sensor of type %s with index %lu (nr of sensors: %lu).",
250  tag.c_str(),
251  sens_index,
252  metadataVector.size());
253  return false;
254  }
255 
256  if (!m_externalConnection)
257  assert(metadataVector.size() == measurementsVector.measurements.size());
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::os::Port::close
void close() override
Stop port activity.
Definition: Port.cpp:357
SensorRPCData::TemperatureSensors
std::vector< SensorMetadata > TemperatureSensors
Definition: SensorRPCData.h:30
MultipleAnalogSensorsClient::getPositionSensorFrameName
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:449
SensorStreamingDataInputPort::status
yarp::dev::MAS_status status
Definition: MultipleAnalogSensorsClient.h:29
SensorMeasurements::measurements
std::vector< SensorMeasurement > measurements
Definition: SensorMeasurements.h:26
SensorStreamingDataInputPort::onRead
void onRead(SensorStreamingData &v) override
Definition: MultipleAnalogSensorsClient.cpp:20
MultipleAnalogSensorsClient::getPositionSensorName
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:444
MultipleAnalogSensorsClient::getSkinPatchSize
size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch.
Definition: MultipleAnalogSensorsClient.cpp:599
SensorRPCData::ThreeAxisGyroscopes
std::vector< SensorMetadata > ThreeAxisGyroscopes
Definition: SensorRPCData.h:26
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
MultipleAnalogSensorsClient::getContactLoadCellArrayMeasure
bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:537
MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerName
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:363
MultipleAnalogSensorsClient.h
MultipleAnalogSensorsClient::getTemperatureSensorMeasure
bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:486
SensorStreamingData::TemperatureSensors
SensorMeasurements TemperatureSensors
Definition: SensorStreamingData.h:30
MultipleAnalogSensorsClient::getSkinPatchName
bool getSkinPatchName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:588
MultipleAnalogSensorsClient::getEncoderArrayStatus
yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:555
SensorRPCData::SkinPatches
std::vector< SensorMetadata > SkinPatches
Definition: SensorRPCData.h:34
SensorStreamingData::SixAxisForceTorqueSensors
SensorMeasurements SixAxisForceTorqueSensors
Definition: SensorStreamingData.h:31
MultipleAnalogSensorsClient::getOrientationSensorFrameName
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:422
SensorRPCData::SixAxisForceTorqueSensors
std::vector< SensorMetadata > SixAxisForceTorqueSensors
Definition: SensorRPCData.h:31
MultipleAnalogSensorsClient::getThreeAxisMagnetometerFrameName
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:395
SensorRPCData::PositionSensors
std::vector< SensorMetadata > PositionSensors
Definition: SensorRPCData.h:35
MultipleAnalogSensorsClient::getSkinPatchMeasure
bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:593
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
MultipleAnalogSensorsClient::getThreeAxisGyroscopeStatus
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:331
MultipleAnalogSensorsClient::getContactLoadCellArraySize
size_t getContactLoadCellArraySize(size_t sens_index) const override
Get the size of the specified contact load cell array.
Definition: MultipleAnalogSensorsClient.cpp:543
MultipleAnalogSensorsClient::getTemperatureSensorStatus
yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:465
yarp::os::BufferedPort::useCallback
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
Definition: BufferedPort-inl.h:211
SensorRPCData::ThreeAxisMagnetometers
std::vector< SensorMetadata > ThreeAxisMagnetometers
Definition: SensorRPCData.h:28
MultipleAnalogSensorsClient::getEncoderArrayName
bool getEncoderArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:560
MultipleAnalogSensorsClient::getNrOfTemperatureSensors
size_t getNrOfTemperatureSensors() const override
Get the number of temperature sensors exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:459
yarp::os::Port::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:82
MultipleAnalogSensorsClient::close
bool close() override
Close the DeviceDriver.
Definition: MultipleAnalogSensorsClient.cpp:144
SensorStreamingDataInputPort::lastTimeStampReadInSeconds
double lastTimeStampReadInSeconds
Definition: MultipleAnalogSensorsClient.h:32
MultipleAnalogSensorsClient::getPositionSensorStatus
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:439
MultipleAnalogSensorsClient::getThreeAxisGyroscopeFrameName
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:341
yarp::os::Time::now
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerStatus
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:358
MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerMeasure
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:373
yarp::sig::VectorOf
Provides:
Definition: Vector.h:122
MultipleAnalogSensorsClient::getTemperatureSensorFrameName
bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:475
MultipleAnalogSensorsMetadata::getMetadata
virtual SensorRPCData getMetadata()
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
Definition: MultipleAnalogSensorsMetadata.cpp:66
SensorStreamingData::ThreeAxisGyroscopes
SensorMeasurements ThreeAxisGyroscopes
Definition: SensorStreamingData.h:26
SensorStreamingDataInputPort::updateTimeoutStatus
void updateTimeoutStatus() const
Definition: MultipleAnalogSensorsClient.cpp:28
MultipleAnalogSensorsClient::getThreeAxisGyroscopeName
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:336
MultipleAnalogSensorsClient::getContactLoadCellArrayName
bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:532
SensorStreamingDataInputPort::receivedData
SensorStreamingData receivedData
Definition: MultipleAnalogSensorsClient.h:28
SensorMeasurements
Definition: SensorMeasurements.h:23
MultipleAnalogSensorsClient::getNrOfPositionSensors
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:433
yarp::os::Value::isFloat64
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
Definition: Value.cpp:153
SensorStreamingData::EncoderArrays
SensorMeasurements EncoderArrays
Definition: SensorStreamingData.h:33
SensorStreamingData::ThreeAxisLinearAccelerometers
SensorMeasurements ThreeAxisLinearAccelerometers
Definition: SensorStreamingData.h:27
MultipleAnalogSensorsClient::getThreeAxisGyroscopeMeasure
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
Definition: MultipleAnalogSensorsClient.cpp:346
MultipleAnalogSensorsClient::getThreeAxisMagnetometerStatus
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:385
SensorStreamingData::ContactLoadCellArrays
SensorMeasurements ContactLoadCellArrays
Definition: SensorStreamingData.h:32
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::os::NetworkBase::connect
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:685
MultipleAnalogSensorsClient::getNrOfContactLoadCellArrays
size_t getNrOfContactLoadCellArrays() const override
Get the number of contact load cell array exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:521
MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorName
bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:505
MultipleAnalogSensorsClient::getThreeAxisMagnetometerName
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:390
yarp::os::BufferedPort::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: BufferedPort-inl.h:41
MultipleAnalogSensorsClient::getNrOfThreeAxisGyroscopes
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
Definition: MultipleAnalogSensorsClient.cpp:325
yarp::os::Searchable::check
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
yarp::os::Searchable::find
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
MultipleAnalogSensorsClient::getContactLoadCellArrayStatus
yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:527
MultipleAnalogSensorsClient::getNrOfThreeAxisMagnetometers
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:379
MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorFrameName
bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:510
MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorStatus
yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:500
LogComponent.h
SensorStreamingData::OrientationSensors
SensorMeasurements OrientationSensors
Definition: SensorStreamingData.h:29
SensorRPCData::ContactLoadCellArrays
std::vector< SensorMetadata > ContactLoadCellArrays
Definition: SensorRPCData.h:32
SensorStreamingData.h
MultipleAnalogSensorsClient::getSkinPatchStatus
yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:583
MultipleAnalogSensorsClient::getSixAxisForceTorqueSensorMeasure
bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:515
MultipleAnalogSensorsClient::getNrOfEncoderArrays
size_t getNrOfEncoderArrays() const override
Get the number of encoder arrays exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:549
yarp::os::Wire::yarp
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition: Wire.h:34
yCError
#define yCError(component,...)
Definition: LogComponent.h:157
SensorStreamingDataInputPort::timeoutInSeconds
double timeoutInSeconds
Definition: MultipleAnalogSensorsClient.h:31
SensorRPCData::OrientationSensors
std::vector< SensorMetadata > OrientationSensors
Definition: SensorRPCData.h:29
SensorStreamingDataInputPort::dataMutex
std::mutex dataMutex
Definition: MultipleAnalogSensorsClient.h:30
MultipleAnalogSensorsClient::getNrOfSkinPatches
size_t getNrOfSkinPatches() const override
Get the number of skin patches exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:577
SensorStreamingData::PositionSensors
SensorMeasurements PositionSensors
Definition: SensorStreamingData.h:35
SensorStreamingData::ThreeAxisMagnetometers
SensorMeasurements ThreeAxisMagnetometers
Definition: SensorStreamingData.h:28
MultipleAnalogSensorsMetadata.h
MultipleAnalogSensorsClient::getThreeAxisLinearAccelerometerFrameName
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:368
SensorStreamingData
Definition: SensorStreamingData.h:23
yarp::dev::MAS_status
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
Definition: MultipleAnalogSensorsInterfaces.h:37
MultipleAnalogSensorsClient::getEncoderArraySize
size_t getEncoderArraySize(size_t sens_index) const override
Get the size of the specified encoder array.
Definition: MultipleAnalogSensorsClient.cpp:571
MultipleAnalogSensorsClient::getThreeAxisMagnetometerMeasure
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:400
yarp::os::BufferedPort::close
void close() override
Stop port activity.
Definition: BufferedPort-inl.h:73
MultipleAnalogSensorsClient::getNrOfThreeAxisLinearAccelerometers
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:352
yarp::dev::MAS_TIMEOUT
@ MAS_TIMEOUT
The sensor is read through the network, and the latest measurement was received before an implementat...
Definition: MultipleAnalogSensorsInterfaces.h:41
SensorRPCData::ThreeAxisLinearAccelerometers
std::vector< SensorMetadata > ThreeAxisLinearAccelerometers
Definition: SensorRPCData.h:27
MultipleAnalogSensorsClient::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: MultipleAnalogSensorsClient.cpp:427
MultipleAnalogSensorsClient::getNrOfSixAxisForceTorqueSensors
size_t getNrOfSixAxisForceTorqueSensors() const override
Get the number of six axis force torque sensors exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:494
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
MultipleAnalogSensorsClient::getOrientationSensorStatus
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:412
MultipleAnalogSensorsClient::getOrientationSensorName
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:417
SensorRPCData::EncoderArrays
std::vector< SensorMetadata > EncoderArrays
Definition: SensorRPCData.h:33
MultipleAnalogSensorsClient::getEncoderArrayMeasure
bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:565
MultipleAnalogSensorsClient::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: MultipleAnalogSensorsClient.cpp:43
MultipleAnalogSensorsClient::getNrOfOrientationSensors
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
Definition: MultipleAnalogSensorsClient.cpp:406
MultipleAnalogSensorsClient::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: MultipleAnalogSensorsClient.cpp:454
yarp::dev::MAS_OK
@ MAS_OK
The sensor is working correctly.
Definition: MultipleAnalogSensorsInterfaces.h:38
MultipleAnalogSensorsClient::getTemperatureSensorName
bool getTemperatureSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: MultipleAnalogSensorsClient.cpp:470
SensorStreamingData::SkinPatches
SensorMeasurements SkinPatches
Definition: SensorStreamingData.h:34
yarp::os::NetworkBase::disconnect
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:703