|
| 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 | +} |
0 commit comments