2021-11-23 23:34:46 -05:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
2023-08-28 15:13:34 -07:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
2021-11-23 23:34:46 -05:00
|
|
|
#include "frc/controller/BangBangController.h"
|
|
|
|
|
|
2024-11-05 08:49:38 -08:00
|
|
|
TEST(BangBangToleranceTest, InTolerance) {
|
2021-11-23 23:34:46 -05:00
|
|
|
frc::BangBangController controller{0.1};
|
|
|
|
|
|
|
|
|
|
controller.SetSetpoint(1);
|
|
|
|
|
controller.Calculate(1);
|
|
|
|
|
EXPECT_TRUE(controller.AtSetpoint());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-05 08:49:38 -08:00
|
|
|
TEST(BangBangToleranceTest, OutOfTolerance) {
|
|
|
|
|
frc::BangBangController controller{0.1};
|
|
|
|
|
|
2021-11-23 23:34:46 -05:00
|
|
|
controller.SetSetpoint(1);
|
|
|
|
|
controller.Calculate(0);
|
|
|
|
|
EXPECT_FALSE(controller.AtSetpoint());
|
|
|
|
|
}
|