Skip to content

Commit

Permalink
removed option --subdevice from serveral tests. Attach operation is n…
Browse files Browse the repository at this point in the history
…ow performed externally.
  • Loading branch information
randaz81 committed Nov 15, 2022
1 parent 8e02b9e commit a5c6771
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 32 deletions.
37 changes: 24 additions & 13 deletions tests/libYARP_dev/ControlBoardNwsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <yarp/os/Network.h>
#include <yarp/dev/ControlBoardInterfaces.h>
#include <yarp/dev/IMultipleWrapper.h>
#include <yarp/dev/WrapperSingle.h>

#include <string>

Expand All @@ -29,21 +30,30 @@ TEST_CASE("dev::controlBoard_nws_yarp", "[yarp::dev]")

SECTION("test the controlBoard_nws_yarp device")
{
PolyDriver dd;
Property p;
p.put("device","controlBoard_nws_yarp");
p.put("subdevice","fakeMotionControl");
p.put("name","/motor");
auto& pg = p.addGroup("GENERAL");
PolyDriver dd_nws;
Property p_nws;
p_nws.put("device", "controlBoard_nws_yarp");
p_nws.put("name", "/motor");
bool result_nws = dd_nws.open(p_nws);
REQUIRE(result_nws);

PolyDriver dd_dev;
Property p_dev;
p_dev.put("device", "fakeMotionControl");
auto& pg = p_dev.addGroup("GENERAL");
pg.put("Joints", 16);
bool result;
result = dd.open(p);
REQUIRE(result); // controlBoard_nws_yarp open reported successful
bool result_dev = dd_dev.open(p_dev);
REQUIRE(result_dev);

yarp::dev::WrapperSingle* ww_nws;
dd_nws.view(ww_nws);
bool result_att = ww_nws->attach(&dd_dev);
REQUIRE(result_att);

// Check if IMultipleWrapper interface is correctly found
yarp::dev::IMultipleWrapper * i_mwrapper=nullptr;
result = dd.view(i_mwrapper);
REQUIRE(result); // IMultipleWrapper view reported successful
bool result_imw = dd_nws.view(i_mwrapper);
REQUIRE(result_imw); // IMultipleWrapper view reported successful
REQUIRE(i_mwrapper != nullptr); // IMultipleWrapper pointer not null

PolyDriver dd2;
Expand All @@ -53,7 +63,7 @@ TEST_CASE("dev::controlBoard_nws_yarp", "[yarp::dev]")
p2.put("local","/motor/client");
p2.put("carrier","tcp");
p2.put("ignoreProtocolCheck","true");
result = dd2.open(p2);
bool result = dd2.open(p2);
REQUIRE(result); // remote_controlboard open reported successful

IPositionControl *pos = nullptr;
Expand All @@ -62,7 +72,8 @@ TEST_CASE("dev::controlBoard_nws_yarp", "[yarp::dev]")
int axes = 0;
pos->getAxes(&axes);
CHECK(axes == 16); // interface seems functional
CHECK(dd.close()); // close dd reported successful
CHECK(dd_nws.close()); // close dd reported successful
CHECK(dd_dev.close()); // close dd reported successful
CHECK(dd2.close()); // close dd2 reported successful
}
}
25 changes: 22 additions & 3 deletions tests/libYARP_dev/Navigation2DnwcTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <yarp/os/Network.h>
#include <yarp/os/LogStream.h>
#include <yarp/dev/PolyDriver.h>
#include <yarp/dev/WrapperSingle.h>

#include <catch.hpp>
#include <harness.h>
Expand Down Expand Up @@ -38,18 +39,25 @@ TEST_CASE("dev::Navigation2DNwcTest", "[yarp::dev]")
{
PolyDriver ddnavserver;
PolyDriver ddmapserver;
PolyDriver ddmapstorage;
PolyDriver ddmapclient;
PolyDriver ddlocserver;
PolyDriver ddnavclient;
PolyDriver ddfakeLocalizer;
PolyDriver ddfakeNavigation;
INavigation2D* inav = nullptr;
IMap2D* imap = nullptr;

////////"Checking opening navigation2DServer and navigation2DClient polydrivers"
{
Property pmapserver_cfg;
pmapserver_cfg.put("device", "map2D_nws_yarp");
pmapserver_cfg.put("subdevice", "map2DStorage");
REQUIRE(ddmapserver.open(pmapserver_cfg));
Property pmapstorage_cfg;
pmapstorage_cfg.put("device", "map2DStorage");
REQUIRE(ddmapstorage.open(pmapstorage_cfg));
{yarp::dev::WrapperSingle* ww_nws; ddmapserver.view(ww_nws);
bool result_att = ww_nws->attach(&ddmapstorage);}

Property pmapclient_cfg;
pmapclient_cfg.put("device", "map2D_nwc_yarp");
Expand All @@ -60,13 +68,21 @@ TEST_CASE("dev::Navigation2DNwcTest", "[yarp::dev]")

Property plocserver_cfg;
plocserver_cfg.put("device", "localization2D_nws_yarp");
plocserver_cfg.put("subdevice", "fakeLocalizer");
REQUIRE(ddlocserver.open(plocserver_cfg));
Property pfakeLocalizer_cfg;
pfakeLocalizer_cfg.put("device", "fakeLocalizer");
REQUIRE(ddfakeLocalizer.open(pfakeLocalizer_cfg));
{yarp::dev::WrapperSingle* ww_nws; ddlocserver.view(ww_nws);
bool result_att = ww_nws->attach(&ddfakeLocalizer); }

Property pnavserver_cfg;
pnavserver_cfg.put("device", "navigation2D_nws_yarp");
pnavserver_cfg.put("subdevice", "fakeNavigation");
REQUIRE(ddnavserver.open(pnavserver_cfg));
Property pfakeNavigation;
pfakeNavigation.put("device", "fakeNavigation");
REQUIRE(ddfakeNavigation.open(pfakeNavigation));
{yarp::dev::WrapperSingle* ww_nws; ddnavserver.view(ww_nws);
bool result_att = ww_nws->attach(&ddfakeNavigation); }

Property pnavclient_cfg;
pnavclient_cfg.put("device", "navigation2D_nwc_yarp");
Expand All @@ -89,6 +105,9 @@ TEST_CASE("dev::Navigation2DNwcTest", "[yarp::dev]")
CHECK(ddlocserver.close());
CHECK(ddmapclient.close());
CHECK(ddmapserver.close());
CHECK(ddmapstorage.close());
CHECK(ddfakeLocalizer.close());
CHECK(ddfakeNavigation.close());
}
}

Expand Down
37 changes: 21 additions & 16 deletions tests/libYARP_dev/TorqueControlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <catch.hpp>
#include <harness.h>
#include <yarp/dev/WrapperSingle.h>

using namespace yarp::os;
using namespace yarp::dev;
Expand All @@ -29,22 +30,25 @@ TEST_CASE("dev::TorqueControl", "[yarp::dev]")

SECTION("test the controlBoard_nws_yarp device")
{
PolyDriver dd;
Property p;
p.put("device","controlBoard_nws_yarp");
p.put("subdevice","fakeMotionControl");
p.put("name","/motor");
auto& pg = p.addGroup("GENERAL");
PolyDriver dd_nws;
Property p_nws;
p_nws.put("device","controlBoard_nws_yarp");
p_nws.put("name", "/motor");
bool result_nws = dd_nws.open(p_nws);
REQUIRE(result_nws);

PolyDriver dd_dev;
Property p_dev;
p_dev.put("device", "fakeMotionControl");
auto& pg = p_dev.addGroup("GENERAL");
pg.put("Joints", 1);
bool result;
result = dd.open(p);
REQUIRE(result); // controlboard_nws_yarp open reported successful
bool result_dev = dd_dev.open(p_dev);
REQUIRE(result_dev);

// Check if IMultipleWrapper interface is correctly found
yarp::dev::IMultipleWrapper * i_mwrapper=nullptr;
result = dd.view(i_mwrapper);
REQUIRE(result); // IMultipleWrapper view reported successful
REQUIRE(i_mwrapper != nullptr); // IMultipleWrapper pointer not null
yarp::dev::WrapperSingle* ww_nws;
dd_nws.view(ww_nws);
bool result_att = ww_nws->attach(&dd_dev);
REQUIRE(result_att); // controlboard_nws_yarp open reported successful

PolyDriver dd2;
Property p2;
Expand All @@ -53,7 +57,7 @@ TEST_CASE("dev::TorqueControl", "[yarp::dev]")
p2.put("local","/motor/client");
p2.put("carrier","tcp");
p2.put("ignoreProtocolCheck","true");
result = dd2.open(p2);
bool result = dd2.open(p2);
REQUIRE(result); // remote_controlboard open reported successful

ITorqueControl *trq = nullptr;
Expand Down Expand Up @@ -83,7 +87,8 @@ TEST_CASE("dev::TorqueControl", "[yarp::dev]")
CHECK(res.viscousNeg == 0.6); // interface seems functional
CHECK(res.coulombPos == 0.7); // interface seems functional
CHECK(res.coulombNeg == 0.8); // interface seems functional
CHECK(dd.close()); // close dd reported successful
CHECK(dd_nws.close()); // close dd_nws reported successful
CHECK(dd_dev.close()); // close dd_dev reported successful
CHECK(dd2.close()); // close dd2 reported successful
}
}

0 comments on commit a5c6771

Please sign in to comment.