YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IRangefinder2DTest.h
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#ifndef IRANGEFINDER2DTEST_H
7#define IRANGEFINDER2DTEST_H
8
10#include <catch2/catch_amalgamated.hpp>
11
12using namespace yarp::dev;
13using namespace yarp::sig;
14using namespace yarp::os;
15
16namespace yarp::dev::tests
17{
19 {
20 REQUIRE(irf != nullptr);
21
22 bool b;
23
25 for (size_t counter = 0; counter<10; counter++)
26 {
27 b = irf->getDeviceStatus(status);
28 CHECK(b);
31 }
33
34 std::string info;
35 b = irf->getDeviceInfo(info);
36 CHECK(b);
37 CHECK(info==std::string("Fake Laser device for test/debugging"));
38
39 double scanrate;
40 b = irf->getScanRate(scanrate);
41 CHECK(b);
42 CHECK(scanrate==0.02);
43
44 double hstep;
45 b = irf->getHorizontalResolution(hstep);
46 CHECK(b);
47 CHECK(hstep==1.0);
48
49 double min,max;
50 b = irf->getDistanceRange(min,max);
51 CHECK(b);
52 CHECK(min == 0.1);
53 CHECK(max == 8.0);
54
55 std::vector<yarp::sig::LaserMeasurementData> las;
56 double timestamp;
57 b = irf->getLaserMeasurement(las, &timestamp);
58 CHECK(b);
59 CHECK(timestamp != 0);
60 CHECK(las.size() == 360);
61
62 //check the measurement values.
63 //REQUIRE is needed to prevent segfault if nothing is received.
64 {
65 REQUIRE(las.size() > 0);
66 double r,t;
67 las[0].get_polar(r, t);
68 CHECK(r == 0.5);
69 CHECK(t == 0);
70 }
71 {
72 REQUIRE(las.size() > 0);
73 double x,y;
74 las[0].get_cartesian(x, y);
75 CHECK(x == 0.5);
76 CHECK(y == 0);
77 }
78
79 }
80}
81
82#endif
A generic interface for planar laser range finders.
A mini-server for performing network communication in the background.
void exec_iRangefinder2D_test_1(IRangefinder2D *irf)
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.