YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
controlBoardRemapper_t4_test.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026-2026 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>
41
42#include <catch2/catch_amalgamated.hpp>
43#include <harness.h>
44
45using namespace yarp::dev;
46using namespace yarp::os;
47
48TEST_CASE("dev::ControlBoardRemapperTest4", "[yarp::dev]")
49{
50 YARP_REQUIRE_PLUGIN("fakeMotionControl", "device");
51 YARP_REQUIRE_PLUGIN("controlboardremapper", "device");
52 YARP_REQUIRE_PLUGIN("controlBoard_nws_yarp", "device");
53
54 Network::setLocalMode(true);
55
56 SECTION("Testing an invalid configuration (subdevice not found)")
57 {
61
62 {
64 p_cfg.put("device", "fakeMotionControl");
65 Property& grp = p_cfg.addGroup("GENERAL");
66 grp.put("Joints", 2);
69 }
70 {
72 p_cfg.put("device", "controlboardremapper");
73 p_cfg.put("joints", 2);
74 Value* jlist = Value::makeList("net0");
75 p_cfg.put("networks", jlist);
76 p_cfg.put("net0", "0 1 0 1");
79 }
80 {
84 bool result_att = ww_rem->attachAll(pdlist);
86 }
87
88 //"Close all polydrivers and check"
89 {
92 }
93 }
94
95 SECTION("Testing an invalid configuration")
96 {
100
101 {
103 p_cfg.put("device", "fakeMotionControl");
104 p_cfg.put("name", "fakeboard1");
105 Property& grp = p_cfg.addGroup("GENERAL");
106 grp.put("Joints", 2);
108 }
109 {
111 p_cfg.put("device", "controlboardremapper");
112 p_cfg.put("joints", 4);
113 Value* jlist = Value::makeList("fakeboard1");
114 p_cfg.put("networks", jlist);
115 p_cfg.put("fakeboard1", "0 3 0 3");
117 }
118 {
120 p_cfg.put("device", "controlBoard_nws_yarp");
121 p_cfg.put("name", "/alljoints");
123 }
124 {
127 yarp::dev::PolyDriverList pdlist; pdlist.push(&ddfakemc,"fakeboard1");
128 bool result_att = ww_rem->attachAll(pdlist);
130 }
131 {
135 bool result_att = ww_nws->attachAll(pdlist);
137 }
138
140
141 IAxisInfo* iinfo = nullptr;
142 IControlMode* icmd = nullptr;
143 ddremapper.view(icmd);
144 ReturnValue retval;
145
146 std::vector<yarp::dev::ControlModeEnum> modes;
147 modes.resize(4);
148 retval = icmd->getControlModes(modes);
149 CHECK(!retval); // Expecting failure because the remapper has 4 joints but the underlying device has only 2
150
151 //"Close all polydrivers and check"
152 {
153 CHECK(ddnws.close());
156 }
157 }
158
159 SECTION("Testing an invalid configuration (chain of remappers)")
160 {
165
166 {
168 p_cfg.put("device", "fakeMotionControl");
169 p_cfg.put("name", "fakeboard1");
170 Property& grp = p_cfg.addGroup("GENERAL");
171 grp.put("Joints", 2);
173 }
174 {
176 p_cfg.put("device", "controlboardremapper");
177 p_cfg.put("joints", 4);
178 Value* jlist = Value::makeList("fakeboard1");
179 p_cfg.put("networks", jlist);
180 p_cfg.put("fakeboard1", "0 3 0 3");
182 }
183 {
185 p_cfg.put("device", "controlboardremapper");
186 p_cfg.put("joints", 4);
187 Value* jlist = Value::makeList("rema1");
188 p_cfg.put("networks", jlist);
189 p_cfg.put("rema1", "0 3 0 3");
191 }
192 {
194 p_cfg.put("device", "controlBoard_nws_yarp");
195 p_cfg.put("name", "/alljoints");
197 }
198 {
201 yarp::dev::PolyDriverList pdlist; pdlist.push(&ddfakemc,"fakeboard1");
202 bool result_att = ww_rem->attachAll(pdlist);
204 }
205 {
209 bool result_att = ww_rem->attachAll(pdlist);
211 }
212 {
216 bool result_att = ww_nws->attachAll(pdlist);
218 }
219
221
222 IAxisInfo* iinfo = nullptr;
223 IControlMode* icmd = nullptr;
224 ddremapper2.view(icmd);
225 ReturnValue retval;
226
227 std::vector<yarp::dev::ControlModeEnum> modes;
228 modes.resize(4);
229 retval = icmd->getControlModes(modes);
230 CHECK(!retval); // Expecting failure because the remapper has 4 joints but the underlying device has only 2
231
232 //"Close all polydrivers and check"
233 {
234 CHECK(ddnws.close());
238 }
239 }
240
241 Network::setLocalMode(false);
242}
define control board standard interfaces
define control board standard interfaces
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:37
Interface for setting control mode in control board.
virtual yarp::dev::ReturnValue getControlModes(std::vector< yarp::dev::ControlModeEnum > &mode)=0
Get the current control mode (multiple joints).
Interface for an object that can wrap/attach to to another.
A container for a device driver.
Definition PolyDriver.h:23
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
A single value (typically within a Bottle).
Definition Value.h:44
static Value * makeList()
Create a list Value.
Definition Value.cpp:452
TEST_CASE("dev::ControlBoardRemapperTest4", "[yarp::dev]")
void exec_params_test(yarp::dev::PolyDriver *pdrv)
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