YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RGBDSensor_nwc_yarp_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/os/Network.h>
13
14#include <catch2/catch_amalgamated.hpp>
15#include <harness.h>
16
17using namespace yarp::dev;
18using namespace yarp::sig;
19using namespace yarp::os;
20
21TEST_CASE("dev::RGBDSensor_nwc_yarp", "[yarp::dev]")
22{
23 YARP_REQUIRE_PLUGIN("fakeDepthCamera", "device");
24 YARP_REQUIRE_PLUGIN("fakeDepthCamera_mini", "device");
25 YARP_REQUIRE_PLUGIN("RGBDSensor_nws_yarp", "device");
26 YARP_REQUIRE_PLUGIN("RGBDSensor_nwc_yarp", "device");
27
28 Network::setLocalMode(true);
29
30 //fakeDepthCamera_mini only has IRGBDSensor
31 SECTION("Checking RGBDSensor_nwc_yarp device with fakeDepthCamera_mini")
32 {
36 IRGBDSensor* irgbd = nullptr;
37
39 {
41 pdepth_cfg.put("device", "fakeDepthCamera_mini");
42 // small values to improve valgrind speed
43 pdepth_cfg.put("rgb_w", 32);
44 pdepth_cfg.put("rgb_h", 24);
45 pdepth_cfg.put("dep_w", 32);
46 pdepth_cfg.put("dep_h", 24);
48 }
49 {
51 pnws_cfg.put("device", "RGBDSensor_nws_yarp");
52 pnws_cfg.put("name", "/rgbd_nws");
54 }
55
56 // attach the nws to the fakeDepthCamera device
57 {
59 ddnws.view(ww_nws);
61 bool result_att = ww_nws->attach(&dddepth);
63 }
64
65 // wait some time
67 INFO("rgbdSensor_nws_yarp and fakeDepthCamera ready");
68
69 // create the nwc
70 {
72 pnwc_cfg.put("device", "RGBDSensor_nwc_yarp");
73 pnwc_cfg.put("localImagePort", "/rgbd_nwc/rgbImage:i");
74 pnwc_cfg.put("remoteImagePort", "/rgbd_nws/rgbImage:o");
75
76 pnwc_cfg.put("localDepthPort", "/rgbd_nwc/depthImage:i");
77 pnwc_cfg.put("remoteDepthPort", "/rgbd_nws/depthImage:o");
78
79 pnwc_cfg.put("localRpcPort", "/rgbd_nwc/rpc:o");
80 pnwc_cfg.put("remoteRpcPort", "/rgbd_nws/rpc:i");
81
82 // beware: default carrier is udp, but we do not want to use it for tests
83 // since it may fail on the cloud CI.
84 pnwc_cfg.put("ImageCarrier", "fast_tcp");
85 pnwc_cfg.put("DepthCarrier", "fast_tcp");
87 }
88 REQUIRE(ddnwc.view(irgbd));
89
90 // wait some time
92 INFO("RGBDSensor_nwc_yarp ready");
93
94 // execute tests
96
97 // Close all polydrivers and check
98 CHECK(ddnwc.close());
100 INFO("RGBDSensor_nwc_yarp closed");
101
102 CHECK(ddnws.close());
104 INFO("RGBDSensor_nws_yarp closed");
105
108 INFO("fakeDepthCamera closed");
109
110 INFO("Test complete");
111 }
112
113 // fakeDepthCamera has IRGBDSensor AND IFrameGrabberControls
114 SECTION("Checking RGBDSensor_nwc_yarp device with fakeDepthCamera")
115 {
119 IRGBDSensor* irgbd = nullptr;
120 IFrameGrabberControls* ictl = nullptr;
121
123 {
125 pdepth_cfg.put("device", "fakeDepthCamera");
126 // small values to improve valgrind speed
127 pdepth_cfg.put("rgb_w", 32);
128 pdepth_cfg.put("rgb_h", 24);
129 pdepth_cfg.put("dep_w", 32);
130 pdepth_cfg.put("dep_h", 24);
132 }
133 {
135 pnws_cfg.put("device", "RGBDSensor_nws_yarp");
136 pnws_cfg.put("name", "/rgbd_nws");
138 }
139
140 //attach the nws to the fakeDepthCamera device
141 {yarp::dev::WrapperSingle* ww_nws = nullptr; ddnws.view(ww_nws);
143 bool result_att = ww_nws->attach(&dddepth);
145
146 //wait some time
148 INFO("rgbdSensor_nws_yarp and fakeDepthCamera ready");
149
150 //create the nwc
151 {
153 pnwc_cfg.put("device", "RGBDSensor_nwc_yarp");
154 pnwc_cfg.put("localImagePort", "/rgbd_nwc/rgbImage:i");
155 pnwc_cfg.put("remoteImagePort", "/rgbd_nws/rgbImage:o");
156
157 pnwc_cfg.put("localDepthPort", "/rgbd_nwc/depthImage:i");
158 pnwc_cfg.put("remoteDepthPort", "/rgbd_nws/depthImage:o");
159
160 pnwc_cfg.put("localRpcPort", "/rgbd_nwc/rpc:o");
161 pnwc_cfg.put("remoteRpcPort", "/rgbd_nws/rpc:i");
162
163 //beware: default carrier is udp, but we do not want to use it for tests
164 //since it may fail on the cloud CI.
165 pnwc_cfg.put("ImageCarrier", "fast_tcp");
166 pnwc_cfg.put("DepthCarrier", "fast_tcp");
168 }
169 REQUIRE(ddnwc.view(irgbd));
170 REQUIRE(ddnwc.view(ictl));
171
172 // wait some time
174 INFO("RGBDSensor_nwc_yarp ready");
175
176 //execute tests
179
180 //Close all polydrivers and check
181 CHECK(ddnwc.close());
183 INFO("RGBDSensor_nwc_yarp closed");
184
185 CHECK(ddnws.close());
187 INFO("RGBDSensor_nws_yarp closed");
188
191 INFO("fakeDepthCamera closed");
192
193 INFO("Test complete");
194 }
195
196 Network::setLocalMode(false);
197}
TEST_CASE("dev::RGBDSensor_nwc_yarp", "[yarp::dev]")
Control interface for frame grabber devices.
A generic interface for cameras that have both color camera as well as depth camera sensor,...
Definition IRGBDSensor.h:39
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
static void delaySystem(double seconds)
void exec_IFrameGrabberControls_test_1(IFrameGrabberControls *ictl)
void exec_iRGBDSensor_test_1(IRGBDSensor *irgbd)
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.
std::string INFO
Definition ymanager.cpp:51