YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ITorqueControlTest.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 ITORQUECONTROLTEST_H
7#define ITORQUECONTROLTEST_H
8
9#include <vector>
10#include <numeric>
11
14#include <catch2/catch_amalgamated.hpp>
15
16using namespace yarp::dev;
17using namespace yarp::os;
18
19namespace yarp::dev::tests
20{
22 {
23 REQUIRE(itrq != nullptr);
24 REQUIRE(icmd != nullptr);
25
26 bool b;
27
28 int ax;
29 b = itrq->getAxes(&ax);
30 CHECK(b);
31 REQUIRE(ax > 0);
32
33 for (size_t i = 0; i < ax; i++)
34 {
35 b = icmd->setControlMode(i, VOCAB_CM_TORQUE);
36 CHECK(b);
37 }
38
40 //params.bemf = 0.1;
41 //params.bemf_scale = 0.2;
42 //params.ktau = 0.3;
43 //params.ktau_scale = 0.4;
44 params.viscousPos = 0.5;
45 params.viscousNeg = 0.6;
46 params.coulombPos = 0.7;
47 params.coulombNeg = 0.8;
48 params.velocityThres = 0.9;
49 b= itrq->setMotorTorqueParams(0, params);
50 CHECK(b);
51
53 b= itrq->getMotorTorqueParams(0, &res);
54 CHECK(b);
55 //CHECK(res.bemf == 0.1); // interface seems functional
56 //CHECK(res.bemf_scale == 0.2); // interface seems functional
57 //CHECK(res.ktau == 0.3); // interface seems functional
58 //CHECK(res.ktau_scale == 0.4); // interface seems functional
59 CHECK(res.viscousPos == 0.5); // interface seems functional
60 CHECK(res.viscousNeg == 0.6); // interface seems functional
61 CHECK(res.coulombPos == 0.7); // interface seems functional
62 CHECK(res.coulombNeg == 0.8); // interface seems functional
63 CHECK(res.velocityThres == 0.9); // interface seems functional
64 }
65
67 {
68 REQUIRE(itrq != nullptr);
69 REQUIRE(icmd != nullptr);
70
71 bool b;
72 int ax;
73 double val, val1, val2;
75
76 b = itrq->getAxes(&ax);
77 CHECK(b);
78 REQUIRE(ax > 0);
79
80 for (size_t i = 0; i < ax; i++)
81 {
82 b = icmd->setControlMode(i, VOCAB_CM_TORQUE);
83 //CHECK(b); //this will fail
84 }
85
86 auto vals = std::vector<double>(ax);
87 auto refvals = std::vector<double>(ax);
88 auto vals1 = std::vector<double>(ax);
89 auto vals2 = std::vector<double>(ax);
90
91 b = itrq->setMotorTorqueParams(0, param);
92 CHECK(!b);
93
94 b = itrq->getMotorTorqueParams(0, &param);
95 CHECK(!b);
96
97 b = itrq->getRefTorque(0, &val);
98 CHECK(!b);
99
100 b = itrq->getRefTorques(refvals.data());
101 CHECK(!b);
102
103 b = itrq->getTorque(0,&val);
104 CHECK(!b);
105
106 b = itrq->getTorqueRange(0, &val1, &val2);
107 CHECK(!b);
108
109 b = itrq->getTorqueRanges(vals1.data(), vals2.data());
110 CHECK(!b);
111
112 b = itrq->getTorques(vals.data()); //streaming
113 // CHECK(!b); //this is streaming, it will return true if data is arrived in time
114
115 b = itrq->setRefTorque(0,val); //streaming
116 // CHECK(!b); //this is streaming, it will return true always
117
118 b = itrq->setRefTorques(refvals.data()); //streaming
119 // CHECK(!b); //this is streaming, it will return true always
120
121 }
122}
123
124#endif
constexpr yarp::conf::vocab32_t VOCAB_CM_TORQUE
Interface for setting control mode in control board.
virtual bool setControlMode(const int j, const int mode)=0
Set the current control mode.
Interface for control boards implementing torque control.
A mini-server for performing network communication in the background.
void exec_iTorqueControl_test_unimplemented_interface(ITorqueControl *itrq, IControlMode *icmd)
void exec_iTorqueControl_test_1(ITorqueControl *itrq, IControlMode *icmd)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.