blob: 4171719b50094a7ec9c2c25829c93b6ac8be7378 [file] [log] [blame]
Tyler Chatow12581562019-01-26 20:42:42 -08001#ifndef FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_
2#define FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_
3
Tyler Chatow12581562019-01-26 20:42:42 -08004#include "gtest/gtest.h"
5
Philipp Schrader790cb542023-07-05 21:06:52 -07006#include "frc971/control_loops/state_feedback_loop.h"
7
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08008namespace frc971::control_loops {
Tyler Chatow12581562019-01-26 20:42:42 -08009
10// Basic state feedback plant for use in tests.
11class CappedTestPlant : public StateFeedbackPlant<2, 1, 1> {
12 public:
13 explicit CappedTestPlant(StateFeedbackPlant<2, 1, 1> &&other)
14 : StateFeedbackPlant<2, 1, 1>(::std::move(other)) {}
15
16 void CheckU(const ::Eigen::Matrix<double, 1, 1> &U) override {
17 EXPECT_LE(U(0, 0), U_max(0, 0) + 0.00001 + voltage_offset_);
18 EXPECT_GE(U(0, 0), U_min(0, 0) - 0.00001 + voltage_offset_);
19 }
20
21 double voltage_offset() const { return voltage_offset_; }
22 void set_voltage_offset(double voltage_offset) {
23 voltage_offset_ = voltage_offset;
24 }
25
26 private:
27 double voltage_offset_ = 0.0;
28};
29
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080030} // namespace frc971::control_loops
Austin Schuhb39f4522022-03-27 13:29:42 -070031#endif // FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_