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>
42
43#include <catch2/catch_amalgamated.hpp>
44#include <harness.h>
45
46using namespace yarp::dev;
47using namespace yarp::os;
48
49TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
50{
51 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
52 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
53 YARP_REQUIRE_PLUGIN("remote_controlboard", "device");
54
55 Network::setLocalMode(true);
56
57 SECTION("Checking remote_controlboard device (using fakeMotionControl)")
58 {
62
63 IPositionControl* ipos = nullptr;
64 IVelocityControl* ivel = nullptr;
65 ITorqueControl* itrq = nullptr;
66 IAxisInfo* iinfo = nullptr;
67 IEncodersTimed* ienc = nullptr;
68 IControlMode* icmd = nullptr;
69 IInteractionMode* iint = nullptr;
70 IMotor* imot = nullptr;
71 IMotorEncoders* imotenc = nullptr;
72 IPidControl* ipid = nullptr;
73 IPWMControl* ipwm = nullptr;
74 ICurrentControl* icurr = nullptr;
75 IJointFault* ifault = nullptr;
76 IControlLimits* ilims = nullptr;
77 IImpedanceControl* iimp = nullptr;
78 //IRemoteCalibrator* iremotecalib = nullptr;
79 IJointBrake* ibrake = nullptr;
80 IVelocityDirect* ivelod = nullptr;
81
83 {
85 p_cfg.put("device", "fakeMotionControl");
86 Property& grp = p_cfg.addGroup("GENERAL");
87 grp.put("Joints", 2);
89 }
91 {
93 p_cfg.put("device", "controlBoard_nws_yarp");
94 p_cfg.put("name", "/controlboardserver");
96 }
97
98 //attach nws and fake
99 {
102 bool result_att = ww_nws->attach(&ddmc);
104 }
105
107
108 //open the nwc
109 {
111 p_cfg.put("device", "remote_controlboard");
112 p_cfg.put("local", "/local_controlboard");
113 p_cfg.put("remote", "/controlboardserver");
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);
135 ddnwc.view(ivelod); REQUIRE(ivelod);
136 //ddnwc.view(icalib); REQUIRE(iremotecalib);
137
151 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);
156
157 //"Close all polydrivers and check"
158 {
159 CHECK(ddnwc.close());
160 CHECK(ddnws.close());
161 CHECK(ddmc.close());
162 }
163 }
164
165 SECTION("Checking remote_controlboard device (using fakeMotionControlMicro)")
166 {
170
171 IPositionControl* ipos = nullptr;
172 IVelocityControl* ivel = nullptr;
173 ITorqueControl* itrq = nullptr;
174 IAxisInfo* iinfo = nullptr;
175 IEncodersTimed* ienc = nullptr;
176 IControlMode* icmd = nullptr;
177
179 {
181 p_cfg.put("device", "fakeMotionControlMicro");
182 Property& grp = p_cfg.addGroup("GENERAL");
183 grp.put("Joints", 2);
185 }
187 {
189 p_cfg.put("device", "controlBoard_nws_yarp");
190 p_cfg.put("name", "/controlboardserver");
192 }
193
194 //attach nws and fake
195 {
198 bool result_att = ww_nws->attach(&ddmc);
200 }
201
203
204 //open the nwc
205 {
207 p_cfg.put("device", "remote_controlboard");
208 p_cfg.put("local", "/local_controlboard");
209 p_cfg.put("remote", "/controlboardserver");
211 }
212
214
215 //test
216 ddnwc.view(ipos); REQUIRE(ipos);
217 ddnwc.view(ivel); REQUIRE(ivel);
218 ddnwc.view(itrq); REQUIRE(itrq);
219 ddnwc.view(iinfo); REQUIRE(iinfo);
220 ddnwc.view(ienc); REQUIRE(ienc);
221 ddnwc.view(icmd); REQUIRE(icmd);
227
228 //"Close all polydrivers and check"
229 {
230 CHECK(ddnwc.close());
231 CHECK(ddnws.close());
232 CHECK(ddmc.close());
233 }
234 }
235
236 Network::setLocalMode(false);
237}
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 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: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.
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
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_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)
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.