YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RemoteControlBoard_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>
40
41#include <catch2/catch_amalgamated.hpp>
42#include <harness.h>
43
44using namespace yarp::dev;
45using namespace yarp::os;
46
47TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
48{
49 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
50 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
51 YARP_REQUIRE_PLUGIN("remote_controlboard", "device");
52
53 Network::setLocalMode(true);
54
55 SECTION("Checking remote_controlboard device (using fakeMotionControl)")
56 {
60
61 IPositionControl* ipos = nullptr;
62 IVelocityControl* ivel = nullptr;
63 ITorqueControl* itrq = nullptr;
64 IAxisInfo* iinfo = nullptr;
65 IEncodersTimed* ienc = nullptr;
66 IControlMode* icmd = nullptr;
67 IInteractionMode* iint = nullptr;
68 IMotor* imot = nullptr;
69 IMotorEncoders* imotenc = nullptr;
70 IPidControl* ipid = nullptr;
71 IPWMControl* ipwm = nullptr;
72 ICurrentControl* icurr = nullptr;
73 IJointFault* ifault = nullptr;
74 IControlLimits* ilims = nullptr;
75 IImpedanceControl* iimp = nullptr;
76 //IRemoteCalibrator* iremotecalib = nullptr;
77
79 {
81 p_cfg.put("device", "fakeMotionControl");
82 Property& grp = p_cfg.addGroup("GENERAL");
83 grp.put("Joints", 2);
85 }
87 {
89 p_cfg.put("device", "controlBoard_nws_yarp");
90 p_cfg.put("name", "/controlboardserver");
92 }
93
94 //attach nws and fake
95 {
98 bool result_att = ww_nws->attach(&ddmc);
100 }
101
103
104 //open the nwc
105 {
107 p_cfg.put("device", "remote_controlboard");
108 p_cfg.put("local", "/local_controlboard");
109 p_cfg.put("remote", "/controlboardserver");
111 }
112
114
115 //test
116 ddnwc.view(ipos); REQUIRE(ipos);
117 ddnwc.view(ivel); REQUIRE(ivel);
118 ddnwc.view(itrq); REQUIRE(itrq);
119 ddnwc.view(iinfo); REQUIRE(iinfo);
120 ddnwc.view(ienc); REQUIRE(ienc);
121 ddnwc.view(icmd); REQUIRE(icmd);
122 ddnwc.view(iint); REQUIRE(iint);
123 ddnwc.view(imot); REQUIRE(imot);
125 ddnwc.view(ipid); REQUIRE(ipid);
126 ddnwc.view(ipwm); REQUIRE(ipwm);
127 ddnwc.view(icurr); REQUIRE(icurr);
128 ddnwc.view(ifault); REQUIRE(ifault);
129 ddnwc.view(ilims); REQUIRE(ilims);
130 ddnwc.view(iimp); REQUIRE(iimp);
131 REQUIRE(iimp);
132 //ddnwc.view(icalib); REQUIRE(iremotecalib);
133
147 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);
151
152 //"Close all polydrivers and check"
153 {
154 CHECK(ddnwc.close());
155 CHECK(ddnws.close());
156 CHECK(ddmc.close());
157 }
158 }
159
160 SECTION("Checking remote_controlboard device (using fakeMotionControlMicro)")
161 {
165
166 IPositionControl* ipos = nullptr;
167 IVelocityControl* ivel = nullptr;
168 ITorqueControl* itrq = nullptr;
169 IAxisInfo* iinfo = nullptr;
170 IEncodersTimed* ienc = nullptr;
171 IControlMode* icmd = nullptr;
172
174 {
176 p_cfg.put("device", "fakeMotionControlMicro");
177 Property& grp = p_cfg.addGroup("GENERAL");
178 grp.put("Joints", 2);
180 }
182 {
184 p_cfg.put("device", "controlBoard_nws_yarp");
185 p_cfg.put("name", "/controlboardserver");
187 }
188
189 //attach nws and fake
190 {
193 bool result_att = ww_nws->attach(&ddmc);
195 }
196
198
199 //open the nwc
200 {
202 p_cfg.put("device", "remote_controlboard");
203 p_cfg.put("local", "/local_controlboard");
204 p_cfg.put("remote", "/controlboardserver");
206 }
207
209
210 //test
211 ddnwc.view(ipos); REQUIRE(ipos);
212 ddnwc.view(ivel); REQUIRE(ivel);
213 ddnwc.view(itrq); REQUIRE(itrq);
214 ddnwc.view(iinfo); REQUIRE(iinfo);
215 ddnwc.view(ienc); REQUIRE(ienc);
216 ddnwc.view(icmd); REQUIRE(icmd);
222
223 //"Close all polydrivers and check"
224 {
225 CHECK(ddnwc.close());
226 CHECK(ddnws.close());
227 CHECK(ddmc.close());
228 }
229 }
230
231 Network::setLocalMode(false);
232}
define control board standard interfaces
define control board standard interfaces
TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:36
Interface for control devices, commands to get/set position and veloity 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:23
Control board, encoder interface.
Control board, encoder interface.
Definition IMotor.h:94
Interface for controlling an axis, by sending directly a PWM reference signal to a motor.
Definition IPWMControl.h:23
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
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
void exec_iMotorEncoders_test_1(IMotorEncoders *imotenc)
void exec_iAxisInfo_test_1(IAxisInfo *iinfo)
void exec_iControlLimits_test1(IControlLimits *ilims, IAxisInfo *iinfo)
void exec_iMotor_test_1(IMotor *imot)
Definition IMotorTest.h:17
void exec_iTorqueControl_test_unimplemented_interface(ITorqueControl *itrq, IControlMode *icmd)
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_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_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)
void exec_iPidControl_test_2(IPidControl *ipid)
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.