Tyler Chatow | 1258156 | 2019-01-26 20:42:42 -0800 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_ |
| 3 | |
Tyler Chatow | 1258156 | 2019-01-26 20:42:42 -0800 | [diff] [blame] | 4 | #include "gtest/gtest.h" |
| 5 | |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 6 | #include "frc971/control_loops/state_feedback_loop.h" |
| 7 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 8 | namespace frc971::control_loops { |
Tyler Chatow | 1258156 | 2019-01-26 20:42:42 -0800 | [diff] [blame] | 9 | |
| 10 | // Basic state feedback plant for use in tests. |
| 11 | class 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 Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 30 | } // namespace frc971::control_loops |
Austin Schuh | b39f452 | 2022-03-27 13:29:42 -0700 | [diff] [blame] | 31 | #endif // FRC971_CONTROL_LOOPS_CAPPED_TEST_PLANT_H_ |