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
13
14using namespace yarp::os;
15using namespace yarp::sig;
16using namespace yarp::dev;
17
18namespace {
20 "yarp.carrier.portmonitor.sensorMeasurements_to_vector",
24 nullptr)
25}
26
27
29{
30 return true;
31}
32
36
38{
39 return false;
40}
41
43{
44 return false;
45}
46
48{
50 if(ssd == nullptr ||
51 ssd->OrientationSensors.measurements.size() != 1 ||
52 ssd->OrientationSensors.measurements[0].measurement.size() != 3 ||
53 ssd->PositionSensors.measurements.size() != 1 ||
54 ssd->PositionSensors.measurements[0].measurement.size() != 3)
55 {
56 yCError(SM2VEC, "SensorMeasurements_to_vector: received invalid data type!");
57 return false;
58 }
59
60 out.resize(3 + 3);
61 return true;
62}
63
65{
67 const size_t sensor_id = 0;
68 if (ssd)
69 {
70 out[0] = ssd->PositionSensors.measurements[sensor_id].measurement[0];
71 out[1] = ssd->PositionSensors.measurements[sensor_id].measurement[1];
72 out[2] = ssd->PositionSensors.measurements[sensor_id].measurement[2];
73 out[3] = ssd->OrientationSensors.measurements[sensor_id].measurement[0];
74 out[4] = ssd->OrientationSensors.measurements[sensor_id].measurement[1];
75 out[5] = ssd->OrientationSensors.measurements[sensor_id].measurement[2];
76 }
77
78 th.setPortWriter(&out);
79 return th;
80}
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
Definition SM_to_vec.cpp:47
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:37
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:64
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:28
void destroy() override
This will be called when the portmonitor object destroyes.
Definition SM_to_vec.cpp:33
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:42
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:211
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.