YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IFrameTransformStorageTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IFRAMETRANSFORMSTORAGETEST_H
7#define IFRAMETRANSFORMSTORAGETEST_H
8
9#define _USE_MATH_DEFINES
10#include <math.h>
11
12#include <yarp/sig/Matrix.h>
13#include <yarp/sig/Vector.h>
16#include <yarp/os/Network.h>
17#include <yarp/os/Time.h>
18#include <yarp/os/LogStream.h>
19
20#include <yarp/math/Math.h>
22
23#include <cmath>
24#include <vector>
25
26#include <catch2/catch_amalgamated.hpp>
27
28using namespace yarp::os;
29using namespace yarp::dev;
30using namespace yarp::math;
31
32namespace yarp::dev::tests
33{
34 inline bool isEqual(const yarp::sig::Vector& v1, const yarp::sig::Vector& v2, double precision)
35 {
36 if (v1.size() != v2.size())
37 {
38 return false;
39 }
40
41 for (size_t i = 0; i < v1.size(); i++)
42 {
43 double check = fabs(v1[i] - v2[i]);
44 if (check > precision)
45 {
46 return false;
47 }
48 }
49 return true;
50 }
51
53 {
54 yarp::sig::Vector v1 = q1.toVector();
55 yarp::sig::Vector v2 = q2.toVector();
56
57 for (size_t i = 0; i < v1.size(); i++)
58 {
59 double check = fabs(v1[i] - v2[i]);
60 if (check > precision)
61 {
62 return false;
63 }
64 }
65 return true;
66 }
67
68 inline bool isEqual(const yarp::sig::Matrix& m1, const yarp::sig::Matrix& m2, double precision)
69 {
70 if (m1.cols() != m2.cols() || m1.rows() != m2.rows())
71 {
72 return false;
73 }
74
75 for (size_t i = 0; i < m1.rows(); i++)
76 {
77 if (!isEqual(m1.getRow(i), m2.getRow(i), precision))
78 {
79 return false;
80 }
81 }
82 return true;
83 }
84
88 {
89 if (itfSet)
90 {
91 CHECK(itfSet->clearAll());
92 }
93 if (itfGet)
94 {
95 std::vector<yarp::math::FrameTransform> transforms;
96 CHECK(itfGet->getTransforms(transforms));
97 }
98 if (itfUtils)
99 {
100 size_t siz;
101 CHECK(itfUtils->size(siz));
102 }
103 }
104
105}
106
107#endif
contains the definition of a Matrix type
contains the definition of a Vector type
A mini-server for performing network communication in the background.
A class for a Matrix.
Definition Matrix.h:39
bool isEqual(const yarp::sig::Vector &v1, const yarp::sig::Vector &v2, double precision)
void exec_frameTransformStorage_test_1(IFrameTransformStorageSet *itfSet, IFrameTransformStorageGet *itfGet, IFrameTransformStorageUtils *itfUtils)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.