YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
laserFromExternalPort_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
7#include <yarp/os/Network.h>
11
12#include <catch2/catch_amalgamated.hpp>
13#include <harness.h>
14
15using namespace yarp::dev;
16using namespace yarp::sig;
17using namespace yarp::os;
18
19TEST_CASE("dev::laserFromExternalPort", "[yarp::dev]")
20{
21 #if defined(DISABLE_FAILING_TESTS)
22 YARP_SKIP_TEST("Skipping failing tests")
23 #endif
24
25 YARP_REQUIRE_PLUGIN("laserFromExternalPort", "device");
26 YARP_REQUIRE_PLUGIN("fakeLaser", "device");
27 YARP_REQUIRE_PLUGIN("rangefinder2D_nws_yarp", "device");
28
29 Network::setLocalMode(true);
30
31 SECTION("Checking laserFromExternalPort device")
32 {
38
39 // open laser1
40 {
42 pnws_cfg.put("device", "rangefinder2D_nws_yarp");
43 pnws_cfg.put("period", "0.010");
44 pnws_cfg.put("name", "/laser1");
46
48 pdev_cfg.put("device", "fakeLaser");
50
52 bool result_att = ww_nws->attach(&ddfake1);
54 }
55 // open laser2
56 {
58 pnws_cfg.put("device", "rangefinder2D_nws_yarp");
59 pnws_cfg.put("period", "0.010");
60 pnws_cfg.put("name", "/laser2");
62
64 pdev_cfg.put("device", "fakeLaser");
66
68 bool result_att = ww_nws->attach(&ddfake2);
70 }
71
72 IRangefinder2D* irng = nullptr;
73
75 {
77 las_cfg.put("device", "laserFromExternalPort");
78 Property& las_cfg_sensor = las_cfg.addGroup("SENSOR");
79 las_cfg_sensor.put("input_ports_name", "\"(/laser1 /laser2)\"");
80 las_cfg_sensor.put("min_angle", 0.0);
81 las_cfg_sensor.put("max_angle", 360.0);
82 las_cfg_sensor.put("resolution", 1.0);
83 std::string las_cfg_str = las_cfg.toString();
85 REQUIRE(laserdev.view(irng));
86 }
87 yarp::os::Network::connect ("/laser1", "/laserFromExternalPort:i");
88
89 //execute tests
91
92 //"Close all polydrivers and check"
94 }
95
96 Network::setLocalMode(false);
97}
A generic interface for planar laser range finders.
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.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition Network.cpp:682
A class for storing options and configuration information.
Definition Property.h:33
TEST_CASE("dev::laserFromExternalPort", "[yarp::dev]")
void exec_iRangefinder2D_test_1(IRangefinder2D *irf)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.