Skip to content

Commit b20c218

Browse files
authored
Merge pull request #3301 from randaz81/improved_controlBoardRemapperTest
Improved control board remapper test
2 parents 4c0d1cd + e94f004 commit b20c218

File tree

4 files changed

+178
-3
lines changed

4 files changed

+178
-3
lines changed

src/devices/controlBoardRemapper/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
create_device_test(controlBoardRemapper_t1)
55
create_device_test(controlBoardRemapper_t2)
6+
create_device_test(controlBoardRemapper_t3)

src/devices/controlBoardRemapper/tests/controlBoardRemapper_t2_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ TEST_CASE("dev::ControlBoardRemapperTest2", "[yarp::dev]")
7373
IImpedanceControl* iimp = nullptr;
7474
//IRemoteCalibrator* iremotecalib = nullptr;
7575

76-
////////"Checking opening map2DServer and map2DClient polydrivers"
76+
////////"Test a controlboardremapper attached to a fakeMotionControl"
7777
{
7878
Property p_cfg;
7979
p_cfg.put("device", "fakeMotionControl");
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3+
* SPDX-License-Identifier: BSD-3-Clause
4+
*/
5+
6+
#include <yarp/dev/IAxisInfo.h>
7+
#include <yarp/dev/IPositionControl.h>
8+
#include <yarp/dev/IVelocityControl.h>
9+
#include <yarp/dev/ITorqueControl.h>
10+
#include <yarp/dev/IEncodersTimed.h>
11+
#include <yarp/dev/IAxisInfo.h>
12+
#include <yarp/dev/IInteractionMode.h>
13+
#include <yarp/dev/IMotorEncoders.h>
14+
#include <yarp/dev/IMotor.h>
15+
#include <yarp/dev/IPidControl.h>
16+
#include <yarp/dev/IPWMControl.h>
17+
#include <yarp/dev/ICurrentControl.h>
18+
#include <yarp/dev/IRemoteCalibrator.h>
19+
#include <yarp/dev/IControlLimits.h>
20+
#include <yarp/dev/IImpedanceControl.h>
21+
#include <yarp/os/Network.h>
22+
#include <yarp/dev/PolyDriver.h>
23+
#include <yarp/dev/WrapperMultiple.h>
24+
#include <yarp/dev/tests/IPositionControlTest.h>
25+
#include <yarp/dev/tests/IVelocityControlTest.h>
26+
#include <yarp/dev/tests/ITorqueControlTest.h>
27+
#include <yarp/dev/tests/IEncodersTimedTest.h>
28+
#include <yarp/dev/tests/IAxisInfoTest.h>
29+
#include <yarp/dev/tests/IControlModeTest.h>
30+
#include <yarp/dev/tests/IInteractionModeTest.h>
31+
#include <yarp/dev/tests/ICurrentControlTest.h>
32+
#include <yarp/dev/tests/IPWMControlTest.h>
33+
#include <yarp/dev/tests/IPidControlTest.h>
34+
#include <yarp/dev/tests/IMotorTest.h>
35+
#include <yarp/dev/tests/IMotorEncodersTest.h>
36+
#include <yarp/dev/tests/IRemoteCalibratorTest.h>
37+
#include <yarp/dev/tests/IJointFaultTest.h>
38+
#include <yarp/dev/tests/IControlLimitsTest.h>
39+
#include <yarp/dev/tests/IImpedanceControlTest.h>
40+
41+
#include <catch2/catch_amalgamated.hpp>
42+
#include <harness.h>
43+
44+
using namespace yarp::dev;
45+
using namespace yarp::os;
46+
47+
TEST_CASE("dev::ControlBoardRemapperTest3", "[yarp::dev]")
48+
{
49+
YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
50+
YARP_REQUIRE_PLUGIN("controlboardremapper", "device");
51+
YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
52+
//YARP_REQUIRE_PLUGIN("controlBoard_nwc_yarp", "device");
53+
YARP_REQUIRE_PLUGIN("remote_controlboard", "device");
54+
55+
Network::setLocalMode(true);
56+
57+
SECTION("Checking controlboardremapper device attached to a controlBoard_nwc_yarp device")
58+
{
59+
PolyDriver ddfakemc;
60+
PolyDriver ddnws;
61+
PolyDriver ddnwc;
62+
PolyDriver ddremapper;
63+
64+
IPositionControl* ipos = nullptr;
65+
IVelocityControl* ivel = nullptr;
66+
ITorqueControl* itrq = nullptr;
67+
IAxisInfo* iinfo = nullptr;
68+
IEncodersTimed* ienc = nullptr;
69+
IControlMode* icmd = nullptr;
70+
IInteractionMode* iint = nullptr;
71+
IMotor* imot = nullptr;
72+
IMotorEncoders* imotenc = nullptr;
73+
IPidControl* ipid = nullptr;
74+
IPWMControl* ipwm = nullptr;
75+
ICurrentControl* icurr = nullptr;
76+
IJointFault* ifault = nullptr;
77+
IControlLimits* ilims = nullptr;
78+
IImpedanceControl* iimp = nullptr;
79+
//IRemoteCalibrator* iremotecalib = nullptr;
80+
81+
////////"Test a controlboardremapper attached to a controlBoard_nwc_yarp"
82+
{
83+
Property p_cfg;
84+
p_cfg.put("device", "fakeMotionControl");
85+
Property& grp = p_cfg.addGroup("GENERAL");
86+
grp.put("Joints", 4);
87+
REQUIRE(ddfakemc.open(p_cfg));
88+
}
89+
{
90+
Property p_cfg;
91+
p_cfg.put("device", "controlBoard_nws_yarp");
92+
p_cfg.put("name", "/alljoints");
93+
REQUIRE(ddnws.open(p_cfg));
94+
}
95+
{
96+
yarp::dev::IMultipleWrapper* ww_nws=nullptr; ddnws.view(ww_nws);
97+
REQUIRE(ww_nws);
98+
yarp::dev::PolyDriverList pdlist; pdlist.push(&ddfakemc,"fakeboard1");
99+
bool result_att = ww_nws->attachAll(pdlist);
100+
REQUIRE(result_att);
101+
}
102+
103+
yarp::os::Time::delay(0.1);
104+
105+
//client side
106+
{
107+
Property p_cfg;
108+
//p_cfg.put("device", "controlBoard_nwc_yarp");
109+
p_cfg.put("device", "remote_controlboard");
110+
p_cfg.put("local", "/localalljoints");
111+
p_cfg.put("remote", "/alljoints");
112+
REQUIRE(ddnwc.open(p_cfg));
113+
}
114+
{
115+
Property p_cfg;
116+
p_cfg.put("device", "controlboardremapper");
117+
yarp::os::Value* jlist = yarp::os::Value::makeList("joint3 joint2");
118+
p_cfg.put("axesNames", jlist);
119+
REQUIRE(ddremapper.open(p_cfg));
120+
}
121+
{
122+
yarp::dev::IMultipleWrapper* ww_rem=nullptr; ddremapper.view(ww_rem);
123+
REQUIRE(ww_rem);
124+
yarp::dev::PolyDriverList pdlist; pdlist.push(&ddnwc,"nwcboard1");
125+
bool result_att = ww_rem->attachAll(pdlist);
126+
REQUIRE(result_att);
127+
}
128+
129+
ddremapper.view(ipos); REQUIRE(ipos);
130+
ddremapper.view(ivel); REQUIRE(ivel);
131+
ddremapper.view(itrq); REQUIRE(itrq);
132+
ddremapper.view(iinfo); REQUIRE(iinfo);
133+
ddremapper.view(ienc); REQUIRE(ienc);
134+
ddremapper.view(icmd); REQUIRE(icmd);
135+
ddremapper.view(iint); REQUIRE(iint);
136+
ddremapper.view(imot); REQUIRE(imot);
137+
ddremapper.view(imotenc); REQUIRE(imotenc);
138+
ddremapper.view(ipid); REQUIRE(ipid);
139+
ddremapper.view(ipwm); REQUIRE(ipwm);
140+
ddremapper.view(icurr); REQUIRE(icurr);
141+
ddremapper.view(ifault); REQUIRE(ifault);
142+
ddremapper.view(ilims); REQUIRE(ilims);
143+
ddremapper.view(iimp); REQUIRE(iimp);
144+
//ddremapper.view(iremotecalib); REQUIRE(iremotecalib);
145+
146+
yarp::dev::tests::exec_iPositionControl_test_1(ipos, icmd);
147+
yarp::dev::tests::exec_iVelocityControl_test_1(ivel, icmd);
148+
yarp::dev::tests::exec_iTorqueControl_test_1(itrq, icmd);
149+
yarp::dev::tests::exec_iAxisInfo_test_1(iinfo, "joint3");
150+
yarp::dev::tests::exec_iEncodersTimed_test_1(ienc);
151+
yarp::dev::tests::exec_iControlMode_test_1(icmd, iinfo);
152+
yarp::dev::tests::exec_iInteractionMode_test_1(iint,iinfo);
153+
yarp::dev::tests::exec_iMotor_test_1(imot);
154+
yarp::dev::tests::exec_iMotorEncoders_test_1(imotenc);
155+
yarp::dev::tests::exec_iPidControl_test_1(ipid, iinfo);
156+
yarp::dev::tests::exec_iPidControl_test_2(ipid);
157+
yarp::dev::tests::exec_iPwmControl_test_1(ipwm, icmd);
158+
yarp::dev::tests::exec_iCurrentControl_test_1(icurr, icmd);
159+
//yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib);
160+
yarp::dev::tests::exec_iJointFault_test_1(ifault);
161+
yarp::dev::tests::exec_iControlLimits_test1(ilims, iinfo);
162+
yarp::dev::tests::exec_iImpedanceControl_test_1(iimp);
163+
164+
//"Close all polydrivers and check"
165+
{
166+
CHECK(ddremapper.close());
167+
CHECK(ddnwc.close());
168+
CHECK(ddnws.close());
169+
CHECK(ddfakemc.close());
170+
}
171+
}
172+
173+
Network::setLocalMode(false);
174+
}

src/libYARP_dev/src/yarp/dev/tests/IAxisInfoTest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace yarp::os;
1414

1515
namespace yarp::dev::tests
1616
{
17-
inline void exec_iAxisInfo_test_1(IAxisInfo* iinfo)
17+
inline void exec_iAxisInfo_test_1(IAxisInfo* iinfo, std::string jname="joint0")
1818
{
1919
REQUIRE(iinfo !=nullptr);
2020

@@ -28,7 +28,7 @@ namespace yarp::dev::tests
2828
std::string name;
2929
b = iinfo->getAxisName(0,name);
3030
CHECK(b);
31-
CHECK(name == std::string("joint0"));
31+
CHECK(name == jname);
3232

3333
yarp::dev::JointTypeEnum type;
3434
b = iinfo->getJointType(0, type);

0 commit comments

Comments
 (0)