YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
MultipleAnalogSensorsServer.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
9
11
12#include <yarp/os/Log.h>
14#include <yarp/os/Property.h>
16
17
18namespace {
19YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSSERVER, "yarp.device.multipleanalogsensorsserver")
20}
21
40
45{
46 switch(type)
47 {
49 return 3;
50 break;
52 return 3;
53 break;
55 return 3;
56 break;
58 return 3;
59 break;
61 return 3;
62 break;
63 case PositionSensors:
64 return 3;
65 break;
67 return 3;
68 break;
70 return 1;
71 break;
73 return 6;
74 break;
75 default:
76 assert(false);
77 // "MAS_getMeasureSizeFromEnum passed unexepcted enum";
78 return 0;
79 break;
80 }
81}
82
83inline std::string MAS_getStatusString(const yarp::dev::MAS_status status)
84{
85 switch(status)
86 {
88 return "MAS_OK";
89 break;
91 return "MAS_ERROR";
92 break;
94 return "MAS_OVF";
95 break;
97 return "MAS_TIMEOUT";
98 break;
100 return "MAS_WAITING_FOR_FIRST_READ";
101 break;
103 return "MAS_UNKNOWN";
104 break;
105 default:
106 assert(false);
107 // "MAS_getStatusString passed unexepcted enum";
108 return "";
109 break;
110 }
111}
112
113
114
116 PeriodicThread(0.02)
117{
118}
119
121
123{
124 if (!parseParams(config)) { return false; }
125
126 m_periodInS = m_period / 1000.0;
127
128 if (m_periodInS <= 0)
129 {
130 yCError(MULTIPLEANALOGSENSORSSERVER,
131 "Period parameter is present (%f) but it is not a positive integer, exiting.",
132 m_periodInS);
133 return false;
134 }
135
136 // Reserve a fair amount of elements
137 // It would be great if yarp::sig::Vector had a reserve method
138 m_buffer.resize(100);
139 m_buffer.resize(0);
140
141 // TODO(traversaro) Add port name validation when ready,
142 // see https://github.com/robotology/yarp/pull/1508
143 m_RPCPortName = m_name + "/rpc:o";
144 m_streamingPortName = m_name + "/measures:o";
145
146 return true;
147}
148
150{
151 bool ok = this->detachAll();
152
153 return ok;
154}
155
156// Note: as soon as we support only C++17, we can switch to using std::invoke
157// See https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
158#define MAS_CALL_MEMBER_FN(object, ptrToMember) ((*object).*(ptrToMember))
159
160template<typename Interface>
161bool MultipleAnalogSensorsServer::populateSensorsMetadata(Interface * wrappedDeviceInterface,
162 std::vector<SensorMetadata>& metadataVector, const std::string& tag,
163 size_t (Interface::*getNrOfSensorsMethodPtr)() const,
164 bool (Interface::*getNameMethodPtr)(size_t, std::string&) const,
165 bool (Interface::*getFrameNameMethodPtr)(size_t, std::string&) const)
166{
167 if (wrappedDeviceInterface)
168 {
169 size_t nrOfSensors = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)();
170 metadataVector.resize(nrOfSensors);
171 for (size_t i=0; i < nrOfSensors; i++)
172 {
173 std::string sensorName;
174 bool ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
175 if (!ok)
176 {
177 yCError(MULTIPLEANALOGSENSORSSERVER,
178 "Failure in reading name of sensor of type %s at index %zu.",
179 tag.c_str(),
180 i);
181 return false;
182 }
183 std::string frameName;
184 ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getFrameNameMethodPtr)(i, frameName);
185 if (!ok)
186 {
187 yCError(MULTIPLEANALOGSENSORSSERVER,
188 "Failure in reading frame name of sensor of type %s at index %zu.",
189 tag.c_str(),
190 i);
191 return false;
192 }
193
194 metadataVector[i].name = sensorName;
195 metadataVector[i].frameName = frameName;
196 metadataVector[i].additionalMetadata = "";
197 }
198
199 }
200 else
201 {
202 metadataVector.resize(0);
203 }
204 return true;
205}
206
207template<typename Interface>
208bool MultipleAnalogSensorsServer::populateSensorsMetadataNoFrameName(Interface * wrappedDeviceInterface,
209 std::vector<SensorMetadata>& metadataVector, const std::string& tag,
210 size_t (Interface::*getNrOfSensorsMethodPtr)() const,
211 bool (Interface::*getNameMethodPtr)(size_t, std::string&) const)
212{
213 if (wrappedDeviceInterface)
214 {
215 size_t nrOfSensors = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)();
216 metadataVector.resize(nrOfSensors);
217 for (size_t i=0; i < nrOfSensors; i++)
218 {
219 std::string sensorName;
220 bool ok = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
221 if (!ok)
222 {
223 yCError(MULTIPLEANALOGSENSORSSERVER,
224 "Failure in reading name of sensor of type %s at index %zu.",
225 tag.c_str(),
226 i);
227 return false;
228 }
229
230 metadataVector[i].name = sensorName;
231 metadataVector[i].frameName = "";
232 metadataVector[i].additionalMetadata = "";
233 }
234
235 }
236 else
237 {
238 metadataVector.resize(0);
239 }
240 return true;
241}
242
243
244bool MultipleAnalogSensorsServer::populateAllSensorsMetadata()
245{
246 bool ok = true;
247 ok = ok && populateSensorsMetadata(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes",
251 ok = ok && populateSensorsMetadata(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers",
255 ok = ok && populateSensorsMetadata(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers, "ThreeAxisAngularAccelerometers",
259 ok = ok && populateSensorsMetadata(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers",
263 ok = ok && populateSensorsMetadata(m_iPositionSensors, m_sensorMetadata.PositionSensors, "PositionSensors",
267 ok = ok && populateSensorsMetadata(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors, "LinearVelocitySensors",
271 ok = ok && populateSensorsMetadata(m_iOrientationSensors, m_sensorMetadata.OrientationSensors, "OrientationSensors",
275 ok = ok && populateSensorsMetadata(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors, "TemperatureSensors",
279 ok = ok && populateSensorsMetadata(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors",
283 ok = ok && populateSensorsMetadataNoFrameName(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
286 ok = ok && populateSensorsMetadataNoFrameName(m_iEncoderArrays, m_sensorMetadata.EncoderArrays, "EncoderArrays",
289 ok = ok && populateSensorsMetadataNoFrameName(m_iSkinPatches, m_sensorMetadata.SkinPatches, "ISkinPatches",
292
293 return ok;
294}
295
296// Function to resize the measure vectors, variant where the size is given by a method
297template<typename Interface>
298bool MultipleAnalogSensorsServer::resizeMeasureVectors(Interface* wrappedDeviceInterface,
299 const std::vector< SensorMetadata >& metadataVector,
300 std::vector< yarp::dev::SensorMeasurement >& streamingDataVector,
301 size_t (Interface::*getMeasureSizePtr)(size_t) const)
302{
303 if (wrappedDeviceInterface)
304 {
305 size_t nrOfSensors = metadataVector.size();
306 streamingDataVector.resize(nrOfSensors);
307 for (size_t i=0; i < nrOfSensors; i++)
308 {
309 size_t measureSize = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getMeasureSizePtr)(i);
310 streamingDataVector[i].measurement.resize(measureSize, std::numeric_limits<double>::quiet_NaN());
311 }
312 }
313
314 return true;
315}
316
317// Function to resize the measure vectors, variant where the measure size is given by the type of the sensor
318template<typename Interface>
319bool MultipleAnalogSensorsServer::resizeMeasureVectors(Interface* wrappedDeviceInterface,
320 const std::vector< SensorMetadata >& metadataVector,
321 std::vector< yarp::dev::SensorMeasurement >& streamingDataVector,
322 size_t measureSize)
323{
324 if (wrappedDeviceInterface)
325 {
326 size_t nrOfSensors = metadataVector.size();
327 streamingDataVector.resize(nrOfSensors);
328 for (size_t i=0; i < nrOfSensors; i++)
329 {
330 streamingDataVector[i].measurement.resize(measureSize, std::numeric_limits<double>::quiet_NaN());
331 }
332 }
333
334 return true;
335}
336
337bool MultipleAnalogSensorsServer::resizeAllMeasureVectors( yarp::dev::SensorStreamingData& streamingData)
338{
339 bool ok = true;
340 // The size of each sensor is given in the interface documentation
341 ok = ok && resizeMeasureVectors(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes,
343 ok = ok && resizeMeasureVectors(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers,
345 ok = ok && resizeMeasureVectors(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers,
347 ok = ok && resizeMeasureVectors(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers,
349 ok = ok && resizeMeasureVectors(m_iPositionSensors, m_sensorMetadata.PositionSensors,
351 ok = ok && resizeMeasureVectors(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors,
353 ok = ok && resizeMeasureVectors(m_iOrientationSensors, m_sensorMetadata.OrientationSensors,
355 ok = ok && resizeMeasureVectors(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors,
357 ok = ok && resizeMeasureVectors(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors,
359 ok = ok && resizeMeasureVectors(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays,
361 ok = ok && resizeMeasureVectors(m_iEncoderArrays, m_sensorMetadata.EncoderArrays,
363 ok = ok && resizeMeasureVectors(m_iSkinPatches, m_sensorMetadata.SkinPatches,
365
366 return ok;
367}
368
370{
371 if (!poly)
372 {
373 yCError(MULTIPLEANALOGSENSORSSERVER, "Null pointer passed to attach.");
374 close();
375 return false;
376 }
377
378 // View all the interfaces
379 poly->view(m_iThreeAxisGyroscopes);
380 poly->view(m_iThreeAxisLinearAccelerometers);
381 poly->view(m_iThreeAxisAngularAccelerometers);
382 poly->view(m_iThreeAxisMagnetometers);
383 poly->view(m_iPositionSensors);
384 poly->view(m_iLinearVelocitySensors);
385 poly->view(m_iOrientationSensors);
386 poly->view(m_iTemperatureSensors);
387 poly->view(m_iSixAxisForceTorqueSensors);
388 poly->view(m_iContactLoadCellArrays);
389 poly->view(m_iEncoderArrays);
390 poly->view(m_iSkinPatches);
391
392
393 // Populate the RPC data to be served on the RPC port
394 bool ok = populateAllSensorsMetadata();
395
396 if(!ok)
397 {
398 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in populateAllSensorsMetadata()");
399 close();
400 return false;
401 }
402
403 // Attach was successful, open the ports
404 ok = m_streamingPort.open(m_streamingPortName);
405 if (!ok)
406 {
407 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_streamingPortName.c_str());
408 close();
409 return false;
410 }
411
412 ok = this->yarp().attachAsServer(m_rpcPort);
413 if (!ok)
414 {
415 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in attaching RPC port to thrift RPC interface.");
416 close();
417 return false;
418 }
419
420 ok = m_rpcPort.open(m_RPCPortName);
421 if (!ok)
422 {
423 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_RPCPortName.c_str());
424 close();
425 return false;
426 }
427
428 // Set rate period
429 ok = this->setPeriod(m_periodInS);
430 ok = ok && this->start();
431 if (!ok)
432 {
433 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in starting thread.");
434 close();
435 return false;
436 }
437
438 yCDebug(MULTIPLEANALOGSENSORSSERVER, "Attach complete");
439 return true;
440}
441
443{
444 // Stop the thread on detach
445 if (this->isRunning())
446 {
447 this->stop();
448 }
449
450 m_rpcPort.close();
451 m_streamingPort.close();
452
453 yCDebug(MULTIPLEANALOGSENSORSSERVER, "Detach complete");
454 return true;
455}
456
458{
459 return m_sensorMetadata;
460}
461
462template<typename Interface>
463bool MultipleAnalogSensorsServer::genericStreamData(Interface* wrappedDeviceInterface,
464 const std::vector< SensorMetadata >& metadataVector,
465 std::vector< typename yarp::dev::SensorMeasurement >& streamingDataVector,
466 yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
467 bool (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const,
468 const char* sensorType)
469{
470 if (wrappedDeviceInterface)
471 {
472 size_t nrOfSensors = metadataVector.size();
473 for (size_t i=0; i < nrOfSensors; i++)
474 {
475 yarp::sig::Vector& outputBuffer = streamingDataVector[i].measurement;
476 double& outputTimestamp = streamingDataVector[i].timestamp;
477 yarp::dev::MAS_status status = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getStatusMethodPtr)(i);
478 if (status == yarp::dev::MAS_OK)
479 {
480 MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getMeasureMethodPtr)(i, outputBuffer, outputTimestamp);
481 } else
482 {
483 yCError(MULTIPLEANALOGSENSORSSERVER,
484 "Failure in reading data from sensor %s of type %s with code %s, no data will be sent on the port.",
485 metadataVector[i].name.c_str(), sensorType, MAS_getStatusString(status).c_str());
486 return false;
487 }
488 }
489 }
490
491 return true;
492}
493
494
496{
497 yarp::dev::SensorStreamingData& streamingData = m_streamingPort.prepare();
498
499 // Resize the output streaming buffer vectors to be of the correct size
500 bool ok = true;
501 ok = resizeAllMeasureVectors(streamingData);
502
503 // Populate buffers
504 ok = ok && genericStreamData(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes,
505 streamingData.ThreeAxisGyroscopes.measurements,
508 "ThreeAxisGyroscope");
509
510 ok = ok && genericStreamData(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers,
514 "ThreeAxisLinearAccelerometer");
515
516 ok = ok && genericStreamData(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers,
520 "ThreeAxisAngularAccelerometer");
521
522 ok = ok && genericStreamData(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers,
526 "ThreeAxisMagnetometer");
527
528 ok = ok && genericStreamData(m_iPositionSensors, m_sensorMetadata.PositionSensors,
529 streamingData.PositionSensors.measurements,
532 "PositionSensor");
533
534 ok = ok && genericStreamData(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors,
538 "LinearVelocitySensor");
539
540 ok = ok && genericStreamData(m_iOrientationSensors, m_sensorMetadata.OrientationSensors,
541 streamingData.OrientationSensors.measurements,
544 "OrientationSensor");
545
546 ok = ok && genericStreamData(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors,
547 streamingData.TemperatureSensors.measurements,
550 "TemperatureSensor");
551
552 ok = ok && genericStreamData(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors,
556 "SixAxisForceTorqueSensor");
557
558 ok = ok && genericStreamData(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays,
562 "ContactLoadCellArrays");
563
564 ok = ok && genericStreamData(m_iEncoderArrays, m_sensorMetadata.EncoderArrays,
565 streamingData.EncoderArrays.measurements,
568 "EncoderArray");
569
570 ok = ok && genericStreamData(m_iSkinPatches, m_sensorMetadata.SkinPatches,
571 streamingData.SkinPatches.measurements,
574 "SkinPatch");
575
576 if (ok)
577 {
578 m_stamp.update();
579 m_streamingPort.setEnvelope(m_stamp);
580 m_streamingPort.write();
581 }
582 else
583 {
584 m_streamingPort.unprepare();
585 }
586}
587
size_t size_t
#define MAS_CALL_MEMBER_FN(object, ptrToMember)
@ ThreeAxisAngularAccelerometers
@ ThreeAxisLinearAccelerometers
std::string MAS_getStatusString(const yarp::dev::MAS_status status)
#define MAS_CALL_MEMBER_FN(object, ptrToMember)
MAS_SensorTypeServer
Internal identifier of the type of sensors.
@ ThreeAxisAngularAccelerometers
@ ThreeAxisLinearAccelerometers
size_t MAS_getMeasureSizeFromEnum(const MAS_SensorTypeServer type)
Get measure size for sensors with fixed size measure.
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool detach() override
Detach the object (you must have first called attach).
SensorRPCData getMetadata() override
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
void threadRelease() override
Release method.
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *p) override
Attach to another object.
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
std::vector< SensorMetadata > SkinPatches
std::vector< SensorMetadata > ContactLoadCellArrays
std::vector< SensorMetadata > ThreeAxisAngularAccelerometers
std::vector< SensorMetadata > EncoderArrays
std::vector< SensorMetadata > PositionSensors
std::vector< SensorMetadata > ThreeAxisGyroscopes
std::vector< SensorMetadata > ThreeAxisLinearAccelerometers
std::vector< SensorMetadata > LinearVelocitySensors
std::vector< SensorMetadata > ThreeAxisMagnetometers
std::vector< SensorMetadata > OrientationSensors
std::vector< SensorMetadata > SixAxisForceTorqueSensors
std::vector< SensorMetadata > TemperatureSensors
bool view(T *&x)
Get an interface to the device driver.
virtual yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getContactLoadCellArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getContactLoadCellArraySize(size_t sens_index) const =0
Get the size of the specified contact load cell array.
virtual bool getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual size_t getNrOfContactLoadCellArrays() const =0
Get the number of contact load cell array exposed by this device.
virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual size_t getEncoderArraySize(size_t sens_index) const =0
Get the size of the specified encoder array.
virtual size_t getNrOfEncoderArrays() const =0
Get the number of encoder arrays exposed by this device.
virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual bool getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const =0
Get the last reading of the linear velocity sensor as x y z.
virtual bool getLinearVelocitySensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfLinearVelocitySensors() const =0
Get the number of linear velocity sensors exposed by this device.
virtual yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getLinearVelocitySensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getOrientationSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfOrientationSensors() const =0
Get the number of orientation sensors exposed by this device.
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.
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.
virtual bool getPositionSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfPositionSensors() const =0
Get the number of position sensors exposed by this device.
virtual yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual size_t getNrOfSixAxisForceTorqueSensors() const =0
Get the number of six axis force torque sensors exposed by this device.
virtual yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual bool getSkinPatchName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfSkinPatches() const =0
Get the number of skin patches exposed by this device.
virtual size_t getSkinPatchSize(size_t sens_index) const =0
Get the size of the specified skin patch.
virtual yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual bool getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getTemperatureSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual size_t getNrOfTemperatureSensors() const =0
Get the number of temperature sensors exposed by this device.
virtual yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual size_t getNrOfThreeAxisAngularAccelerometers() const =0
Get the number of three axis angular accelerometers exposed by this device.
virtual bool getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfThreeAxisGyroscopes() const =0
Get the number of three axis gyroscopes exposed by this sensor.
virtual bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the gyroscope.
virtual bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfThreeAxisLinearAccelerometers() const =0
Get the number of three axis linear accelerometers exposed by this device.
virtual bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual size_t getNrOfThreeAxisMagnetometers() const =0
Get the number of magnetometers exposed by this device.
virtual yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
A container for a device driver.
Definition PolyDriver.h:23
std::vector< SensorMeasurement > measurements
SensorMeasurements SixAxisForceTorqueSensors
SensorMeasurements ThreeAxisMagnetometers
SensorMeasurements ThreeAxisLinearAccelerometers
SensorMeasurements ThreeAxisAngularAccelerometers
bool detachAll() final
Detach the object (you must have first called attach).
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
bool unprepare()
Give the last prepared object back to YARP without writing it.
bool setPeriod(double period)
Set the (new) period of the thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
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:31
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
Definition Stamp.cpp:124
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
STL namespace.
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_UNKNOWN
The sensor is in an unknown state.
@ MAS_TIMEOUT
The sensor is read through the network, and the latest measurement was received before an implementat...
@ MAS_ERROR
The sensor is in generic error state.
@ MAS_WAITING_FOR_FIRST_READ
The sensor is read through the network, and the device is waiting to receive the first measurement.
@ MAS_OK
The sensor is working correctly.
@ MAS_OVF
The sensor reached an overflow.
The main, catch-all namespace for YARP.
Definition dirs.h:16