YARP
Yet Another Robot Platform
MultipleAnalogSensorsServer.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 
9 #include "SensorStreamingData.h"
11 
13 
14 #include <yarp/os/Log.h>
15 #include <yarp/os/LogComponent.h>
16 #include <yarp/os/Property.h>
18 
19 
20 namespace {
21 YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSSERVER, "yarp.device.multipleanalogsensorsserver")
22 }
23 
25  PeriodicThread(0.02)
26 {
27 }
28 
30 
32 {
33  if (!config.check("name"))
34  {
35  yCError(MULTIPLEANALOGSENSORSSERVER, "Missing name parameter, exiting.");
36  return false;
37  }
38 
39  if (!config.check("period"))
40  {
41  yCError(MULTIPLEANALOGSENSORSSERVER, "Missing period parameter, exiting.");
42  return false;
43  }
44 
45  if (!config.find("period").isInt32())
46  {
47  yCError(MULTIPLEANALOGSENSORSSERVER, "Period parameter is present but it is not an integer, exiting.");
48  return false;
49  }
50 
51  m_periodInS = config.find("period").asInt32() / 1000.0;
52 
53  if (m_periodInS <= 0)
54  {
55  yCError(MULTIPLEANALOGSENSORSSERVER,
56  "Period parameter is present (%f) but it is not a positive integer, exiting.",
57  m_periodInS);
58  return false;
59  }
60 
61  std::string name = config.find("name").asString();
62 
63  // Reserve a fair amount of elements
64  // It would be great if yarp::sig::Vector had a reserve method
65  m_buffer.resize(100);
66  m_buffer.resize(0);
67 
68  // TODO(traversaro) Add port name validation when ready,
69  // see https://github.com/robotology/yarp/pull/1508
70  m_RPCPortName = name + "/rpc:o";
71  m_streamingPortName = name + "/measures:o";
72 
73  if (config.check("subdevice"))
74  {
75  std::string subdeviceName = config.find("subdevice").asString();
76 
77  yarp::os::Property driverConfig;
78  driverConfig.fromString(config.toString());
79  driverConfig.setMonitor(config.getMonitor(), subdeviceName.c_str()); // pass on any monitoring
80  driverConfig.put("device", subdeviceName);
81 
82  if (!m_subdevice.open(driverConfig))
83  {
84  yCError(MULTIPLEANALOGSENSORSSERVER, "Opening subdevice failed.");
85  return false;
86  }
87 
88  yarp::dev::PolyDriverList driverList;
89  driverList.push(&m_subdevice, subdeviceName.c_str());
90 
91  if (!attachAll(driverList))
92  {
93  yCError(MULTIPLEANALOGSENSORSSERVER, "Attaching subdevice failed.");
94  return false;
95  }
96 
97  yCInfo(MULTIPLEANALOGSENSORSSERVER,
98  "Subdevice \"%s\" successfully configured and attached.",
99  subdeviceName.c_str());
100  m_isDeviceOwned = true;
101  }
102 
103  return true;
104 }
105 
107 {
108  bool ok = this->detachAll();
109 
110  if (m_isDeviceOwned)
111  {
112  ok &= m_subdevice.close();
113  m_isDeviceOwned = false;
114  }
115 
116  return ok;
117 }
118 
119 // Note: as soon as we support only C++17, we can switch to using std::invoke
120 // See https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
121 #define MAS_CALL_MEMBER_FN(object, ptrToMember) ((*object).*(ptrToMember))
122 
123 template<typename Interface>
124 bool MultipleAnalogSensorsServer::populateSensorsMetadata(Interface * wrappedDeviceInterface,
125  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
126  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
127  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
128  bool (Interface::*getFrameNameMethodPtr)(size_t, std::string&) const)
129 {
130  if (wrappedDeviceInterface)
131  {
132  size_t nrOfSensors = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)();
133  metadataVector.resize(nrOfSensors);
134  for (size_t i=0; i < nrOfSensors; i++)
135  {
136  std::string sensorName;
137  bool ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
138  if (!ok)
139  {
140  yCError(MULTIPLEANALOGSENSORSSERVER,
141  "Failure in reading name of sensor of type %s at index %zu.",
142  tag.c_str(),
143  i);
144  return false;
145  }
146  std::string frameName;
147  ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getFrameNameMethodPtr)(i, frameName);
148  if (!ok)
149  {
150  yCError(MULTIPLEANALOGSENSORSSERVER,
151  "Failure in reading frame name of sensor of type %s at index %zu.",
152  tag.c_str(),
153  i);
154  return false;
155  }
156 
157  metadataVector[i].name = sensorName;
158  metadataVector[i].frameName = frameName;
159  metadataVector[i].additionalMetadata = "";
160  }
161 
162  }
163  else
164  {
165  metadataVector.resize(0);
166  }
167  return true;
168 }
169 
170 template<typename Interface>
171 bool MultipleAnalogSensorsServer::populateSensorsMetadataNoFrameName(Interface * wrappedDeviceInterface,
172  std::vector<SensorMetadata>& metadataVector, const std::string& tag,
173  size_t (Interface::*getNrOfSensorsMethodPtr)() const,
174  bool (Interface::*getNameMethodPtr)(size_t, std::string&) const)
175 {
176  if (wrappedDeviceInterface)
177  {
178  size_t nrOfSensors = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)();
179  metadataVector.resize(nrOfSensors);
180  for (size_t i=0; i < nrOfSensors; i++)
181  {
182  std::string sensorName;
183  bool ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
184  if (!ok)
185  {
186  yCError(MULTIPLEANALOGSENSORSSERVER,
187  "Failure in reading name of sensor of type %s at index %zu.",
188  tag.c_str(),
189  i);
190  return false;
191  }
192 
193  metadataVector[i].name = sensorName;
194  metadataVector[i].frameName = "";
195  metadataVector[i].additionalMetadata = "";
196  }
197 
198  }
199  else
200  {
201  metadataVector.resize(0);
202  }
203  return true;
204 }
205 
206 
207 bool MultipleAnalogSensorsServer::populateAllSensorsMetadata()
208 {
209  bool ok = true;
210  ok = ok && populateSensorsMetadata(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes",
214  ok = ok && populateSensorsMetadata(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers",
218  ok = ok && populateSensorsMetadata(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers",
222  ok = ok && populateSensorsMetadata(m_iPositionSensors, m_sensorMetadata.PositionSensors, "PositionSensors",
226  ok = ok && populateSensorsMetadata(m_iOrientationSensors, m_sensorMetadata.OrientationSensors, "OrientationSensors",
230  ok = ok && populateSensorsMetadata(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors, "TemperatureSensors",
234  ok = ok && populateSensorsMetadata(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors",
238  ok = ok && populateSensorsMetadataNoFrameName(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
241  ok = ok && populateSensorsMetadataNoFrameName(m_iEncoderArrays, m_sensorMetadata.EncoderArrays, "EncoderArrays",
244  ok = ok && populateSensorsMetadataNoFrameName(m_iSkinPatches, m_sensorMetadata.SkinPatches, "ISkinPatches",
247 
248  return ok;
249 }
250 
252 {
253  // Attach the device
254  if (p.size() > 1)
255  {
256  yCError(MULTIPLEANALOGSENSORSSERVER,
257  "This device only supports exposing a "
258  "single MultipleAnalogSensors device on YARP ports, but %d devices have been passed in attachAll.",
259  p.size());
260  yCError(MULTIPLEANALOGSENSORSSERVER,
261  "Please use the multipleanalogsensorsremapper device to combine several device in a new device.");
262  close();
263  return false;
264  }
265 
266  if (p.size() == 0)
267  {
268  yCError(MULTIPLEANALOGSENSORSSERVER, "No device passed to attachAll, please pass a device to expose on YARP ports.");
269  close();
270  return false;
271  }
272 
273  yarp::dev::PolyDriver* poly = p[0]->poly;
274 
275  if (!poly)
276  {
277  yCError(MULTIPLEANALOGSENSORSSERVER, "Null pointer passed to attachAll.");
278  close();
279  return false;
280  }
281 
282  // View all the interfaces
283  poly->view(m_iThreeAxisGyroscopes);
284  poly->view(m_iThreeAxisLinearAccelerometers);
285  poly->view(m_iThreeAxisMagnetometers);
286  poly->view(m_iPositionSensors);
287  poly->view(m_iOrientationSensors);
288  poly->view(m_iTemperatureSensors);
289  poly->view(m_iSixAxisForceTorqueSensors);
290  poly->view(m_iContactLoadCellArrays);
291  poly->view(m_iEncoderArrays);
292  poly->view(m_iSkinPatches);
293 
294 
295  // Populate the RPC data to be served on the RPC port
296  bool ok = populateAllSensorsMetadata();
297 
298  if(!ok)
299  {
300  close();
301  return false;
302  }
303 
304  // Attach was successful, open the ports
305  ok = m_streamingPort.open(m_streamingPortName);
306  if (!ok)
307  {
308  yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_streamingPortName.c_str());
309  close();
310  return false;
311  }
312 
313  ok = this->yarp().attachAsServer(m_rpcPort);
314  if (!ok)
315  {
316  yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in attaching RPC port to thrift RPC interface.");
317  close();
318  return false;
319  }
320 
321  ok = m_rpcPort.open(m_RPCPortName);
322  if (!ok)
323  {
324  yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_RPCPortName.c_str());
325  close();
326  return false;
327  }
328 
329  // Set rate period
330  ok = this->setPeriod(m_periodInS);
331  ok = ok && this->start();
332  if (!ok)
333  {
334  yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in starting thread.");
335  close();
336  return false;
337  }
338 
339  return true;
340 }
341 
343 {
344  // Stop the thread on detach
345  if (this->isRunning())
346  {
347  this->stop();
348  }
349 
350  m_rpcPort.close();
351  m_streamingPort.close();
352 
353  return true;
354 }
355 
357 {
358  return m_sensorMetadata;
359 }
360 
361 template<typename Interface>
362 bool MultipleAnalogSensorsServer::genericStreamData(Interface* wrappedDeviceInterface,
363  const std::vector< SensorMetadata >& metadataVector,
364  std::vector< SensorMeasurement >& streamingDataVector,
365  yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
366  bool (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const)
367 {
368  if (wrappedDeviceInterface)
369  {
370  size_t nrOfSensors = metadataVector.size();
371  streamingDataVector.resize(nrOfSensors);
372  for (size_t i=0; i < nrOfSensors; i++)
373  {
374  yarp::sig::Vector& outputBuffer = streamingDataVector[i].measurement;
375  double& outputTimestamp = streamingDataVector[i].timestamp;
376  // TODO(traversaro): resize the buffer to the correct size
377  MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getMeasureMethodPtr)(i, outputBuffer, outputTimestamp);
378  yarp::dev::MAS_status status = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getStatusMethodPtr)(i);
379  if (status != yarp::dev::MAS_OK)
380  {
381  yCError(MULTIPLEANALOGSENSORSSERVER,
382  "Failure in reading data from sensor %s, no data will be sent on the port.",
383  m_sensorMetadata.ThreeAxisGyroscopes[i].name.c_str());
384  return false;
385  }
386  }
387  }
388 
389  return true;
390 }
391 
392 
394 {
395  SensorStreamingData& streamingData = m_streamingPort.prepare();
396 
397  bool ok = true;
398 
399  ok = ok && genericStreamData(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes,
400  streamingData.ThreeAxisGyroscopes.measurements,
403 
404  ok = ok && genericStreamData(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers,
408 
409  ok = ok && genericStreamData(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers,
410  streamingData.ThreeAxisMagnetometers.measurements,
413 
414  ok = ok && genericStreamData(m_iPositionSensors, m_sensorMetadata.PositionSensors,
415  streamingData.PositionSensors.measurements,
418 
419  ok = ok && genericStreamData(m_iOrientationSensors, m_sensorMetadata.OrientationSensors,
420  streamingData.OrientationSensors.measurements,
423 
424  ok = ok && genericStreamData(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors,
425  streamingData.TemperatureSensors.measurements,
428 
429  ok = ok && genericStreamData(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors,
433 
434  ok = ok && genericStreamData(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays,
435  streamingData.ContactLoadCellArrays.measurements,
438 
439  ok = ok && genericStreamData(m_iEncoderArrays, m_sensorMetadata.EncoderArrays,
440  streamingData.EncoderArrays.measurements,
443 
444  ok = ok && genericStreamData(m_iSkinPatches, m_sensorMetadata.SkinPatches,
445  streamingData.SkinPatches.measurements,
448 
449  if (ok)
450  {
451  m_stamp.update();
452  m_streamingPort.setEnvelope(m_stamp);
453  m_streamingPort.write();
454  }
455  else
456  {
457  m_streamingPort.unprepare();
458  }
459 }
460 
462 {
463  return;
464 }
yarp::os::Port::close
void close() override
Stop port activity.
Definition: Port.cpp:357
SensorRPCData::TemperatureSensors
std::vector< SensorMetadata > TemperatureSensors
Definition: SensorRPCData.h:30
yarp::dev::IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerFrameName
virtual bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::dev::ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorStatus
virtual yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::dev::ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorName
virtual bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
SensorMeasurements::measurements
std::vector< SensorMeasurement > measurements
Definition: SensorMeasurements.h:26
yarp::os::Property::put
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition: Property.cpp:998
yarp::sig::VectorOf::resize
void resize(size_t size) override
Resize the vector.
Definition: Vector.h:254
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
SensorRPCData
Definition: SensorRPCData.h:23
yarp::dev::ISkinPatches::getSkinPatchStatus
virtual yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const =0
Get the status of the specified sensor.
SensorStreamingData::TemperatureSensors
SensorMeasurements TemperatureSensors
Definition: SensorStreamingData.h:30
yarp::dev::IThreeAxisGyroscopes::getThreeAxisGyroscopeMeasure
virtual bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the gyroscope.
SensorRPCData::SkinPatches
std::vector< SensorMetadata > SkinPatches
Definition: SensorRPCData.h:34
SensorStreamingData::SixAxisForceTorqueSensors
SensorMeasurements SixAxisForceTorqueSensors
Definition: SensorStreamingData.h:31
SensorRPCData::SixAxisForceTorqueSensors
std::vector< SensorMetadata > SixAxisForceTorqueSensors
Definition: SensorRPCData.h:31
SensorRPCData::PositionSensors
std::vector< SensorMetadata > PositionSensors
Definition: SensorRPCData.h:35
yarp::os::Searchable::toString
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
yarp::os::Property::fromString
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
yarp::dev::PolyDriverList::size
int size() const
Definition: PolyDriverList.cpp:39
yarp::dev::ISkinPatches::getSkinPatchMeasure
virtual bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
MAS_CALL_MEMBER_FN
#define MAS_CALL_MEMBER_FN(object, ptrToMember)
Definition: MultipleAnalogSensorsServer.cpp:121
MultipleAnalogSensorsServer::~MultipleAnalogSensorsServer
~MultipleAnalogSensorsServer()
YARP_LOG_COMPONENT
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
yarp::dev::IPositionSensors::getPositionSensorFrameName
virtual bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::os::BufferedPort::setEnvelope
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
Definition: BufferedPort-inl.h:232
SensorRPCData::ThreeAxisMagnetometers
std::vector< SensorMetadata > ThreeAxisMagnetometers
Definition: SensorRPCData.h:28
yarp::dev::DeviceDriver::view
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
yarp::dev::IThreeAxisGyroscopes::getThreeAxisGyroscopeName
virtual bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
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
yarp::dev::PolyDriverList
Definition: PolyDriverList.h:22
yarp::dev::IEncoderArrays::getNrOfEncoderArrays
virtual size_t getNrOfEncoderArrays() const =0
Get the number of encoder arrays exposed by this device.
yarp::dev::IThreeAxisMagnetometers::getNrOfThreeAxisMagnetometers
virtual size_t getNrOfThreeAxisMagnetometers() const =0
Get the number of magnetometers exposed by this device.
yarp::dev::PolyDriver::open
bool open(const std::string &txt)
Construct and configure a device by its common name.
Definition: PolyDriver.cpp:143
yarp::os::PeriodicThread::isRunning
bool isRunning() const
Returns true when the thread is started, false otherwise.
Definition: PeriodicThread.cpp:316
yarp::dev::IContactLoadCellArrays::getContactLoadCellArrayStatus
virtual yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const =0
Get the status of the specified sensor.
PolyDriverList.h
yarp::dev::IEncoderArrays::getEncoderArrayName
virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
MultipleAnalogSensorsServer::detachAll
bool detachAll() override
Detach the object (you must have first called attach).
Definition: MultipleAnalogSensorsServer.cpp:342
yarp::dev::PolyDriverList::push
void push(PolyDriver *p, const char *k)
Definition: PolyDriverList.cpp:44
MultipleAnalogSensorsServer::threadRelease
void threadRelease() override
Release method.
Definition: MultipleAnalogSensorsServer.cpp:461
yarp::dev::IPositionSensors::getPositionSensorMeasure
virtual bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const =0
Get the last reading of the position sensor as x y z.
yarp::os::BufferedPort::prepare
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
Definition: BufferedPort-inl.h:114
yarp::sig::VectorOf
Provides:
Definition: Vector.h:122
Log.h
SensorStreamingData::ThreeAxisGyroscopes
SensorMeasurements ThreeAxisGyroscopes
Definition: SensorStreamingData.h:26
yarp::dev::IPositionSensors::getPositionSensorStatus
virtual yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::dev::IOrientationSensors::getOrientationSensorFrameName
virtual bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::dev::ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorMeasure
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
MultipleAnalogSensorsServer::open
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
Definition: MultipleAnalogSensorsServer.cpp:31
Property.h
SensorStreamingData::EncoderArrays
SensorMeasurements EncoderArrays
Definition: SensorStreamingData.h:33
SensorStreamingData::ThreeAxisLinearAccelerometers
SensorMeasurements ThreeAxisLinearAccelerometers
Definition: SensorStreamingData.h:27
SensorStreamingData::ContactLoadCellArrays
SensorMeasurements ContactLoadCellArrays
Definition: SensorStreamingData.h:32
yarp::dev::ITemperatureSensors::getTemperatureSensorMeasure
virtual bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const =0
Get the last reading of the specified sensor.
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
MultipleAnalogSensorsServer::getMetadata
SensorRPCData getMetadata() override
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
Definition: MultipleAnalogSensorsServer.cpp:356
yarp::os::PeriodicThread::start
bool start()
Call this to start the thread.
Definition: PeriodicThread.cpp:311
yarp::dev::PolyDriver
A container for a device driver.
Definition: PolyDriver.h:27
yarp::dev::ITemperatureSensors::getNrOfTemperatureSensors
virtual size_t getNrOfTemperatureSensors() const =0
Get the number of temperature sensors exposed by this device.
yarp::dev::PolyDriver::close
bool close() override
Close the DeviceDriver.
Definition: PolyDriver.cpp:176
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
yarp::dev::IContactLoadCellArrays::getContactLoadCellArrayName
virtual bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
yarp::dev::IThreeAxisMagnetometers::getThreeAxisMagnetometerStatus
virtual yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
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::PeriodicThread::setPeriod
bool setPeriod(double period)
Set the (new) period of the thread.
Definition: PeriodicThread.cpp:281
yarp::os::Searchable::find
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
yarp::dev::IOrientationSensors::getOrientationSensorName
virtual bool getOrientationSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
MultipleAnalogSensorsServer.h
MultipleAnalogSensorsServer::close
bool close() override
Close the DeviceDriver.
Definition: MultipleAnalogSensorsServer.cpp:106
yarp::dev::IThreeAxisMagnetometers::getThreeAxisMagnetometerName
virtual bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
yarp::dev::IPositionSensors::getNrOfPositionSensors
virtual size_t getNrOfPositionSensors() const =0
Get the number of position sensors exposed by this device.
yarp::dev::IContactLoadCellArrays::getNrOfContactLoadCellArrays
virtual size_t getNrOfContactLoadCellArrays() const =0
Get the number of contact load cell array exposed by this device.
LogComponent.h
SensorStreamingData::OrientationSensors
SensorMeasurements OrientationSensors
Definition: SensorStreamingData.h:29
SensorRPCData::ContactLoadCellArrays
std::vector< SensorMetadata > ContactLoadCellArrays
Definition: SensorRPCData.h:32
SensorStreamingData.h
yarp::dev::IThreeAxisMagnetometers::getThreeAxisMagnetometerMeasure
virtual bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
yarp::dev::IThreeAxisGyroscopes::getThreeAxisGyroscopeStatus
virtual yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::dev::IOrientationSensors::getOrientationSensorMeasureAsRollPitchYaw
virtual bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double &timestamp) const =0
Get the last reading of the orientation sensor as roll pitch yaw.
yarp::dev::ISkinPatches::getSkinPatchName
virtual bool getSkinPatchName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
MultipleAnalogSensorsServer::attachAll
bool attachAll(const yarp::dev::PolyDriverList &p) override
Attach to a list of objects.
Definition: MultipleAnalogSensorsServer.cpp:251
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
MultipleAnalogSensorsServer::run
void run() override
Loop function.
Definition: MultipleAnalogSensorsServer.cpp:393
yarp::os::Value::asInt32
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:207
yarp::dev::ITemperatureSensors::getTemperatureSensorStatus
virtual yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::os::Stamp::update
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
Definition: Stamp.cpp:113
yarp::os::BufferedPort::write
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
Definition: BufferedPort-inl.h:126
SensorRPCData::OrientationSensors
std::vector< SensorMetadata > OrientationSensors
Definition: SensorRPCData.h:29
yCInfo
#define yCInfo(component,...)
Definition: LogComponent.h:135
SensorStreamingData::PositionSensors
SensorMeasurements PositionSensors
Definition: SensorStreamingData.h:35
yarp::dev::ISixAxisForceTorqueSensors::getSixAxisForceTorqueSensorFrameName
virtual bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::dev::IThreeAxisGyroscopes::getThreeAxisGyroscopeFrameName
virtual bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
MultipleAnalogSensorsServer::MultipleAnalogSensorsServer
MultipleAnalogSensorsServer()
Definition: MultipleAnalogSensorsServer.cpp:24
SensorStreamingData::ThreeAxisMagnetometers
SensorMeasurements ThreeAxisMagnetometers
Definition: SensorStreamingData.h:28
MultipleAnalogSensorsMetadata.h
yarp::os::BufferedPort::unprepare
bool unprepare()
Give the last prepared object back to YARP without writing it.
Definition: BufferedPort-inl.h:120
yarp::dev::ISixAxisForceTorqueSensors::getNrOfSixAxisForceTorqueSensors
virtual size_t getNrOfSixAxisForceTorqueSensors() const =0
Get the number of six axis force torque sensors exposed by this device.
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
yarp::os::BufferedPort::close
void close() override
Stop port activity.
Definition: BufferedPort-inl.h:73
yarp::dev::IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerStatus
virtual yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::os::PeriodicThread::stop
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
Definition: PeriodicThread.cpp:296
yarp::dev::IOrientationSensors::getNrOfOrientationSensors
virtual size_t getNrOfOrientationSensors() const =0
Get the number of orientation sensors exposed by this device.
SensorRPCData::ThreeAxisLinearAccelerometers
std::vector< SensorMetadata > ThreeAxisLinearAccelerometers
Definition: SensorRPCData.h:27
yarp::dev::IThreeAxisGyroscopes::getNrOfThreeAxisGyroscopes
virtual size_t getNrOfThreeAxisGyroscopes() const =0
Get the number of three axis gyroscopes exposed by this sensor.
yarp::dev::IEncoderArrays::getEncoderArrayStatus
virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::dev::ITemperatureSensors::getTemperatureSensorName
virtual bool getTemperatureSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
yarp::dev::IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerName
virtual bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
yarp::dev::IOrientationSensors::getOrientationSensorStatus
virtual yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
yarp::dev::ISkinPatches::getNrOfSkinPatches
virtual size_t getNrOfSkinPatches() const =0
Get the number of skin patches exposed by this device.
yarp::dev::IContactLoadCellArrays::getContactLoadCellArrayMeasure
virtual bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
yarp::dev::IThreeAxisLinearAccelerometers::getThreeAxisLinearAccelerometerMeasure
virtual bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
yarp::dev::IPositionSensors::getPositionSensorName
virtual bool getPositionSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
yarp::dev::ITemperatureSensors::getTemperatureSensorFrameName
virtual bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::dev::IEncoderArrays::getEncoderArrayMeasure
virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
SensorRPCData::EncoderArrays
std::vector< SensorMetadata > EncoderArrays
Definition: SensorRPCData.h:33
yarp::dev::IThreeAxisLinearAccelerometers::getNrOfThreeAxisLinearAccelerometers
virtual size_t getNrOfThreeAxisLinearAccelerometers() const =0
Get the number of three axis linear accelerometers exposed by this device.
yarp::dev::IThreeAxisMagnetometers::getThreeAxisMagnetometerFrameName
virtual bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::dev::MAS_OK
@ MAS_OK
The sensor is working correctly.
Definition: MultipleAnalogSensorsInterfaces.h:38
SensorStreamingData::SkinPatches
SensorMeasurements SkinPatches
Definition: SensorStreamingData.h:34
yarp::os::Value::isInt32
virtual bool isInt32() const
Checks if value is a 32-bit integer.
Definition: Value.cpp:135