YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
multipleAnalogSensorsServer_test.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
8
9#include <yarp/os/Time.h>
10#include <yarp/dev/PolyDriver.h>
13
14#include <cmath>
15#include <chrono>
16#include <thread>
17
18#include <catch2/catch_amalgamated.hpp>
19#include <harness.h>
20
21using namespace yarp::os;
22using namespace yarp::dev;
23
24
25TEST_CASE("dev::MultipleAnalogSensorsServerTest", "[yarp::dev]")
26{
27 YARP_REQUIRE_PLUGIN("fakeIMU", "device");
28 YARP_REQUIRE_PLUGIN("multipleanalogsensorsserver", "device");
29
30//#if defined(DISABLE_FAILING_TESTS)
31// YARP_SKIP_TEST("Skipping failing tests")
32//#endif
33
34 Network::setLocalMode(true);
35
36 SECTION("Test the nws alone")
37 {
39
41 pWrapper.put("device", "multipleanalogsensorsserver");
42 std::string serverPrefix = "/test/mas/server";
43 pWrapper.put("name", serverPrefix);
44 pWrapper.put("period", 10);
45 REQUIRE(wrapper.open(pWrapper)); // multipleanalogsensorsserver open reported successful
46
47 // Close devices
48 wrapper.close();
49 }
50
51 SECTION("Test the multiple analog sensors device on a single IMU (deferred attach)")
52 {
53 // We first allocate a single fakeImu
56
57 Property p;
58 p.put("device", "fakeIMU");
59 p.put("constantValue", 1);
60
61 REQUIRE(imuSensor.open(p)); // sensor open reported successful
62
64 REQUIRE(imuSensor.view(orientSens)); // IOrientationSensors of fakeIMU correctly opened
66 int nrOfSensors = orientSens->getNrOfOrientationSensors();
67 CHECK(nrOfSensors == 1); // getNrOfOrientationSensors of fakeIMU works correctly
68
70 pWrapper.put("device", "multipleanalogsensorsserver");
71 std::string serverPrefix = "/test/mas/server";
72 pWrapper.put("name", serverPrefix);
73 pWrapper.put("period", 10);
74 REQUIRE(wrapper.open(pWrapper)); // multipleanalogsensorsserver open reported successful
75
77 REQUIRE(wrapper.view(iwrap)); // IMultipleWrapper interface correctly opened for the multipleanalogsensorsserver
79
81 pdList.push(&imuSensor, "pdlist_key");
82 REQUIRE(iwrap->attachAll(pdList)); // multipleanalogsensorsserver attached successfully to the device
83
84 // Close devices
85 iwrap->detachAll();
86 wrapper.close();
88 }
89
90 Network::setLocalMode(false);
91}
Interface for an object that can wrap/attach to to another.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
A container for a device driver.
Definition PolyDriver.h:23
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A class for storing options and configuration information.
Definition Property.h:33
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition Property.cpp:987
TEST_CASE("dev::MultipleAnalogSensorsServerTest", "[yarp::dev]")
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.