YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
controlBoard_nwc_yarp_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
6#include <yarp/os/Network.h>
29
30#include <catch2/catch_amalgamated.hpp>
31#include <harness.h>
32
33using namespace yarp::dev;
34using namespace yarp::os;
35
36TEST_CASE("dev::controlBoard_nwc_yarp", "[yarp::dev]")
37{
38 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
39 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
40 YARP_REQUIRE_PLUGIN("controlBoard_nwc_yarp", "device");
41
42 Network::setLocalMode(true);
43
45 bool(true),
46 bool(false)
47 );
48
50 "controlBoard_nwc_yarp",
51 "remote_controlboard"
52 );
53
54 SECTION("Checking controlBoard_nwc_yarp device (using fakeMotionControl)")
55 {
59
60 IPositionControl* ipos = nullptr;
61 IVelocityControl* ivel = nullptr;
62 ITorqueControl* itrq = nullptr;
63 IAxisInfo* iinfo = nullptr;
64 IEncodersTimed* ienc = nullptr;
65 IControlMode* icmd = nullptr;
66 IInteractionMode* iint = nullptr;
67 IMotor* imot = nullptr;
68 IMotorEncoders* imotenc = nullptr;
69 IPidControl* ipid = nullptr;
70 IPWMControl* ipwm = nullptr;
71 ICurrentControl* icurr = nullptr;
72 IJointFault* ifault = nullptr;
73 IControlLimits* ilims = nullptr;
74 IImpedanceControl* iimp = nullptr;
75 //IRemoteCalibrator* iremotecalib = nullptr;
76 IJointBrake* ibrake = nullptr;
77 IPositionDirect* iposdir = nullptr;
78 IVelocityDirect* iveldir = nullptr;
79
81 {
83 p_cfg.put("device", "fakeMotionControl");
84 Property& grp = p_cfg.addGroup("GENERAL");
85 grp.put("Joints", 2);
87 }
89 {
91 p_cfg.put("device", "controlBoard_nws_yarp");
92 p_cfg.put("name", "/controlboardserver");
94 }
95
96 //attach nws and fake
97 {
100 bool result_att = ww_nws->attach(&ddmc);
102 }
103
105
106 //open the nwc
107 {
109 p_cfg.put("device", compatibility_oldclient_name);
110 p_cfg.put("local", "/local_controlboard");
111 p_cfg.put("remote", "/controlboardserver");
112 p_cfg.put("use_streaming", use_streaming_config);
115 }
116
118
119 //test
120 ddnwc.view(ipos); REQUIRE(ipos);
121 ddnwc.view(ivel); REQUIRE(ivel);
122 ddnwc.view(itrq); REQUIRE(itrq);
123 ddnwc.view(iinfo); REQUIRE(iinfo);
124 ddnwc.view(ienc); REQUIRE(ienc);
125 ddnwc.view(icmd); REQUIRE(icmd);
126 ddnwc.view(iint); REQUIRE(iint);
127 ddnwc.view(imot); REQUIRE(imot);
129 ddnwc.view(ipid); REQUIRE(ipid);
130 ddnwc.view(ipwm); REQUIRE(ipwm);
131 ddnwc.view(icurr); REQUIRE(icurr);
132 ddnwc.view(ifault); REQUIRE(ifault);
133 ddnwc.view(ilims); REQUIRE(ilims);
134 ddnwc.view(ibrake); REQUIRE(ibrake);
137 //ddnwc.view(icalib); REQUIRE(iremotecalib);
138
152 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);
158
159 //"Close all polydrivers and check"
160 {
161 CHECK(ddnwc.close());
162 CHECK(ddnws.close());
163 CHECK(ddmc.close());
164 }
165 }
166
167 SECTION("Checking controlBoard_nwc_yarp device (using fakeMotionControlMicro)")
168 {
172
173 IPositionControl* ipos = nullptr;
174 IVelocityControl* ivel = nullptr;
175 ITorqueControl* itrq = nullptr;
176 IAxisInfo* iinfo = nullptr;
177 IEncodersTimed* ienc = nullptr;
178 IControlMode* icmd = nullptr;
179
181 {
183 p_cfg.put("device", "fakeMotionControlMicro");
184 Property& grp = p_cfg.addGroup("GENERAL");
185 grp.put("Joints", 2);
187 }
189 {
191 p_cfg.put("device", "controlBoard_nws_yarp");
192 p_cfg.put("name", "/controlboardserver");
194 }
195
196 //attach nws and fake
197 {
200 bool result_att = ww_nws->attach(&ddmc);
202 }
203
205
206 //open the nwc
207 {
209 p_cfg.put("device", "controlBoard_nwc_yarp");
210 p_cfg.put("local", "/local_controlboard");
211 p_cfg.put("remote", "/controlboardserver");
212 p_cfg.put("use_streaming", use_streaming_config);
214 }
215
217
218 //test
219 ddnwc.view(ipos); REQUIRE(ipos);
220 ddnwc.view(ivel); REQUIRE(ivel);
221 ddnwc.view(itrq); REQUIRE(itrq);
222 ddnwc.view(iinfo); REQUIRE(iinfo);
223 ddnwc.view(ienc); REQUIRE(ienc);
224 ddnwc.view(icmd); REQUIRE(icmd);
230
231 //"Close all polydrivers and check"
232 {
233 CHECK(ddnwc.close());
234 CHECK(ddnws.close());
235 CHECK(ddmc.close());
236 }
237 }
238
239 Network::setLocalMode(false);
240}
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 controlling a joint equipped with brakes (hardware or simulated).
Definition IJointBrake.h:23
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 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 a generic control board device implementing position control.
Interface for control boards implementing torque control.
Interface for control boards implementing velocity control.
Interface for control boards implementing direct velocity control.
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.
A class for storing options and configuration information.
Definition Property.h:33
TEST_CASE("dev::controlBoard_nwc_yarp", "[yarp::dev]")
void exec_iMotorEncoders_test_1(IMotorEncoders *imotenc)
void exec_iPositionDirect_test_1(IPositionDirect *ipdir, IControlMode *icmd)
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_iTorqueControl_test_unimplemented_interface(ITorqueControl *itrq, IControlMode *icmd)
void exec_iAxisInfo_test_1(IAxisInfo *iinfo, std::string jname="joint0")
void exec_iCurrentControl_test_1(ICurrentControl *icurr, IControlMode *icmd)
void exec_iVelocityControl_test_unimplemented_interface(IVelocityControl *ivel, IControlMode *icmd)
void exec_iTorqueControl_test_1(ITorqueControl *itrq, IControlMode *icmd)
void exec_iInteractionMode_test_1(IInteractionMode *iint, IAxisInfo *iinfo)
void exec_params_test(yarp::dev::PolyDriver *pdrv)
void exec_iJointBrake_test1(IJointBrake *ibrake)
void exec_iPidControl_test_1(IPidControl *ipid, IAxisInfo *iaxis)
void exec_iPositionControl_test_1(IPositionControl *ipos, IControlMode *icmd)
void exec_iVelocityDirect_test_1(IVelocityDirect *ivdir, IControlMode *icmd)
void exec_iPositionControl_test_unimplemented_interface(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.
Definition OSTestMsg.cpp:13