YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IControlModeTest.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 ICONTROLMODETEST_H
7#define ICONTROLMODETEST_H
8
11#include <yarp/dev/IAxisInfo.h>
12#include <catch2/catch_amalgamated.hpp>
13#include "TestUtils.h"
14
15using namespace yarp::dev;
16using namespace yarp::os;
17
18namespace yarp::dev::tests
19{
21 {
22 REQUIRE(icmd != nullptr);
23 bool b = false;
24 b = icmd->setControlMode(0, mode);
25 CHECK(b);
26 wait_safe(); // Allow some time for the command to take effect
27
29 b = icmd->getControlMode(0, ret);
30 CHECK(b);
32 }
33
35 {
36 REQUIRE(icmd != nullptr);
37 REQUIRE(iinfo != nullptr);
38 size_t ax = 0; bool bax = false;
39 bax = iinfo->getAxes(ax);
40 REQUIRE(bax);
41 REQUIRE(ax==2);
42
43 bool b = false;
44 std::vector<SelectableControlModeEnum> modes (2);
45 modes[0]=mode;
46 modes[1]=mode;
47 b = icmd->setControlModes(modes);
48 CHECK(b);
49 wait_safe(); // Allow some time for the command to take effect
50
51 std::vector<ControlModeEnum> rets (2);
52 b = icmd->getControlModes(rets);
53 CHECK(b);
56 }
57
59 {
60 REQUIRE(icmd != nullptr);
61 REQUIRE(iinfo != nullptr);
62 size_t ax=0; bool bax= false;
63 bax=iinfo->getAxes(ax);
64 REQUIRE (bax);
65 REQUIRE (ax==2);
66
67 bool b = false;
68 std::vector <SelectableControlModeEnum> modes (2);
69 modes[0] = mode;
70 modes[1] = mode;
71 std::vector<int> joints (2);
72 joints[0] = 0;
73 joints[1] = 1;
74 b = icmd->setControlModes(joints,modes);
75 CHECK(b);
76 wait_safe(); // Allow some time for the command to take effect
77
78 std::vector<ControlModeEnum> rets (2);
79 b = icmd->getControlModes(joints,rets);
80 CHECK(b);
83 }
84
86 {
87 REQUIRE(icmd != nullptr);
88 test_single_joint(icmd, iinfo, mode);
89 test_all_joints(icmd, iinfo, mode);
90 test_multi_joint(icmd, iinfo, mode);
91 }
92
94 {
95 REQUIRE(icmd != nullptr);
96 REQUIRE(iinfo != nullptr);
97
98 bool b= false;
99 size_t ax=0;
100 std::string name_ret;
102
103 b = iinfo->getAxes(ax);
104 CHECK(b); CHECK(ax>0);
105 b = iinfo->getAxisName(0, name_ret);
106 CHECK(b); CHECK (!name_ret.empty());
107 b = iinfo->getJointType(0, jointtype_ret);
109
110
111 // get available control modes
112 {
113 bool b;
114 std::vector<yarp::dev::SelectableControlModeEnum> avail;
115 b = icmd->getAvailableControlModes(0, avail);
116 CHECK(b);
117 CHECK(avail.size() == 10); // expected presence of 10 control modes
118 }
119
131 }
132}
133
134#endif
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 getControlMode(int j, yarp::dev::ControlModeEnum &mode)=0
Get the current control mode.
virtual yarp::dev::ReturnValue getControlModes(std::vector< yarp::dev::ControlModeEnum > &mode)=0
Get the current control mode (multiple joints).
virtual yarp::dev::ReturnValue setControlModes(const std::vector< int > &joints, const std::vector< yarp::dev::SelectableControlModeEnum > &mode)=0
Set the current control mode for a subset of axes.
virtual yarp::dev::ReturnValue setControlMode(int j, yarp::dev::SelectableControlModeEnum mode)=0
Set the current control mode.
virtual yarp::dev::ReturnValue getAvailableControlModes(int j, std::vector< yarp::dev::SelectableControlModeEnum > &avail)=0
Return a list of available control mode for the given joint.
A mini-server for performing network communication in the background.
void test_joint(IControlMode *icmd, IAxisInfo *iinfo, SelectableControlModeEnum mode)
void test_single_joint(IControlMode *icmd, IAxisInfo *iinfo, SelectableControlModeEnum mode)
void wait_safe(const double seconds)
Definition TestUtils.cpp:17
void test_multi_joint(IControlMode *icmd, IAxisInfo *iinfo, SelectableControlModeEnum mode)
void test_all_joints(IControlMode *icmd, IAxisInfo *iinfo, SelectableControlModeEnum mode)
void exec_iControlMode_test_1(IControlMode *icmd, IAxisInfo *iinfo)
For streams capable of holding different kinds of content, check what they actually have.
SelectableControlModeEnum
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13