28 lines
480 B
C++
28 lines
480 B
C++
#include <unity.h>
|
|
|
|
//#include "p_controller.h"
|
|
#include "pi_controller.h"
|
|
|
|
static const double KP = 2.0;
|
|
static const double KI = 1.0;
|
|
static const double T = 0.1;
|
|
static const double TOL = 1e-4; // Tolerance
|
|
|
|
void test_positive_error()
|
|
{
|
|
PI_controller controller(KP, KI, T);
|
|
|
|
double output = controller.update(10.0, 8.0);
|
|
|
|
TEST_ASSERT_DOUBLE_WITHIN(TOL, 4.4, output);
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
UNITY_BEGIN();
|
|
|
|
RUN_TEST(test_positive_error);
|
|
|
|
return UNITY_END();
|
|
} |