YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IPositionSensorsTest.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 IPOSITIONSENSOTSTEST_H
7#define IPOSITIONSENSOTSTEST_H
8
10#include <catch2/catch_amalgamated.hpp>
11
12using namespace yarp::dev;
13using namespace yarp::os;
14
15namespace yarp::dev::tests
16{
18 {
19 REQUIRE(ios != nullptr);
20
21 size_t nrOfSensors = 0;
22 auto ret = ios->getNrOfPositionSensors(nrOfSensors);
23 CHECK(ret);
24 CHECK(nrOfSensors == 1); // getNrOfPositionSensors of multipleanalogsensorsclient works correctly
25
27 double timestamp{ 0.0 }, clientTimestamp{ 0.0 };
28
29 MAS_status status = ios->getPositionSensorStatus(0);
30 CHECK(status == MAS_status::MAS_OK); // multipleanalogsensorsclient getPositionSensorStatus return value is MAS_OK
31
32 bool result = ios->getPositionSensorMeasure(0, sensorMeasure, timestamp);
34
35 CHECK(result == resultClient); // getPositionSensorMeasure return value is consistent between sensor and client
36
37 for (int i = 0; i < 3; i++) {
38 CHECK(sensorMeasure[i] == Catch::Approx(clientMeasure[i])); // getPositionSensorMeasure measure is consistent between sensor and client
39 }
40
41 CHECK(std::abs(timestamp - clientTimestamp) < 0.2); // getOrientationSensorMeasureAsRollPitchYaw measure is consistent between sensor and client (up to 200 ms)
42
43 std::string name;
44 result = ios->getPositionSensorName(0,name);
45 CHECK(result);
46 CHECK(!name.empty());
47
48 result = ios->getPositionSensorFrameName(0,name);
49 CHECK(result);
50 CHECK(!name.empty());
51 }
52}
53
54#endif
Device interface to one or multiple position sensors, such as UWB localization sensors.
virtual yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const =0
Get the status of the specified sensor.
virtual yarp::dev::ReturnValue getPositionSensorName(size_t sens_index, std::string &name) const =0
Get the name of the specified sensor.
virtual yarp::dev::ReturnValue getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const =0
Get the last reading of the position sensor as x y z.
virtual yarp::dev::ReturnValue getPositionSensorFrameName(size_t sens_index, std::string &frameName) const =0
Get the name of the frame of the specified sensor.
virtual yarp::dev::ReturnValue getNrOfPositionSensors(size_t &num) const =0
Get the number of position sensors exposed by this device.
A mini-server for performing network communication in the background.
void exec_IPositionSensors_test_1(IPositionSensors *ios)
For streams capable of holding different kinds of content, check what they actually have.
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_OK
The sensor is working correctly.
An interface to the operating system, including Port based communication.