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
15#include <catch2/catch_amalgamated.hpp>
16#include <harness.h>
17
18using namespace yarp::dev;
19using namespace yarp::sig;
20using namespace yarp::os;
21
22TEST_CASE("dev::RGBDSensor_nwc_yarp", "[yarp::dev]")
23{
24 YARP_REQUIRE_PLUGIN("fakeDepthCamera", "device");
25 YARP_REQUIRE_PLUGIN("fakeDepthCamera_mini", "device");
26 YARP_REQUIRE_PLUGIN("RGBDSensor_nws_yarp", "device");
27 YARP_REQUIRE_PLUGIN("RGBDSensor_nwc_yarp", "device");
28
29 Network::setLocalMode(true);
30
31 //fakeDepthCamera_mini only has IRGBDSensor
32 SECTION("Checking RGBDSensor_nwc_yarp device with fakeDepthCamera_mini")
33 {
37 IRGBDSensor* irgbd = nullptr;
38
40 {
42 pdepth_cfg.put("device", "fakeDepthCamera_mini");
43 // small values to improve valgrind speed
44 pdepth_cfg.put("rgb_w", 32);
45 pdepth_cfg.put("rgb_h", 24);
46 pdepth_cfg.put("dep_w", 32);
47 pdepth_cfg.put("dep_h", 24);
49 }
50 {
52 pnws_cfg.put("device", "RGBDSensor_nws_yarp");
53 pnws_cfg.put("name", "/rgbd_nws");
55 }
56
57 // attach the nws to the fakeDepthCamera device
58 {
60 ddnws.view(ww_nws);
62 bool result_att = ww_nws->attach(&dddepth);
64 }
65
66 // wait some time
68 INFO("RGBDSensor_nws_yarp and fakeDepthCamera ready");
69
70 // create the nwc
71 {
73 pnwc_cfg.put("device", "RGBDSensor_nwc_yarp");
74 pnwc_cfg.put("localImagePort", "/rgbd_nwc/rgbImage:i");
75 pnwc_cfg.put("remoteImagePort", "/rgbd_nws/rgbImage:o");
76
77 pnwc_cfg.put("localDepthPort", "/rgbd_nwc/depthImage:i");
78 pnwc_cfg.put("remoteDepthPort", "/rgbd_nws/depthImage:o");
79
80 pnwc_cfg.put("localRpcPort", "/rgbd_nwc/rpc:o");
81 pnwc_cfg.put("remoteRpcPort", "/rgbd_nws/rpc:i");
82
83 // beware: default carrier is udp, but we do not want to use it for tests
84 // since it may fail on the cloud CI.
85 pnwc_cfg.put("ImageCarrier", "fast_tcp");
86 pnwc_cfg.put("DepthCarrier", "fast_tcp");
88 }
89 REQUIRE(ddnwc.view(irgbd));
90
91 // wait some time
93 INFO("RGBDSensor_nwc_yarp ready");
94
95 // execute tests
97
98 // Close all polydrivers and check
99 CHECK(ddnwc.close());
101 INFO("RGBDSensor_nwc_yarp closed");
102
103 CHECK(ddnws.close());
105 INFO("RGBDSensor_nws_yarp closed");
106
109 INFO("fakeDepthCamera closed");
110
111 INFO("Test complete");
112 }
113
114 // fakeDepthCamera has IRGBDSensor AND IFrameGrabberControls
115 SECTION("Checking RGBDSensor_nwc_yarp device with fakeDepthCamera")
116 {
120 IRGBDSensor* irgbd = nullptr;
121 IFrameGrabberControls* ictl = nullptr;
122
124 {
126 pdepth_cfg.put("device", "fakeDepthCamera");
127 // small values to improve valgrind speed
128 pdepth_cfg.put("rgb_w", 32);
129 pdepth_cfg.put("rgb_h", 24);
130 pdepth_cfg.put("dep_w", 32);
131 pdepth_cfg.put("dep_h", 24);
133 }
134 {
136 pnws_cfg.put("device", "RGBDSensor_nws_yarp");
137 pnws_cfg.put("name", "/rgbd_nws");
139 }
140
141 //attach the nws to the fakeDepthCamera device
142 {yarp::dev::WrapperSingle* ww_nws = nullptr; ddnws.view(ww_nws);
144 bool result_att = ww_nws->attach(&dddepth);
146
147 //wait some time
149 INFO("RGBDSensor_nws_yarp and fakeDepthCamera ready");
150
151 //create the nwc
152 {
154 pnwc_cfg.put("device", "RGBDSensor_nwc_yarp");
155 pnwc_cfg.put("localImagePort", "/rgbd_nwc/rgbImage:i");
156 pnwc_cfg.put("remoteImagePort", "/rgbd_nws/rgbImage:o");
157
158 pnwc_cfg.put("localDepthPort", "/rgbd_nwc/depthImage:i");
159 pnwc_cfg.put("remoteDepthPort", "/rgbd_nws/depthImage:o");
160
161 pnwc_cfg.put("localRpcPort", "/rgbd_nwc/rpc:o");
162 pnwc_cfg.put("remoteRpcPort", "/rgbd_nws/rpc:i");
163
164 //beware: default carrier is udp, but we do not want to use it for tests
165 //since it may fail on the cloud CI.
166 pnwc_cfg.put("ImageCarrier", "fast_tcp");
167 pnwc_cfg.put("DepthCarrier", "fast_tcp");
170 }
171 REQUIRE(ddnwc.view(irgbd));
172 REQUIRE(ddnwc.view(ictl));
173
174 // wait some time
176 INFO("RGBDSensor_nwc_yarp ready");
177
178 //execute tests
181
182 //Close all polydrivers and check
183 CHECK(ddnwc.close());
185 INFO("RGBDSensor_nwc_yarp closed");
186
187 CHECK(ddnws.close());
189 INFO("RGBDSensor_nws_yarp closed");
190
193 INFO("fakeDepthCamera closed");
194
195 INFO("Test complete");
196 }
197
198 Network::setLocalMode(false);
199}
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:32
static void delaySystem(double seconds)
void exec_params_test(yarp::dev::PolyDriver *pdrv)
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:54