YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
battery_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
6#include <yarp/os/Network.h>
7#include <yarp/os/LogStream.h>
10
11#include <catch2/catch_amalgamated.hpp>
12#include <harness.h>
13
14using namespace yarp::dev;
15using namespace yarp::os;
16
17TEST_CASE("dev::battery_nws_ros2_test", "[yarp::dev]")
18{
19 YARP_REQUIRE_PLUGIN("battery_nws_ros2", "device");
20 YARP_REQUIRE_PLUGIN("fakeBattery", "device");
21
22 Network::setLocalMode(true);
23
24 SECTION("Checking the nws alone")
25 {
27
29 {
31 pcfg.put("device", "battery_nws_ros2");
32 pcfg.put("node_name", "battery_node");
33 pcfg.put("topic_name","/robot_battery");
35 }
36
37 //"Close all polydrivers and check"
38 {
39 CHECK(ddnws.close());
40 }
41 }
42
43 SECTION("Checking the nws attached to device")
44 {
48
50 {
52 pcfg.put("device", "battery_nws_ros2");
53 pcfg.put("node_name", "battery_node");
54 pcfg.put("topic_name","/robot_battery");
56 }
57
59 {
61 pcfg_fake.put("device", "fakeBattery");
63 }
64
65 //attach the nws to the fake device
66 {
67 ddnws.view(ww_nws);
68 bool result_att = ww_nws->attach(&ddfake);
70 }
71
72 //"Close all polydrivers and check"
73 {
74 CHECK(ddnws.close());
76 }
77 }
78
79 Network::setLocalMode(false);
80}
TEST_CASE("dev::battery_nws_ros2_test", "[yarp::dev]")
A container for a device driver.
Definition PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
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
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.