YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IJoypadControllerTest.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef IJOYPADCONTROLLERTEST_H
7#define IJOYPADCONTROLLERTEST_H
8
10#include <catch2/catch_amalgamated.hpp>
11
12using namespace yarp::dev;
13using namespace yarp::os;
14
15namespace yarp::dev::tests
16{
18 {
19 REQUIRE(iJoy != nullptr);
20
21 bool b=false;
22 size_t count=0;
23 double value=0;
24
25 b = iJoy->getAxisCount(count);
26 CHECK(b);
27 CHECK(count==4);
28
29 b = iJoy->getButtonCount(count);
30 CHECK(b);
31 CHECK(count==4);
32
33 b = iJoy->getHatCount(count);
34 CHECK(b);
35 CHECK(count==4);
36
37 b = iJoy->getStickCount(count);
38 CHECK(b);
39 CHECK(count==4);
40
41 b = iJoy->getTouchSurfaceCount(count);
42 CHECK(b);
43 CHECK(count==4);
44
45 b = iJoy->getTrackballCount(count);
46 CHECK(b);
47 CHECK(count==4);
48
49 //-----
50
51 std::vector<double> axesvals;
52 b = iJoy->getAllAxes(axesvals);
53 CHECK(b);
54 REQUIRE(axesvals.size() == 4);
55 for (size_t i=0; i<4; i++)
56 {
57 CHECK (axesvals[i] == i*10);
58 }
59
60 //-----
61
62 for (size_t i=0; i<4; i++)
63 {
64 b = iJoy->getAxis(i, value);
65 CHECK(b);
66 CHECK(value == i*10);
67 }
68
69 for (size_t i=0; i<4; i++)
70 {
71 b = iJoy->getButton(i, value);
72 CHECK(b);
73 CHECK(value == i*11);
74 }
75
76 for (size_t i=0; i<4; i++)
77 {
78 unsigned char hatdata;
79 b = iJoy->getHat(i, hatdata);
80 CHECK(b);
81 CHECK(hatdata == i*12);
82 }
83
84 for (size_t i=0; i<4; i++)
85 {
88 CHECK(b);
89 CHECK(sdata.s1 == i*100);
90 CHECK(sdata.s2 == i*101);
91 }
92 for (size_t i=0; i<4; i++)
93 {
96 CHECK(b);
97 CHECK(sdata.s1 == i*102);
98 CHECK(sdata.s2 == i*103);
99 }
100
101
102 for (size_t i=0; i<4; i++)
103 {
104 std::vector<yarp::dev::TouchData> tval;
105 b = iJoy->getTouch(i, tval);
106 CHECK(b);
107 REQUIRE(tval.size()==2);
108 CHECK(tval[0].x == i * 110);
109 CHECK(tval[0].y == i * 111);
110 CHECK(tval[1].x == i * 112);
111 CHECK(tval[1].y == i * 113);
112 }
113
114 for (size_t i=0; i<4; i++)
115 {
117 b = iJoy->getTrackball(i, tdata);
118 CHECK(b);
119 CHECK(tdata.x == i*120);
120 CHECK(tdata.y == i*121);
121 }
122
123 }
124}
125
126#endif
A mini-server for performing network communication in the background.
void exec_iJoypadController_test_1(yarp::dev::IJoypadController *iJoy)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.