YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IPidControlTest.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 IPIDCONTROLTEST_H
7#define IPIDCONTROLTEST_H
8
11#include <yarp/dev/IAxisInfo.h>
12#include <catch2/catch_amalgamated.hpp>
13
14using namespace yarp::dev;
15using namespace yarp::os;
16
17namespace yarp::dev::tests
18{
20 {
21 REQUIRE(ipid != nullptr);
22 REQUIRE(iaxis != nullptr);
23
24 int ax;
25 bool b = false;
26
27 b = iaxis->getAxes(&ax);
28 CHECK(b);
29 REQUIRE(ax > 0);
30
32 b = ipid->disablePid(pp,0);
33 CHECK(b);
34
35 b = ipid->enablePid(pp,0);
36 CHECK(b);
37
38 bool enabled;
39 b = ipid->isPidEnabled(pp, 0, &enabled);
40 CHECK(b);
41
43 b=ipid->getPid(pp,0, &retpid);
44 CHECK(b);
45
46 auto retpids = std::vector<yarp::dev::Pid>(ax);
47 b= ipid->getPids(pp, retpids.data());
48 CHECK(b);
49
51 b = ipid->setPid(pp, 0, setpid);
52 CHECK(b);
53
54 auto setpids = std::vector<yarp::dev::Pid>(ax);
55 b = ipid->setPids(pp, setpids.data());
56 CHECK(b);
57
58 b = ipid->resetPid(pp,0);
59 CHECK(b);
60
61 b = ipid->setPidOffset(pp,0,0);
62 CHECK(b);
63
64 double getpidref=0;
65 b = ipid->getPidReference(pp, 0, &getpidref);
66 CHECK(b);
67
68 auto getpidrefs = std::vector<double>(ax);
69 b = ipid->getPidReferences(pp, getpidrefs.data());
70 CHECK(b);
71
72 double setpidref=0;
73 b = ipid->setPidReference(pp, 0, setpidref);
74 CHECK(b);
75
76 auto setpidrefs = std::vector<double>(ax);
77 b = ipid->setPidReferences(pp, setpidrefs.data());
78 CHECK(b);
79
80 double errlim=0;
81 b = ipid->getPidErrorLimit(pp, 0, &errlim);
82 CHECK(b);
83
84 auto errlims = std::vector<double>(ax);
85 b = ipid->getPidErrorLimits(pp, errlims.data());
86 CHECK(b);
87 }
88
90 {
92 testpid.setKp(1); CHECK(testpid.kp ==1);
93 testpid.setKd(2); CHECK(testpid.kd == 2);
94 testpid.setKff(3); CHECK(testpid.kff == 3);
95 testpid.setKi(4); CHECK(testpid.ki == 4);
96 testpid.setMaxInt(5); CHECK(testpid.max_int == 5);
97 testpid.setMaxOut(6); CHECK(testpid.max_output == 6);
98 testpid.setOffset(7); CHECK(testpid.offset == 7);
99 testpid.setScale(8); CHECK(testpid.scale == 8);
100 testpid.setStictionValues(9,10);
101 CHECK(testpid.stiction_up_val == 9);
102 CHECK(testpid.stiction_down_val==10);
103
106
108 testpid2.clear();
110
111 yarp::dev::Pid testpid3 (1,2,3,4,5,6);
112 CHECK(testpid3.kp == 1);
113 CHECK(testpid3.kd == 2);
114 CHECK(testpid3.ki == 3);
115 CHECK(testpid3.max_int == 4);
116 CHECK(testpid3.scale == 5);
117 CHECK(testpid3.max_output == 6);
118
119 yarp::dev::Pid testpid4 (1,2,3,4,5,6,7,8,9);
120 CHECK(testpid4.kp == 1);
121 CHECK(testpid4.kd == 2);
122 CHECK(testpid4.ki == 3);
123 CHECK(testpid4.max_int == 4);
124 CHECK(testpid4.scale == 5);
125 CHECK(testpid4.max_output == 6);
126 CHECK(testpid4.stiction_up_val == 7);
127 CHECK(testpid4.stiction_down_val == 8);
128 CHECK(testpid4.kff == 9);
129 }
130
131}
132
133#endif
define control board standard interfaces
Interface for getting information about specific axes, if available.
Definition IAxisInfo.h:36
Interface for a generic control board device implementing a PID controller, with scaled arguments.
Contains the parameters for a PID.
A mini-server for performing network communication in the background.
void exec_iPidControl_test_1(IPidControl *ipid, IAxisInfo *iaxis)
void exec_iPidControl_test_2(IPidControl *ipid)
For streams capable of holding different kinds of content, check what they actually have.
PidControlTypeEnum
Definition PidEnums.h:15
@ VOCAB_PIDTYPE_POSITION
Definition PidEnums.h:16
An interface to the operating system, including Port based communication.