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>
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::laserFromExternalPort", "[yarp::dev]")
22{
23 YARP_REQUIRE_PLUGIN("laserFromExternalPort", "device");
24 YARP_REQUIRE_PLUGIN("fakeLaser", "device");
25 YARP_REQUIRE_PLUGIN("rangefinder2D_nws_yarp", "device");
26
27 Network::setLocalMode(true);
28
29 const double test_distance = 0.5;
30
31 SECTION("Checking laserFromExternalPort device")
32 {
38
39 // open laser1
40 {
42 pdev_cfg.put("device", "fakeLaser");
43 pdev_cfg.put("rpc_test_port", "/fakeLaser1/rpc:i");
44 pdev_cfg.put("test", "use_constant");
45 Property& cm_cfg= pdev_cfg.addGroup("CONSTANT_MODE");
46 cm_cfg.put("const_distance", test_distance);
48
50 pnws_cfg.put("device", "rangefinder2D_nws_yarp");
51 pnws_cfg.put("period", "0.010");
52 pnws_cfg.put("name", "/laser1");
54
56 bool result_att = ww_nws->attach(&ddfake1);
58 }
59 // open laser2
60 {
62 pdev_cfg.put("device", "fakeLaser");
63 pdev_cfg.put("rpc_test_port", "/fakeLaser2/rpc:i");
64 pdev_cfg.put("test", "use_constant");
65 Property& cm_cfg= pdev_cfg.addGroup("CONSTANT_MODE");
66 cm_cfg.put("const_distance", test_distance);
68
70 pnws_cfg.put("device", "rangefinder2D_nws_yarp");
71 pnws_cfg.put("period", "0.010");
72 pnws_cfg.put("name", "/laser2");
74
76 bool result_att = ww_nws->attach(&ddfake2);
78 }
79
80 IRangefinder2D* irng = nullptr;
81
83 {
85 las_cfg.put("device", "laserFromExternalPort");
86 Property& las_cfg_sensor = las_cfg.addGroup("SENSOR");
87 las_cfg_sensor.put("input_ports_name", "\"(/laser1 /laser2)\"");
88 las_cfg_sensor.put("min_angle", 0.0);
89 las_cfg_sensor.put("max_angle", 360.0);
90 las_cfg_sensor.put("resolution", 1.0);
91 std::string las_cfg_str = las_cfg.toString();
93 REQUIRE(laserdev.view(irng));
94
95 //@@@not available yet
96 //yarp::dev::tests::exec_params_test(&laserdev);
97 }
98
100 bool b=yarp::os::Network::connect ("/laser1", "/laserFromExternalPort:i");
101 REQUIRE(b);
103
104 //execute tests
106 vals.test_scanrate=0;
107 vals.test_max=30.0;
108 vals.test_min=0.1;
110 vals.test_theta=0.0;
112 vals.test_cartesian_y=0.0;
114
115 //"Close all polydrivers and check"
117 CHECK(ddnws1.close());
118 CHECK(ddnws2.close());
121 }
122
123 Network::setLocalMode(false);
124}
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:751
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, const ValuestoCheck &v=ValuestoCheck())
void wait_safe(const double seconds)
Definition TestUtils.cpp:17
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13