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>
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 //IRemoteCalibrator* iremotecalib = nullptr;
76 IJointBrake* ibrake = nullptr;
77 IVelocityDirect* ivelod = nullptr;
78
80 {
82 p_cfg.put("device", "fakeMotionControl");
83 Property& grp = p_cfg.addGroup("GENERAL");
84 grp.put("Joints", 2);
86 }
88 {
90 p_cfg.put("device", "controlBoard_nws_yarp");
91 p_cfg.put("name", "/controlboardserver");
93 }
94
95 //attach nws and fake
96 {
99 bool result_att = ww_nws->attach(&ddmc);
101 }
102
104
105 //open the nwc
106 {
108 p_cfg.put("device", "remote_controlboard");
109 p_cfg.put("local", "/local_controlboard");
110 p_cfg.put("remote", "/controlboardserver");
112 }
113
115
116 //test
117 ddnwc.view(ipos); REQUIRE(ipos);
118 ddnwc.view(ivel); REQUIRE(ivel);
119 ddnwc.view(itrq); REQUIRE(itrq);
120 ddnwc.view(iinfo); REQUIRE(iinfo);
121 ddnwc.view(ienc); REQUIRE(ienc);
122 ddnwc.view(icmd); REQUIRE(icmd);
123 ddnwc.view(iint); REQUIRE(iint);
124 ddnwc.view(imot); REQUIRE(imot);
126 ddnwc.view(ipid); REQUIRE(ipid);
127 ddnwc.view(ipwm); REQUIRE(ipwm);
128 ddnwc.view(icurr); REQUIRE(icurr);
129 ddnwc.view(ifault); REQUIRE(ifault);
130 ddnwc.view(ilims); REQUIRE(ilims);
131 ddnwc.view(ibrake); REQUIRE(ibrake);
132 ddnwc.view(ivelod); REQUIRE(ivelod);
133 //ddnwc.view(icalib); REQUIRE(iremotecalib);
134
148 //yarp::dev::tests::exec_iRemoteCalibrator_test_1(icalib);
153
154 //"Close all polydrivers and check"
155 {
156 CHECK(ddnwc.close());
157 CHECK(ddnws.close());
158 CHECK(ddmc.close());
159 }
160 }
161
162 SECTION("Checking remote_controlboard device (using fakeMotionControlMicro)")
163 {
167
168 IPositionControl* ipos = nullptr;
169 IVelocityControl* ivel = nullptr;
170 ITorqueControl* itrq = nullptr;
171 IAxisInfo* iinfo = nullptr;
172 IEncodersTimed* ienc = nullptr;
173 IControlMode* icmd = nullptr;
174
176 {
178 p_cfg.put("device", "fakeMotionControlMicro");
179 Property& grp = p_cfg.addGroup("GENERAL");
180 grp.put("Joints", 2);
182 }
184 {
186 p_cfg.put("device", "controlBoard_nws_yarp");
187 p_cfg.put("name", "/controlboardserver");
189 }
190
191 //attach nws and fake
192 {
195 bool result_att = ww_nws->attach(&ddmc);
197 }
198
200
201 //open the nwc
202 {
204 p_cfg.put("device", "remote_controlboard");
205 p_cfg.put("local", "/local_controlboard");
206 p_cfg.put("remote", "/controlboardserver");
208 }
209
211
212 //test
213 ddnwc.view(ipos); REQUIRE(ipos);
214 ddnwc.view(ivel); REQUIRE(ivel);
215 ddnwc.view(itrq); REQUIRE(itrq);
216 ddnwc.view(iinfo); REQUIRE(iinfo);
217 ddnwc.view(ienc); REQUIRE(ienc);
218 ddnwc.view(icmd); REQUIRE(icmd);
224
225 //"Close all polydrivers and check"
226 {
227 CHECK(ddnwc.close());
228 CHECK(ddnws.close());
229 CHECK(ddmc.close());
230 }
231 }
232
233 Network::setLocalMode(false);
234}
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 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.