YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
multipleanalogsensors_nws_ros2_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 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::MultipleAnalogSensors_nws_ros2_test", "[yarp::dev]")
26{
27 YARP_REQUIRE_PLUGIN("fakeIMU", "device");
28 YARP_REQUIRE_PLUGIN("wrenchStamped_nws_ros2", "device");
29 YARP_REQUIRE_PLUGIN("imu_nws_ros2", "device");
30
31//#if defined(DISABLE_FAILING_TESTS)
32// YARP_SKIP_TEST("Skipping failing tests")
33//#endif
34
35 Network::setLocalMode(true);
36
37 SECTION("Test the nws alone")
38 {
40
42 pWrapper.put("device", "imu_nws_ros2");
43 pWrapper.put("node_name", "imu_node");
44 pWrapper.put("topic_name", "/imu_topic");
45 pWrapper.put("period", 0.01);
46 REQUIRE(wrapper.open(pWrapper)); // multipleanalogsensorsserver open reported successful
47
48 // Close devices
49 wrapper.close();
50 }
51
52 SECTION("Test the multiple analog sensors device on a single IMU (deferred attach)")
53 {
54 // We first allocate a single fakeImu
57
58 Property p;
59 p.put("device", "fakeIMU");
60 p.put("constantValue", 1);
61
62 REQUIRE(imuSensor.open(p)); // sensor open reported successful
63
65 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", "imu_nws_ros2");
71 pWrapper.put("node_name", "imu_node");
72 pWrapper.put("topic_name", "/imu_topic");
73 pWrapper.put("period", 0.01);
74 REQUIRE(wrapper.open(pWrapper)); // multipleanalogsensorsserver open reported successful
75
77 REQUIRE(wrapper.view(iwrap)); // IMultipleWrapper interface correctly opened for the multipleanalogsensorsserver
78
80 pdList.push(&imuSensor, "pdlist_key");
81 REQUIRE(iwrap->attachAll(pdList)); // multipleanalogsensorsserver attached successfully to the device
82
83 // Close devices
84 iwrap->detachAll();
85 wrapper.close();
87 }
88
89 Network::setLocalMode(false);
90}
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::MultipleAnalogSensors_nws_ros2_test", "[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.