YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SM_to_vec.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
6#include "SM_to_vec.h"
7
8#include <algorithm>
9#include <cmath>
10
12#include "SensorStreamingData.h"
13
14using namespace yarp::os;
15using namespace yarp::sig;
16
17namespace {
19 "yarp.carrier.portmonitor.sensorMeasurements_to_vector",
23 nullptr)
24}
25
26
28{
29 return true;
30}
31
35
37{
38 return false;
39}
40
42{
43 return false;
44}
45
47{
49 if(ssd == nullptr ||
50 ssd->OrientationSensors.measurements.size() != 1 ||
51 ssd->OrientationSensors.measurements[0].measurement.size() != 3 ||
52 ssd->PositionSensors.measurements.size() != 1 ||
53 ssd->PositionSensors.measurements[0].measurement.size() != 3)
54 {
55 yCError(SM2VEC, "SensorMeasurements_to_vector: received invalid data type!");
56 return false;
57 }
58
59 out.resize(3 + 3);
60 return true;
61}
62
64{
66 const size_t sensor_id = 0;
67 if (ssd)
68 {
69 out[0] = ssd->PositionSensors.measurements[sensor_id].measurement[0];
70 out[1] = ssd->PositionSensors.measurements[sensor_id].measurement[1];
71 out[2] = ssd->PositionSensors.measurements[sensor_id].measurement[2];
72 out[3] = ssd->OrientationSensors.measurements[sensor_id].measurement[0];
73 out[4] = ssd->OrientationSensors.measurements[sensor_id].measurement[1];
74 out[5] = ssd->OrientationSensors.measurements[sensor_id].measurement[2];
75 }
76
77 th.setPortWriter(&out);
78 return th;
79}
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
Definition SM_to_vec.cpp:46
bool setparam(const yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
Definition SM_to_vec.cpp:36
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
Definition SM_to_vec.cpp:63
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
Definition SM_to_vec.cpp:27
void destroy() override
This will be called when the portmonitor object destroyes.
Definition SM_to_vec.cpp:32
bool getparam(yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
Definition SM_to_vec.cpp:41
A mini-server for performing network communication in the background.
static LogCallback printCallback()
Get current print callback.
Definition Log.cpp:873
static LogType minimumPrintLevel()
Get current minimum print level.
Definition Log.cpp:833
@ LogTypeReserved
Definition Log.h:98
A class for storing options and configuration information.
Definition Property.h:33
Base class for generic things.
Definition Things.h:18
T * cast_as()
Definition Things.h:53
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
Definition Things.cpp:26
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface to the operating system, including Port based communication.