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>
20#include <yarp/os/Network.h>
21#include <yarp/dev/PolyDriver.h>
38
39#include <catch2/catch_amalgamated.hpp>
40#include <harness.h>
41
42using namespace yarp::dev;
43using namespace yarp::os;
44
45TEST_CASE("dev::RemoteControlBoardTest", "[yarp::dev]")
46{
47 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
48 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
49 YARP_REQUIRE_PLUGIN("remote_controlboard", "device");
50
51 Network::setLocalMode(true);
52
53 SECTION("Checking remote_controlboard device (using fakeMotionControl)")
54 {
58
59 IPositionControl* ipos = nullptr;
60 IVelocityControl* ivel = nullptr;
61 ITorqueControl* itrq = nullptr;
62 IAxisInfo* iinfo = nullptr;
63 IEncodersTimed* ienc = nullptr;
64 IControlMode* icmd = nullptr;
65 IInteractionMode* iint = nullptr;
66 IMotor* imot = nullptr;
67 IMotorEncoders* imotenc = nullptr;
68 IPidControl* ipid = nullptr;
69 IPWMControl* ipwm = nullptr;
70 ICurrentControl* icurr = nullptr;
71 IJointFault* ifault = nullptr;
72 IControlLimits* ilims = nullptr;
73 //IRemoteCalibrator* iremotecalib = nullptr;
74
76 {
78 p_cfg.put("device", "fakeMotionControl");
79 Property& grp = p_cfg.addGroup("GENERAL");
80 grp.put("Joints", 2);
82 }
84 {
86 p_cfg.put("device", "controlBoard_nws_yarp");
87 p_cfg.put("name", "/controlboardserver");
89 }
90
91 //attach nws and fake
92 {
95 bool result_att = ww_nws->attach(&ddmc);
97 }
98
100
101 //open the nwc
102 {
104 p_cfg.put("device", "remote_controlboard");
105 p_cfg.put("local", "/local_controlboard");
106 p_cfg.put("remote", "/controlboardserver");
108 }
109
111
112 //test
113 ddnwc.view(ipos); REQUIRE(ipos);
114 ddnwc.view(ivel); REQUIRE(ivel);
115 ddnwc.view(itrq); REQUIRE(itrq);
116 ddnwc.view(iinfo); REQUIRE(iinfo);
117 ddnwc.view(ienc); REQUIRE(ienc);
118 ddnwc.view(icmd); REQUIRE(icmd);
119 ddnwc.view(iint); REQUIRE(iint);
120 ddnwc.view(imot); REQUIRE(imot);
122 ddnwc.view(ipid); REQUIRE(ipid);
123 ddnwc.view(ipwm); REQUIRE(ipwm);
124 ddnwc.view(icurr); REQUIRE(icurr);
125 ddnwc.view(ifault); REQUIRE(ifault);
126 ddnwc.view(ilims); REQUIRE(ilims);
127 //ddnwc.view(icalib); REQUIRE(iremotecalib);
128
142 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);
145
146 //"Close all polydrivers and check"
147 {
148 CHECK(ddnwc.close());
149 CHECK(ddnws.close());
150 CHECK(ddmc.close());
151 }
152 }
153
154 SECTION("Checking remote_controlboard device (using fakeMotionControlMicro)")
155 {
159
160 IPositionControl* ipos = nullptr;
161 IVelocityControl* ivel = nullptr;
162 ITorqueControl* itrq = nullptr;
163 IAxisInfo* iinfo = nullptr;
164 IEncodersTimed* ienc = nullptr;
165 IControlMode* icmd = nullptr;
166
168 {
170 p_cfg.put("device", "fakeMotionControlMicro");
171 Property& grp = p_cfg.addGroup("GENERAL");
172 grp.put("Joints", 2);
174 }
176 {
178 p_cfg.put("device", "controlBoard_nws_yarp");
179 p_cfg.put("name", "/controlboardserver");
181 }
182
183 //attach nws and fake
184 {
187 bool result_att = ww_nws->attach(&ddmc);
189 }
190
192
193 //open the nwc
194 {
196 p_cfg.put("device", "remote_controlboard");
197 p_cfg.put("local", "/local_controlboard");
198 p_cfg.put("remote", "/controlboardserver");
200 }
201
203
204 //test
205 ddnwc.view(ipos); REQUIRE(ipos);
206 ddnwc.view(ivel); REQUIRE(ivel);
207 ddnwc.view(itrq); REQUIRE(itrq);
208 ddnwc.view(iinfo); REQUIRE(iinfo);
209 ddnwc.view(ienc); REQUIRE(ienc);
210 ddnwc.view(icmd); REQUIRE(icmd);
216
217 //"Close all polydrivers and check"
218 {
219 CHECK(ddnwc.close());
220 CHECK(ddnws.close());
221 CHECK(ddmc.close());
222 }
223 }
224
225 Network::setLocalMode(false);
226}
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 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_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.