YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
controlBoardRemapper_t3_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
11#include <yarp/dev/IAxisInfo.h>
14#include <yarp/dev/IMotor.h>
21#include <yarp/os/Network.h>
22#include <yarp/dev/PolyDriver.h>
41
42#include <catch2/catch_amalgamated.hpp>
43#include <harness.h>
44
45using namespace yarp::dev;
46using namespace yarp::os;
47
48TEST_CASE("dev::ControlBoardRemapperTest3", "[yarp::dev]")
49{
50 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
51 YARP_REQUIRE_PLUGIN("controlboardremapper", "device");
52 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
53 YARP_REQUIRE_PLUGIN("controlBoard_nwc_yarp", "device");
54
55 Network::setLocalMode(true);
56
57 //remapping from one single hardware device
58 SECTION("Checking controlboardremapper device attached to a single controlBoard_nwc_yarp device")
59 {
64
65 IPositionControl* ipos = nullptr;
66 IVelocityControl* ivel = nullptr;
67 ITorqueControl* itrq = nullptr;
68 IAxisInfo* iinfo = nullptr;
69 IEncodersTimed* ienc = nullptr;
70 IControlMode* icmd = nullptr;
71 IInteractionMode* iint = nullptr;
72 IMotor* imot = nullptr;
73 IMotorEncoders* imotenc = nullptr;
74 IPidControl* ipid = nullptr;
75 IPWMControl* ipwm = nullptr;
76 ICurrentControl* icurr = nullptr;
77 IJointFault* ifault = nullptr;
78 IControlLimits* ilims = nullptr;
79 IImpedanceControl* iimp = nullptr;
80 //IRemoteCalibrator* iremotecalib = nullptr;
81
83 {
85 p_cfg.put("device", "fakeMotionControl");
86 Property& grp = p_cfg.addGroup("GENERAL");
87 grp.put("Joints", 4);
89 }
90 {
92 p_cfg.put("device", "controlBoard_nws_yarp");
93 p_cfg.put("name", "/alljoints");
95 }
96 {
100 bool result_att = ww_nws->attachAll(pdlist);
102 }
103
105
106 //client side
107 {
109 p_cfg.put("device", "controlBoard_nwc_yarp");
110 p_cfg.put("local", "/localalljoints");
111 p_cfg.put("remote", "/alljoints");
113 }
114 {
116 p_cfg.put("device", "controlboardremapper");
118 p_cfg.put("axesNames", jlist);
120 }
121 {
124 yarp::dev::PolyDriverList pdlist; pdlist.push(&ddnwc,"nwcboard1");
125 bool result_att = ww_rem->attachAll(pdlist);
127 }
128
129 ddremapper.view(ipos); REQUIRE(ipos);
130 ddremapper.view(ivel); REQUIRE(ivel);
131 ddremapper.view(itrq); REQUIRE(itrq);
133 ddremapper.view(ienc); REQUIRE(ienc);
134 ddremapper.view(icmd); REQUIRE(icmd);
135 ddremapper.view(iint); REQUIRE(iint);
136 ddremapper.view(imot); REQUIRE(imot);
138 ddremapper.view(ipid); REQUIRE(ipid);
139 ddremapper.view(ipwm); REQUIRE(ipwm);
143 ddremapper.view(iimp); REQUIRE(iimp);
144 //ddremapper.view(iremotecalib); REQUIRE(iremotecalib);
145
159 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib);
163
164 //"Close all polydrivers and check"
165 {
167 CHECK(ddnwc.close());
168 CHECK(ddnws.close());
170 }
171 }
172
173 // remapping from two hardware devices
174 SECTION("Checking controlboardremapper device attached to two controlBoard_nwc_yarp device")
175 {
183
184 IPositionControl* ipos = nullptr;
185 IVelocityControl* ivel = nullptr;
186 ITorqueControl* itrq = nullptr;
187 IAxisInfo* iinfo = nullptr;
188 IEncodersTimed* ienc = nullptr;
189 IControlMode* icmd = nullptr;
190 IInteractionMode* iint = nullptr;
191 IMotor* imot = nullptr;
192 IMotorEncoders* imotenc = nullptr;
193 IPidControl* ipid = nullptr;
194 IPWMControl* ipwm = nullptr;
195 ICurrentControl* icurr = nullptr;
196 IJointFault* ifault = nullptr;
197 IControlLimits* ilims = nullptr;
198 IImpedanceControl* iimp = nullptr;
199 //IRemoteCalibrator* iremotecalib = nullptr;
200
202 {
204 p_cfg.put("device", "fakeMotionControl");
205 Property& grp = p_cfg.addGroup("GENERAL");
206 grp.put("Joints", 4);
208 grp.put("AxisName", jlist);
210 }
211 {
213 p_cfg.put("device", "fakeMotionControl");
214 Property& grp = p_cfg.addGroup("GENERAL");
215 grp.put("Joints", 3);
217 grp.put("AxisName", jlist);
219 }
220 {
222 p_cfg.put("device", "controlBoard_nws_yarp");
223 p_cfg.put("name", "/alljoints1");
225 }
226 {
228 p_cfg.put("device", "controlBoard_nws_yarp");
229 p_cfg.put("name", "/alljoints2");
231 }
232 {
236 bool result_att = ww_nws->attachAll(pdlist);
238 }
239 {
243 bool result_att = ww_nws->attachAll(pdlist);
245 }
246
248
249 //client side
250 {
252 p_cfg.put("device", "controlBoard_nwc_yarp");
253 p_cfg.put("local", "/localalljoints1");
254 p_cfg.put("remote", "/alljoints1");
256 }
257 {
259 p_cfg.put("device", "controlBoard_nwc_yarp");
260 p_cfg.put("local", "/localalljoints2");
261 p_cfg.put("remote", "/alljoints2");
263 }
264 {
266 p_cfg.put("device", "controlboardremapper");
268 p_cfg.put("axesNames", jlist);
270 }
271 {
275 pdlist.push(&ddnwc1, "nwcboard1");
276 pdlist.push(&ddnwc2, "nwcboard2");
277 bool result_att = ww_rem->attachAll(pdlist);
279 }
280
281 ddremapper.view(ipos); REQUIRE(ipos);
282 ddremapper.view(ivel); REQUIRE(ivel);
283 ddremapper.view(itrq); REQUIRE(itrq);
285 ddremapper.view(ienc); REQUIRE(ienc);
286 ddremapper.view(icmd); REQUIRE(icmd);
287 ddremapper.view(iint); REQUIRE(iint);
288 ddremapper.view(imot); REQUIRE(imot);
290 ddremapper.view(ipid); REQUIRE(ipid);
291 ddremapper.view(ipwm); REQUIRE(ipwm);
295 ddremapper.view(iimp); REQUIRE(iimp);
296 //ddremapper.view(iremotecalib); REQUIRE(iremotecalib);
297
311 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(iremotecalib);
315
316 //"Close all polydrivers and check"
317 {
319 CHECK(ddnwc1.close());
320 CHECK(ddnwc2.close());
321 CHECK(ddnws1.close());
322 CHECK(ddnws2.close());
325 }
326 }
327
328 Network::setLocalMode(false);
329}
define control board standard interfaces
define control board standard interfaces
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:37
Interface for control devices, commands to get/set position and velocity limits.
Interface for setting control mode in control board.
Interface for control boards implementing current control.
Control board, extend encoder interface with timestamps.
Interface for control boards implementing impedance control.
Interface settings the way the robot interacts with the environment: basic interaction types are Stif...
Interface for getting info about the fault which may occur on a robot.
Definition IJointFault.h:24
Control board, encoder interface.
Control board, encoder interface.
Definition IMotor.h:95
Interface for an object that can wrap/attach to to another.
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition IPWMControl.h:24
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Interface for a generic control board device implementing position control.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
A container for a device driver.
Definition PolyDriver.h:23
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.
A class for storing options and configuration information.
Definition Property.h:32
A single value (typically within a Bottle).
Definition Value.h:44
static Value * makeList()
Create a list Value.
Definition Value.cpp:431
TEST_CASE("dev::ControlBoardRemapperTest3", "[yarp::dev]")
void exec_iMotorEncoders_test_1(IMotorEncoders *imotenc)
void exec_iControlLimits_test1(IControlLimits *ilims, IAxisInfo *iinfo)
void exec_iMotor_test_1(IMotor *imot)
Definition IMotorTest.h:17
void exec_iPidControl_test_2(IPidControl *ipid, IAxisInfo *iaxis)
void exec_iAxisInfo_test_1(IAxisInfo *iinfo, std::string jname="joint0")
void exec_iCurrentControl_test_1(ICurrentControl *icurr, IControlMode *icmd)
void exec_iTorqueControl_test_1(ITorqueControl *itrq, IControlMode *icmd)
void exec_iInteractionMode_test_1(IInteractionMode *iint, IAxisInfo *iinfo)
void exec_iPidControl_test_1(IPidControl *ipid, IAxisInfo *iaxis)
void exec_iImpedanceControl_test_1(IImpedanceControl *iimp)
void exec_iPositionControl_test_1(IPositionControl *ipos, IControlMode *icmd)
void exec_iPwmControl_test_1(IPWMControl *ipwm, IControlMode *icmd)
void exec_iJointFault_test_1(IJointFault *ifault)
void exec_iEncodersTimed_test_1(IEncodersTimed *ienc)
void exec_iControlMode_test_1(IControlMode *icmd, IAxisInfo *iinfo)
void exec_iVelocityControl_test_1(IVelocityControl *ivel, IControlMode *icmd)
For streams capable of holding different kinds of content, check what they actually have.
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
An interface to the operating system, including Port based communication.