RobotsIO
Loading...
Searching...
No Matches
YarpVectorOfProbe.hpp
1/*
2 * Copyright (C) 2019 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#ifndef ROBOTSIO_YARPVECTOROFPROBE_H
9#define ROBOTSIO_YARPVECTOROFPROBE_H
10
11#include <Eigen/Dense>
12
13#include <RobotsIO/Utils/Data.h>
14#include <RobotsIO/Utils/Probe.h>
15#include <RobotsIO/Utils/TransformWithVelocity.h>
16#include <RobotsIO/Utils/YarpBufferedPort.hpp>
17#include <RobotsIO/Utils/any.h>
18
19#include <opencv2/opencv.hpp>
20
21#include <string>
22
23#include <yarp/eigen/Eigen.h>
24#include <yarp/sig/Vector.h>
25
26namespace RobotsIO {
27 namespace Utils {
28 template <class T, class U = yarp::sig::VectorOf<T>>
29 class YarpVectorOfProbe;
30 }
31}
32
33
34template <class T, class U>
37{
38public:
39 YarpVectorOfProbe(const std::string& port_name);
40
41 virtual ~YarpVectorOfProbe();
42
43protected:
44 void on_new_data() override;
45
46private:
47 yarp::sig::VectorOf<T> convert_from(const U& data);
48
49 yarp::sig::VectorOf<T> data_;
50
51 const std::string log_name_ = "YarpVectorOfProbe";
52};
53
54
55template <class T, class U>
57 YarpBufferedPort<yarp::sig::VectorOf<T>>(port_name)
58{}
59
60
61template <class T, class U>
63{}
64
65
66template <class T, class U>
68{
69 data_ = convert_from(RobotsIO::Utils::any_cast<U>(get_data()));
70
71 this->send_data(data_);
72}
73
74
75template <class T, class U>
76yarp::sig::VectorOf<T> RobotsIO::Utils::YarpVectorOfProbe<T, U>::convert_from(const U& data)
77{
78 return data;
79}
80
81
82template <>
83yarp::sig::VectorOf<double> RobotsIO::Utils::YarpVectorOfProbe<double, Eigen::VectorXd>::convert_from(const Eigen::VectorXd& data);
84
85
86template <>
87yarp::sig::VectorOf<double> RobotsIO::Utils::YarpVectorOfProbe<double, Eigen::Transform<double, 3, Eigen::Affine>>::convert_from(const Eigen::Transform<double, 3, Eigen::Affine>& data);
88
89
90template <>
92
93template <>
94yarp::sig::VectorOf<int> RobotsIO::Utils::YarpVectorOfProbe<int, cv::Rect>::convert_from(const cv::Rect& data);
95
96#endif /* ROBOTSIO_YARPVECTOROFPROBE_H */