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
8
10
11#include <yarp/os/Log.h>
13#include <yarp/os/Property.h>
16
17
18namespace {
19YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSSERVER, "yarp.device.multipleanalogsensorsserver")
20}
21
22using namespace yarp::dev;
23
42
47{
48 switch(type)
49 {
51 return 3;
52 break;
54 return 3;
55 break;
57 return 3;
58 break;
60 return 3;
61 break;
63 return 3;
64 break;
65 case PositionSensors:
66 return 3;
67 break;
69 return 3;
70 break;
72 return 1;
73 break;
75 return 6;
76 break;
77 default:
78 assert(false);
79 // "MAS_getMeasureSizeFromEnum passed unexepcted enum";
80 return 0;
81 break;
82 }
83}
84
85inline std::string MAS_getStatusString(const yarp::dev::MAS_status status)
86{
87 switch(status)
88 {
90 return "MAS_OK";
91 break;
93 return "MAS_ERROR";
94 break;
96 return "MAS_OVF";
97 break;
99 return "MAS_TIMEOUT";
100 break;
102 return "MAS_WAITING_FOR_FIRST_READ";
103 break;
105 return "MAS_UNKNOWN";
106 break;
107 default:
108 assert(false);
109 // "MAS_getStatusString passed unexepcted enum";
110 return "";
111 break;
112 }
113}
114
115
116
118 PeriodicThread(0.02)
119{
120}
121
123
125{
126 if (!parseParams(config)) { return false; }
127
128 m_periodInS = m_period / 1000.0;
129
130 if (m_periodInS <= 0)
131 {
132 yCError(MULTIPLEANALOGSENSORSSERVER,
133 "Period parameter is present (%f) but it is not a positive integer, exiting.",
134 m_periodInS);
135 return false;
136 }
137
138 // Reserve a fair amount of elements
139 // It would be great if yarp::sig::Vector had a reserve method
140 m_buffer.resize(100);
141 m_buffer.resize(0);
142
143 // TODO(traversaro) Add port name validation when ready,
144 // see https://github.com/robotology/yarp/pull/1508
145 m_RPCPortName = m_name + "/rpc:o";
146 m_streamingPortName = m_name + "/measures:o";
147
148 return true;
149}
150
152{
153 bool ok = this->detachAll();
154
155 return ok;
156}
157
158// Note: as soon as we support only C++17, we can switch to using std::invoke
159// See https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
160#define MAS_CALL_MEMBER_FN(object, ptrToMember) ((*object).*(ptrToMember))
161
162template<typename Interface>
163ReturnValue MultipleAnalogSensorsServer::populateSensorsMetadata(Interface * wrappedDeviceInterface,
164 std::vector<SensorMetadata>& metadataVector, const std::string& tag,
165 yarp::dev::ReturnValue (Interface::*getNrOfSensorsMethodPtr)(size_t&) const,
166 yarp::dev::ReturnValue (Interface::*getNameMethodPtr)(size_t, std::string&) const,
167 yarp::dev::ReturnValue (Interface::*getFrameNameMethodPtr)(size_t, std::string&) const)
168{
169 if (wrappedDeviceInterface)
170 {
171 size_t nrOfSensors = 0;
172 ReturnValue retnum = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)(nrOfSensors);
173 if (!retnum)
174 {
175 yCError(MULTIPLEANALOGSENSORSSERVER,
176 "Failure in reading number of sensors of type %s.",
177 tag.c_str());
178 return retnum;
179 }
180 metadataVector.resize(nrOfSensors);
181 for (size_t i=0; i < nrOfSensors; i++)
182 {
183 std::string sensorName;
184 ReturnValue ret = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
185 if (!ret)
186 {
187 yCError(MULTIPLEANALOGSENSORSSERVER,
188 "Failure in reading name of sensor of type %s at index %zu.",
189 tag.c_str(),
190 i);
191 return ret;
192 }
193 std::string frameName;
194 ret = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getFrameNameMethodPtr)(i, frameName);
195 if (!ret)
196 {
197 yCError(MULTIPLEANALOGSENSORSSERVER,
198 "Failure in reading frame name of sensor of type %s at index %zu.",
199 tag.c_str(),
200 i);
201 return ret;
202 }
203
204 metadataVector[i].name = sensorName;
205 metadataVector[i].frameName = frameName;
206 metadataVector[i].additionalMetadata = "";
207 }
208
209 }
210 else
211 {
212 metadataVector.resize(0);
213 }
214 return ReturnValue_ok;
215}
216
217template<typename Interface>
218ReturnValue MultipleAnalogSensorsServer::populateSensorsMetadataNoFrameName(Interface * wrappedDeviceInterface,
219 std::vector<SensorMetadata>& metadataVector, const std::string& tag,
220 yarp::dev::ReturnValue (Interface::*getNrOfSensorsMethodPtr)(size_t&) const,
221 yarp::dev::ReturnValue (Interface::*getNameMethodPtr)(size_t, std::string&) const)
222{
223 if (wrappedDeviceInterface)
224 {
225 size_t nrOfSensors = 0;
226 ReturnValue retnum = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNrOfSensorsMethodPtr)(nrOfSensors);
227 if (!retnum)
228 {
229 yCError(MULTIPLEANALOGSENSORSSERVER,
230 "Failure in reading number of sensors of type %s.",
231 tag.c_str());
232 return retnum;
233 }
234 metadataVector.resize(nrOfSensors);
235 for (size_t i=0; i < nrOfSensors; i++)
236 {
237 std::string sensorName;
238 ReturnValue ret = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getNameMethodPtr)(i, sensorName);
239 if (!ret)
240 {
241 yCError(MULTIPLEANALOGSENSORSSERVER,
242 "Failure in reading name of sensor of type %s at index %zu.",
243 tag.c_str(),
244 i);
245 return ret;
246 }
247
248 metadataVector[i].name = sensorName;
249 metadataVector[i].frameName = "";
250 metadataVector[i].additionalMetadata = "";
251 }
252
253 }
254 else
255 {
256 metadataVector.resize(0);
257 }
258 return ReturnValue_ok;
259}
260
261
262ReturnValue MultipleAnalogSensorsServer::populateAllSensorsMetadata()
263{
265 ok = ok && populateSensorsMetadata(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes, "ThreeAxisGyroscopes",
269 ok = ok && populateSensorsMetadata(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers, "ThreeAxisLinearAccelerometers",
273 ok = ok && populateSensorsMetadata(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers, "ThreeAxisAngularAccelerometers",
277 ok = ok && populateSensorsMetadata(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers, "ThreeAxisMagnetometers",
281 ok = ok && populateSensorsMetadata(m_iPositionSensors, m_sensorMetadata.PositionSensors, "PositionSensors",
285 ok = ok && populateSensorsMetadata(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors, "LinearVelocitySensors",
289 ok = ok && populateSensorsMetadata(m_iOrientationSensors, m_sensorMetadata.OrientationSensors, "OrientationSensors",
293 ok = ok && populateSensorsMetadata(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors, "TemperatureSensors",
297 ok = ok && populateSensorsMetadata(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors, "SixAxisForceTorqueSensors",
301 ok = ok && populateSensorsMetadataNoFrameName(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays, "ContactLoadCellArrays",
304 ok = ok && populateSensorsMetadataNoFrameName(m_iEncoderArrays, m_sensorMetadata.EncoderArrays, "EncoderArrays",
307 ok = ok && populateSensorsMetadataNoFrameName(m_iSkinPatches, m_sensorMetadata.SkinPatches, "ISkinPatches",
310
311 return ok;
312}
313
314// Function to resize the measure vectors, variant where the size is given by a method
315template<typename Interface>
316bool MultipleAnalogSensorsServer::resizeMeasureVectors(Interface* wrappedDeviceInterface,
317 const std::vector< SensorMetadata >& metadataVector,
318 std::vector< yarp::dev::SensorMeasurement >& streamingDataVector,
319 size_t (Interface::*getMeasureSizePtr)(size_t) const)
320{
321 if (wrappedDeviceInterface)
322 {
323 size_t nrOfSensors = metadataVector.size();
324 streamingDataVector.resize(nrOfSensors);
325 for (size_t i=0; i < nrOfSensors; i++)
326 {
327 size_t measureSize = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getMeasureSizePtr)(i);
328 streamingDataVector[i].measurement.resize(measureSize, std::numeric_limits<double>::quiet_NaN());
329 }
330 }
331
332 return true;
333}
334
335// Function to resize the measure vectors, variant where the measure size is given by the type of the sensor
336template<typename Interface>
337bool MultipleAnalogSensorsServer::resizeMeasureVectors(Interface* wrappedDeviceInterface,
338 const std::vector< SensorMetadata >& metadataVector,
339 std::vector< yarp::dev::SensorMeasurement >& streamingDataVector,
340 size_t measureSize)
341{
342 if (wrappedDeviceInterface)
343 {
344 size_t nrOfSensors = metadataVector.size();
345 streamingDataVector.resize(nrOfSensors);
346 for (size_t i=0; i < nrOfSensors; i++)
347 {
348 streamingDataVector[i].measurement.resize(measureSize, std::numeric_limits<double>::quiet_NaN());
349 }
350 }
351
352 return true;
353}
354
355bool MultipleAnalogSensorsServer::resizeAllMeasureVectors( yarp::dev::SensorStreamingData& streamingData)
356{
357 bool ok = true;
358 // The size of each sensor is given in the interface documentation
359 ok = ok && resizeMeasureVectors(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes,
361 ok = ok && resizeMeasureVectors(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers,
363 ok = ok && resizeMeasureVectors(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers,
365 ok = ok && resizeMeasureVectors(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers,
367 ok = ok && resizeMeasureVectors(m_iPositionSensors, m_sensorMetadata.PositionSensors,
369 ok = ok && resizeMeasureVectors(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors,
371 ok = ok && resizeMeasureVectors(m_iOrientationSensors, m_sensorMetadata.OrientationSensors,
373 ok = ok && resizeMeasureVectors(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors,
375 ok = ok && resizeMeasureVectors(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors,
377 ok = ok && resizeMeasureVectors(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays,
379 ok = ok && resizeMeasureVectors(m_iEncoderArrays, m_sensorMetadata.EncoderArrays,
381 ok = ok && resizeMeasureVectors(m_iSkinPatches, m_sensorMetadata.SkinPatches,
383
384 return ok;
385}
386
388{
389 if (!poly)
390 {
391 yCError(MULTIPLEANALOGSENSORSSERVER, "Null pointer passed to attach.");
392 close();
393 return false;
394 }
395
396 // View all the interfaces
397 poly->view(m_iThreeAxisGyroscopes);
398 poly->view(m_iThreeAxisLinearAccelerometers);
399 poly->view(m_iThreeAxisAngularAccelerometers);
400 poly->view(m_iThreeAxisMagnetometers);
401 poly->view(m_iPositionSensors);
402 poly->view(m_iLinearVelocitySensors);
403 poly->view(m_iOrientationSensors);
404 poly->view(m_iTemperatureSensors);
405 poly->view(m_iSixAxisForceTorqueSensors);
406 poly->view(m_iContactLoadCellArrays);
407 poly->view(m_iEncoderArrays);
408 poly->view(m_iSkinPatches);
409
410
411 // Populate the RPC data to be served on the RPC port
412 bool ok = populateAllSensorsMetadata();
413
414 if(!ok)
415 {
416 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in populateAllSensorsMetadata()");
417 close();
418 return false;
419 }
420
421 // Attach was successful, open the ports
422 ok = m_streamingPort.open(m_streamingPortName);
423 if (!ok)
424 {
425 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_streamingPortName.c_str());
426 close();
427 return false;
428 }
429
430 ok = this->yarp().attachAsServer(m_rpcPort);
431 if (!ok)
432 {
433 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in attaching RPC port to thrift RPC interface.");
434 close();
435 return false;
436 }
437
438 ok = m_rpcPort.open(m_RPCPortName);
439 if (!ok)
440 {
441 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in opening port named %s.", m_RPCPortName.c_str());
442 close();
443 return false;
444 }
445
446 // Set rate period
447 ok = this->setPeriod(m_periodInS);
448 ok = ok && this->start();
449 if (!ok)
450 {
451 yCError(MULTIPLEANALOGSENSORSSERVER, "Failure in starting thread.");
452 close();
453 return false;
454 }
455
456 yCDebug(MULTIPLEANALOGSENSORSSERVER, "Attach complete");
457 return true;
458}
459
461{
462 // Stop the thread on detach
463 if (this->isRunning())
464 {
465 this->stop();
466 }
467
468 m_rpcPort.close();
469 m_streamingPort.close();
470
471 yCDebug(MULTIPLEANALOGSENSORSSERVER, "Detach complete");
472 return true;
473}
474
476{
477 return m_sensorMetadata;
478}
479
480template<typename Interface>
481bool MultipleAnalogSensorsServer::genericStreamData(Interface* wrappedDeviceInterface,
482 const std::vector< SensorMetadata >& metadataVector,
483 std::vector< typename yarp::dev::SensorMeasurement >& streamingDataVector,
484 yarp::dev::MAS_status (Interface::*getStatusMethodPtr)(size_t) const,
485 ReturnValue (Interface::*getMeasureMethodPtr)(size_t, yarp::sig::Vector&, double&) const,
486 const char* sensorType)
487{
488 if (wrappedDeviceInterface)
489 {
490 size_t nrOfSensors = metadataVector.size();
491 for (size_t i=0; i < nrOfSensors; i++)
492 {
493 yarp::sig::Vector& outputBuffer = streamingDataVector[i].measurement;
494 double& outputTimestamp = streamingDataVector[i].timestamp;
495 yarp::dev::MAS_status status = MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getStatusMethodPtr)(i);
496 if (status == yarp::dev::MAS_OK)
497 {
498 MAS_CALL_MEMBER_FN(wrappedDeviceInterface, getMeasureMethodPtr)(i, outputBuffer, outputTimestamp);
499 } else
500 {
501 yCError(MULTIPLEANALOGSENSORSSERVER,
502 "Failure in reading data from sensor %s of type %s with code %s, no data will be sent on the port.",
503 metadataVector[i].name.c_str(), sensorType, MAS_getStatusString(status).c_str());
504 return false;
505 }
506 }
507 }
508
509 return true;
510}
511
512
514{
515 yarp::dev::SensorStreamingData& streamingData = m_streamingPort.prepare();
516
517 // Resize the output streaming buffer vectors to be of the correct size
518 bool ok = true;
519 ok = resizeAllMeasureVectors(streamingData);
520
521 // Populate buffers
522 ok = ok && genericStreamData(m_iThreeAxisGyroscopes, m_sensorMetadata.ThreeAxisGyroscopes,
523 streamingData.ThreeAxisGyroscopes.measurements,
526 "ThreeAxisGyroscope");
527
528 ok = ok && genericStreamData(m_iThreeAxisLinearAccelerometers, m_sensorMetadata.ThreeAxisLinearAccelerometers,
532 "ThreeAxisLinearAccelerometer");
533
534 ok = ok && genericStreamData(m_iThreeAxisAngularAccelerometers, m_sensorMetadata.ThreeAxisAngularAccelerometers,
538 "ThreeAxisAngularAccelerometer");
539
540 ok = ok && genericStreamData(m_iThreeAxisMagnetometers, m_sensorMetadata.ThreeAxisMagnetometers,
544 "ThreeAxisMagnetometer");
545
546 ok = ok && genericStreamData(m_iPositionSensors, m_sensorMetadata.PositionSensors,
547 streamingData.PositionSensors.measurements,
550 "PositionSensor");
551
552 ok = ok && genericStreamData(m_iLinearVelocitySensors, m_sensorMetadata.LinearVelocitySensors,
556 "LinearVelocitySensor");
557
558 ok = ok && genericStreamData(m_iOrientationSensors, m_sensorMetadata.OrientationSensors,
559 streamingData.OrientationSensors.measurements,
562 "OrientationSensor");
563
564 ok = ok && genericStreamData(m_iTemperatureSensors, m_sensorMetadata.TemperatureSensors,
565 streamingData.TemperatureSensors.measurements,
568 "TemperatureSensor");
569
570 ok = ok && genericStreamData(m_iSixAxisForceTorqueSensors, m_sensorMetadata.SixAxisForceTorqueSensors,
574 "SixAxisForceTorqueSensor");
575
576 ok = ok && genericStreamData(m_iContactLoadCellArrays, m_sensorMetadata.ContactLoadCellArrays,
580 "ContactLoadCellArrays");
581
582 ok = ok && genericStreamData(m_iEncoderArrays, m_sensorMetadata.EncoderArrays,
583 streamingData.EncoderArrays.measurements,
586 "EncoderArray");
587
588 ok = ok && genericStreamData(m_iSkinPatches, m_sensorMetadata.SkinPatches,
589 streamingData.SkinPatches.measurements,
592 "SkinPatch");
593
594 if (ok)
595 {
596 m_stamp.update();
597 m_streamingPort.setEnvelope(m_stamp);
598 m_streamingPort.write();
599 }
600 else
601 {
602 m_streamingPort.unprepare();
603 }
604}
605
size_t size_t
#define MAS_CALL_MEMBER_FN(object, ptrToMember)
@ ThreeAxisAngularAccelerometers
@ ThreeAxisLinearAccelerometers
std::string MAS_getStatusString(const yarp::dev::MAS_status status)
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.
#define ReturnValue_ok
Definition ReturnValue.h:82
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 yarp::dev::ReturnValue getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading 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 yarp::dev::ReturnValue getContactLoadCellArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfContactLoadCellArrays(size_t &num) const =0
Get the number of contact load cell array exposed by this device.
virtual yarp::dev::ReturnValue getEncoderArrayName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfEncoderArrays(size_t &num) const =0
Get the number of encoder arrays exposed by this device.
virtual size_t getEncoderArraySize(size_t sens_index) const =0
Get the size of the specified encoder array.
virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::ReturnValue getLinearVelocitySensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfLinearVelocitySensors(size_t &num) const =0
Get the number of linear velocity sensors exposed by this device.
virtual yarp::dev::ReturnValue 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 yarp::dev::ReturnValue getLinearVelocitySensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue 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 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfOrientationSensors(size_t &num) const =0
Get the number of orientation sensors exposed by this device.
virtual yarp::dev::ReturnValue getOrientationSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getPositionSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue 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 yarp::dev::ReturnValue getPositionSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfPositionSensors(size_t &num) const =0
Get the number of position sensors exposed by this device.
virtual yarp::dev::ReturnValue getSixAxisForceTorqueSensorMeasure(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 getSixAxisForceTorqueSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfSixAxisForceTorqueSensors(size_t &num) const =0
Get the number of six axis force torque sensors exposed by this device.
virtual yarp::dev::ReturnValue getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::ReturnValue getSkinPatchName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
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 yarp::dev::ReturnValue getNrOfSkinPatches(size_t &num) const =0
Get the number of skin patches exposed by this device.
virtual yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getTemperatureSensorMeasure(size_t sens_index, double &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfTemperatureSensors(size_t &num) const =0
Get the number of temperature sensors exposed by this device.
virtual yarp::dev::ReturnValue getTemperatureSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfThreeAxisAngularAccelerometers(size_t &num) const =0
Get the number of three axis angular accelerometers exposed by this device.
virtual yarp::dev::ReturnValue getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfThreeAxisGyroscopes(size_t &num) const =0
Get the number of three axis gyroscopes exposed by this sensor.
virtual yarp::dev::ReturnValue getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the gyroscope.
virtual yarp::dev::ReturnValue getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const =0
Get the last reading of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfThreeAxisLinearAccelerometers(size_t &num) const =0
Get the number of three axis linear accelerometers exposed by this device.
virtual yarp::dev::ReturnValue getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getThreeAxisMagnetometerMeasure(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 getThreeAxisMagnetometerStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfThreeAxisMagnetometers(size_t &num) const =0
Get the number of magnetometers exposed by this device.
virtual yarp::dev::ReturnValue getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
A container for a device driver.
Definition PolyDriver.h:23
std::vector< SensorMeasurementData > measurements
SensorMeasurementsData ThreeAxisGyroscopes
SensorMeasurementsData OrientationSensors
SensorMeasurementsData PositionSensors
SensorMeasurementsData SkinPatches
SensorMeasurementsData LinearVelocitySensors
SensorMeasurementsData ThreeAxisMagnetometers
SensorMeasurementsData SixAxisForceTorqueSensors
SensorMeasurementsData ContactLoadCellArrays
SensorMeasurementsData TemperatureSensors
SensorMeasurementsData ThreeAxisLinearAccelerometers
SensorMeasurementsData EncoderArrays
SensorMeasurementsData 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:330
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:49
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
void resize(size_t size)
Resize the vector.
Definition VectorBase.h:106
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
STL namespace.
For streams capable of holding different kinds of content, check what they actually have.
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