14YARP_LOG_COMPONENT(MULTIPLEANALOGSENSORSCLIENT,
"yarp.device.multipleanalogsensorsclient")
35 "No data received in the last %lf seconds, timeout enabled.",
48 std::string localRPCPortName =
m_local +
"/rpc:i";
49 std::string localStreamingPortName =
m_local +
"/measures:i";
50 std::string remoteRPCPortName =
m_remote +
"/rpc:o";
51 std::string remoteStreamingPortName =
m_remote +
"/measures:o";
57 bool ok = m_rpcPort.
open(localRPCPortName);
60 yCError(MULTIPLEANALOGSENSORSCLIENT,
61 "Failure to open the port %s.",
62 localRPCPortName.c_str());
67 ok = m_streamingPort.
open(localStreamingPortName);
71 yCError(MULTIPLEANALOGSENSORSCLIENT,
72 "Failure to open the port %s.",
73 localStreamingPortName.c_str());
83 yCError(MULTIPLEANALOGSENSORSCLIENT,
84 "Failure connecting port %s to %s.",
85 localRPCPortName.c_str(),
86 remoteRPCPortName.c_str());
87 yCError(MULTIPLEANALOGSENSORSCLIENT,
"Check that the specified MultipleAnalogSensorsServer is up.");
94 yCError(MULTIPLEANALOGSENSORSCLIENT,
95 "Failure connecting port %s to %s.",
96 remoteStreamingPortName.c_str(),
97 localStreamingPortName.c_str());
98 yCError(MULTIPLEANALOGSENSORSCLIENT,
"Check that the specified MultipleAnalogSensorsServer is up.");
106 yCError(MULTIPLEANALOGSENSORSCLIENT,
"Failure opening Thrift-based RPC interface.");
118 yCDebug(MULTIPLEANALOGSENSORSCLIENT,
"Open complete");
124 m_streamingPort.
close();
127 yCDebug(MULTIPLEANALOGSENSORSCLIENT,
"Close complete");
131size_t MultipleAnalogSensorsClient::genericGetNrOfSensors(
const std::vector<SensorMetadata>& metadataVector,
135 return metadataVector.size();
137 std::lock_guard<std::mutex> guard(m_streamingPort.
dataMutex);
149 std::lock_guard<std::mutex> guard(m_streamingPort.
dataMutex);
151 return m_streamingPort.
status;
154ReturnValue MultipleAnalogSensorsClient::genericGetName(
const std::vector<SensorMetadata>& metadataVector,
const std::string& tag,
155 size_t sens_index, std::string& name)
const
158 yCError(MULTIPLEANALOGSENSORSCLIENT,
159 "Missing metadata, the device has been configured with the option"
160 "externalConnection set to true.");
163 if (sens_index >= metadataVector.size())
165 yCError(MULTIPLEANALOGSENSORSCLIENT,
166 "No sensor of type %s with index %lu (nr of sensors: %lu).",
169 metadataVector.size());
173 name = metadataVector[sens_index].name;
177ReturnValue MultipleAnalogSensorsClient::genericGetFrameName(
const std::vector<SensorMetadata>& metadataVector,
const std::string& tag,
178 size_t sens_index, std::string& frameName)
const
181 yCError(MULTIPLEANALOGSENSORSCLIENT,
182 "Missing metadata, the device has been configured with the option"
183 "externalConnection set to true.");
186 if (sens_index >= metadataVector.size())
188 yCError(MULTIPLEANALOGSENSORSCLIENT,
189 "No sensor of type %s with index %lu (nr of sensors: %lu).",
192 metadataVector.size());
196 frameName = metadataVector[sens_index].frameName;
200ReturnValue MultipleAnalogSensorsClient::genericGetMeasure(
const std::vector<SensorMetadata>& metadataVector,
const std::string& tag,
205 std::lock_guard<std::mutex> guard(m_streamingPort.
dataMutex);
209 yCError(MULTIPLEANALOGSENSORSCLIENT,
210 "Sensor of type %s with index %lu has non-MAS_OK status.",
218 yCError(MULTIPLEANALOGSENSORSCLIENT,
219 "No sensor of type %s with index %lu (nr of sensors: %lu).",
222 metadataVector.size());
227 assert(metadataVector.size() == measurementsVector.
measurements.size());
230 timestamp = measurementsVector.
measurements[sens_index].timestamp;
231 out = measurementsVector.
measurements[sens_index].measurement;
236size_t MultipleAnalogSensorsClient::genericGetSize(
const std::vector<SensorMetadata>& metadataVector,
239 std::lock_guard<std::mutex> guard(m_streamingPort.
dataMutex);
242 yCError(MULTIPLEANALOGSENSORSCLIENT,
"No data received, no information on the size of the specified sensor.");
247 if (sens_index >= measurementsVector.
measurements.size())
249 yCError(MULTIPLEANALOGSENSORSCLIENT,
250 "No sensor of type %s with index %lu (nr of sensors: %lu).",
253 metadataVector.size());
257 return measurementsVector.
measurements[sens_index].measurement.size();
305 return genericGetStatus();
310 return genericGetName(m_sensorsMetadata.
ThreeAxisGyroscopes,
"ThreeAxisGyroscopes", sens_index, name);
315 return genericGetFrameName(m_sensorsMetadata.
ThreeAxisGyroscopes,
"ThreeAxisGyroscopes", sens_index, frameName);
333 return genericGetStatus();
361 return genericGetStatus();
389 return genericGetStatus();
394 return genericGetName(m_sensorsMetadata.
ThreeAxisMagnetometers,
"ThreeAxisMagnetometers", sens_index, name);
399 return genericGetFrameName(m_sensorsMetadata.
ThreeAxisMagnetometers,
"ThreeAxisMagnetometers", sens_index, frameName);
417 return genericGetStatus();
422 return genericGetName(m_sensorsMetadata.
OrientationSensors,
"OrientationSensors", sens_index, name);
427 return genericGetFrameName(m_sensorsMetadata.
OrientationSensors,
"OrientationSensors", sens_index, frameName);
445 return genericGetStatus();
450 return genericGetName(m_sensorsMetadata.
PositionSensors,
"PositionSensors", sens_index, name);
455 return genericGetFrameName(m_sensorsMetadata.
PositionSensors,
"PositionSensors", sens_index, frameName);
472 return genericGetStatus();
477 return genericGetName(m_sensorsMetadata.
LinearVelocitySensors,
"LinearVelocitySensors", sens_index, name);
482 return genericGetFrameName(m_sensorsMetadata.
LinearVelocitySensors,
"LinearVelocitySensors", sens_index, frameName);
499 return genericGetStatus();
504 return genericGetName(m_sensorsMetadata.
TemperatureSensors,
"TemperatureSensors", sens_index, name);
509 return genericGetFrameName(m_sensorsMetadata.
TemperatureSensors,
"TemperatureSensors", sens_index, frameName);
535 return genericGetStatus();
545 return genericGetFrameName(m_sensorsMetadata.
SixAxisForceTorqueSensors,
"SixAxisForceTorqueSensors", sens_index, frameName);
563 return genericGetStatus();
568 return genericGetName(m_sensorsMetadata.
ContactLoadCellArrays,
"ContactLoadCellArrays", sens_index, name);
592 return genericGetStatus();
597 return genericGetName(m_sensorsMetadata.
EncoderArrays,
"EncoderArrays", sens_index, name);
602 return genericGetMeasure(m_sensorsMetadata.
EncoderArrays,
"EncoderArrays",
608 return genericGetSize(m_sensorsMetadata.
EncoderArrays,
"EncoderArrays",
614 num = genericGetNrOfSensors(m_sensorsMetadata.
SkinPatches,
621 return genericGetStatus();
626 return genericGetName(m_sensorsMetadata.
SkinPatches,
"SkinPatches", sens_index, name);
631 return genericGetMeasure(m_sensorsMetadata.
SkinPatches,
"SkinPatches",
637 return genericGetSize(m_sensorsMetadata.
SkinPatches,
"SkinPatches",
#define ReturnValue_error_method_failed
#define ReturnValue_error_not_ready
#define ReturnValue_error_input_out_of_bounds
bool m_externalConnection
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
yarp::dev::MAS_status getContactLoadCellArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the gyroscope.
yarp::dev::ReturnValue getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getTemperatureSensorMeasure(size_t sens_index, double &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getNrOfThreeAxisMagnetometers(size_t &num) const override
Get the number of magnetometers exposed by this device.
yarp::dev::MAS_status getThreeAxisAngularAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::MAS_status getSixAxisForceTorqueSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getSixAxisForceTorqueSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double ×tamp) const override
Get the last reading of the position sensor as x y z.
yarp::dev::ReturnValue getTemperatureSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getLinearVelocitySensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double ×tamp) const override
Get the last reading of the linear velocity sensor as x y z.
yarp::dev::ReturnValue getThreeAxisAngularAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getNrOfThreeAxisGyroscopes(size_t &num) const override
Get the number of three axis gyroscopes exposed by this sensor.
yarp::dev::ReturnValue getNrOfSixAxisForceTorqueSensors(size_t &num) const override
Get the number of six axis force torque sensors exposed by this device.
yarp::dev::ReturnValue getNrOfEncoderArrays(size_t &num) const override
Get the number of encoder arrays exposed by this device.
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getSkinPatchName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getNrOfTemperatureSensors(size_t &num) const override
Get the number of temperature sensors exposed by this device.
yarp::dev::ReturnValue getThreeAxisAngularAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getEncoderArraySize(size_t sens_index) const override
Get the size of the specified encoder array.
yarp::dev::ReturnValue getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getLinearVelocitySensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getSixAxisForceTorqueSensorFrameName(size_t sens_index, std::string &frame) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getNrOfContactLoadCellArrays(size_t &num) const override
Get the number of contact load cell array exposed by this device.
yarp::dev::ReturnValue getNrOfOrientationSensors(size_t &num) const override
Get the number of orientation sensors exposed by this device.
yarp::dev::ReturnValue getTemperatureSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getThreeAxisAngularAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
size_t getContactLoadCellArraySize(size_t sens_index) const override
Get the size of the specified contact load cell array.
yarp::dev::ReturnValue getSixAxisForceTorqueSensorMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch.
yarp::dev::MAS_status getLinearVelocitySensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getEncoderArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getNrOfLinearVelocitySensors(size_t &num) const override
Get the number of linear velocity sensors exposed by this device.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getNrOfThreeAxisLinearAccelerometers(size_t &num) const override
Get the number of three axis linear accelerometers exposed by this device.
yarp::dev::ReturnValue getNrOfPositionSensors(size_t &num) const override
Get the number of position sensors exposed by this device.
yarp::dev::ReturnValue getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getContactLoadCellArrayName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getNrOfThreeAxisAngularAccelerometers(size_t &num) const override
Get the number of three axis angular accelerometers exposed by this device.
yarp::dev::ReturnValue getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getNrOfSkinPatches(size_t &num) const override
Get the number of skin patches exposed by this device.
yarp::dev::MAS_status getTemperatureSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
yarp::dev::ReturnValue getLinearVelocitySensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getContactLoadCellArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::ReturnValue getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
yarp::dev::ReturnValue getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
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
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
void close() override
Stop port activity.
BufferedPort()
Constructor.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
bool attachAsClient(yarp::os::UnbufferedContactable &port)
Tag this WireLink as a client, sending data via the specified port.
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
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_TIMEOUT
The sensor is read through the network, and the latest measurement was received before an implementat...
@ MAS_OK
The sensor is working correctly.
double now()
Return the current time in seconds, relative to an arbitrary starting point.