Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_STATE_FEEDBACK_LOOP_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_STATE_FEEDBACK_LOOP_H_ |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 3 | |
Austin Schuh | 849f003 | 2013-03-03 23:59:53 -0800 | [diff] [blame] | 4 | #include <assert.h> |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 5 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 6 | #include <iostream> |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 7 | #include <memory> |
| 8 | #include <utility> |
| 9 | #include <vector> |
Brian Silverman | c571e05 | 2013-03-13 17:58:56 -0700 | [diff] [blame] | 10 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 11 | #include "Eigen/Dense" |
| 12 | |
Austin Schuh | cda86af | 2014-02-16 16:16:39 -0800 | [diff] [blame] | 13 | #include "aos/common/logging/logging.h" |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 14 | #include "aos/common/macros.h" |
| 15 | |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 16 | // For everything in this file, "inputs" and "outputs" are defined from the |
| 17 | // perspective of the plant. This means U is an input and Y is an output |
| 18 | // (because you give the plant U (powers) and it gives you back a Y (sensor |
| 19 | // values). This is the opposite of what they mean from the perspective of the |
| 20 | // controller (U is an output because that's what goes to the motors and Y is an |
| 21 | // input because that's what comes back from the sensors). |
| 22 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 23 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 24 | struct StateFeedbackPlantCoefficients final { |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 25 | public: |
| 26 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
| 27 | |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 28 | StateFeedbackPlantCoefficients(const StateFeedbackPlantCoefficients &other) |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 29 | : A(other.A), |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 30 | A_inv(other.A_inv), |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 31 | A_continuous(other.A_continuous), |
| 32 | B(other.B), |
| 33 | B_continuous(other.B_continuous), |
| 34 | C(other.C), |
| 35 | D(other.D), |
| 36 | U_min(other.U_min), |
| 37 | U_max(other.U_max) {} |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 38 | |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 39 | StateFeedbackPlantCoefficients( |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 40 | const Eigen::Matrix<double, number_of_states, number_of_states> &A, |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 41 | const Eigen::Matrix<double, number_of_states, number_of_states> &A_inv, |
Austin Schuh | 6c20f20 | 2017-02-18 22:31:44 -0800 | [diff] [blame] | 42 | const Eigen::Matrix<double, number_of_states, number_of_states> |
| 43 | &A_continuous, |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 44 | const Eigen::Matrix<double, number_of_states, number_of_inputs> &B, |
Austin Schuh | 6c20f20 | 2017-02-18 22:31:44 -0800 | [diff] [blame] | 45 | const Eigen::Matrix<double, number_of_states, number_of_inputs> |
| 46 | &B_continuous, |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 47 | const Eigen::Matrix<double, number_of_outputs, number_of_states> &C, |
| 48 | const Eigen::Matrix<double, number_of_outputs, number_of_inputs> &D, |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 49 | const Eigen::Matrix<double, number_of_inputs, 1> &U_max, |
| 50 | const Eigen::Matrix<double, number_of_inputs, 1> &U_min) |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 51 | : A(A), |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 52 | A_inv(A_inv), |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 53 | A_continuous(A_continuous), |
| 54 | B(B), |
| 55 | B_continuous(B_continuous), |
| 56 | C(C), |
| 57 | D(D), |
| 58 | U_min(U_min), |
| 59 | U_max(U_max) {} |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 60 | |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 61 | const Eigen::Matrix<double, number_of_states, number_of_states> A; |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 62 | const Eigen::Matrix<double, number_of_states, number_of_states> A_inv; |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 63 | const Eigen::Matrix<double, number_of_states, number_of_states> A_continuous; |
| 64 | const Eigen::Matrix<double, number_of_states, number_of_inputs> B; |
| 65 | const Eigen::Matrix<double, number_of_states, number_of_inputs> B_continuous; |
| 66 | const Eigen::Matrix<double, number_of_outputs, number_of_states> C; |
| 67 | const Eigen::Matrix<double, number_of_outputs, number_of_inputs> D; |
| 68 | const Eigen::Matrix<double, number_of_inputs, 1> U_min; |
| 69 | const Eigen::Matrix<double, number_of_inputs, 1> U_max; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
| 73 | class StateFeedbackPlant { |
| 74 | public: |
| 75 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 76 | |
| 77 | StateFeedbackPlant( |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 78 | ::std::vector<::std::unique_ptr<StateFeedbackPlantCoefficients< |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 79 | number_of_states, number_of_inputs, number_of_outputs>>> |
| 80 | *coefficients) |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 81 | : coefficients_(::std::move(*coefficients)), index_(0) { |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 82 | Reset(); |
| 83 | } |
| 84 | |
| 85 | StateFeedbackPlant(StateFeedbackPlant &&other) |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 86 | : index_(other.index_) { |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 87 | ::std::swap(coefficients_, other.coefficients_); |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 88 | X_.swap(other.X_); |
| 89 | Y_.swap(other.Y_); |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Austin Schuh | 1a38796 | 2015-01-31 16:36:20 -0800 | [diff] [blame] | 92 | virtual ~StateFeedbackPlant() {} |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 93 | |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 94 | const Eigen::Matrix<double, number_of_states, number_of_states> &A() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 95 | return coefficients().A; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 96 | } |
| 97 | double A(int i, int j) const { return A()(i, j); } |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 98 | const Eigen::Matrix<double, number_of_states, number_of_states> &A_inv() const { |
| 99 | return coefficients().A_inv; |
| 100 | } |
| 101 | double A_inv(int i, int j) const { return A_inv()(i, j); } |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 102 | const Eigen::Matrix<double, number_of_states, number_of_inputs> &B() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 103 | return coefficients().B; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 104 | } |
| 105 | double B(int i, int j) const { return B()(i, j); } |
| 106 | const Eigen::Matrix<double, number_of_outputs, number_of_states> &C() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 107 | return coefficients().C; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 108 | } |
| 109 | double C(int i, int j) const { return C()(i, j); } |
| 110 | const Eigen::Matrix<double, number_of_outputs, number_of_inputs> &D() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 111 | return coefficients().D; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 112 | } |
| 113 | double D(int i, int j) const { return D()(i, j); } |
| 114 | const Eigen::Matrix<double, number_of_inputs, 1> &U_min() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 115 | return coefficients().U_min; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 116 | } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 117 | double U_min(int i, int j) const { return U_min()(i, j); } |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 118 | const Eigen::Matrix<double, number_of_inputs, 1> &U_max() const { |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 119 | return coefficients().U_max; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 120 | } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 121 | double U_max(int i, int j) const { return U_max()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 122 | |
| 123 | const Eigen::Matrix<double, number_of_states, 1> &X() const { return X_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 124 | double X(int i, int j) const { return X()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 125 | const Eigen::Matrix<double, number_of_outputs, 1> &Y() const { return Y_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 126 | double Y(int i, int j) const { return Y()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 127 | |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 128 | Eigen::Matrix<double, number_of_states, 1> &mutable_X() { return X_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 129 | double &mutable_X(int i, int j) { return mutable_X()(i, j); } |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 130 | Eigen::Matrix<double, number_of_outputs, 1> &mutable_Y() { return Y_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 131 | double &mutable_Y(int i, int j) { return mutable_Y()(i, j); } |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 132 | |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 133 | const StateFeedbackPlantCoefficients<number_of_states, number_of_inputs, |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 134 | number_of_outputs> |
| 135 | &coefficients(int index) const { |
| 136 | return *coefficients_[index]; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 139 | const StateFeedbackPlantCoefficients<number_of_states, number_of_inputs, |
| 140 | number_of_outputs> |
| 141 | &coefficients() const { |
| 142 | return *coefficients_[index_]; |
| 143 | } |
| 144 | |
| 145 | int index() const { return index_; } |
| 146 | void set_index(int index) { |
| 147 | assert(index >= 0); |
| 148 | assert(index < static_cast<int>(coefficients_.size())); |
| 149 | index_ = index; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | void Reset() { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 153 | X_.setZero(); |
| 154 | Y_.setZero(); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 155 | } |
| 156 | |
Austin Schuh | 849f003 | 2013-03-03 23:59:53 -0800 | [diff] [blame] | 157 | // Assert that U is within the hardware range. |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 158 | virtual void CheckU(const Eigen::Matrix<double, number_of_inputs, 1> &U) { |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 159 | for (int i = 0; i < kNumInputs; ++i) { |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 160 | if (U(i, 0) > U_max(i, 0) + 0.00001 || U(i, 0) < U_min(i, 0) - 0.00001) { |
| 161 | LOG(FATAL, "U out of range\n"); |
| 162 | } |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 163 | } |
| 164 | } |
Austin Schuh | 849f003 | 2013-03-03 23:59:53 -0800 | [diff] [blame] | 165 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 166 | // Computes the new X and Y given the control input. |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 167 | void Update(const Eigen::Matrix<double, number_of_inputs, 1> &U) { |
Austin Schuh | 849f003 | 2013-03-03 23:59:53 -0800 | [diff] [blame] | 168 | // Powers outside of the range are more likely controller bugs than things |
| 169 | // that the plant should deal with. |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 170 | CheckU(U); |
| 171 | X_ = A() * X() + B() * U; |
| 172 | Y_ = C() * X() + D() * U; |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | protected: |
| 176 | // these are accessible from non-templated subclasses |
Austin Schuh | b1cdb38 | 2013-03-01 22:53:52 -0800 | [diff] [blame] | 177 | static const int kNumStates = number_of_states; |
| 178 | static const int kNumOutputs = number_of_outputs; |
| 179 | static const int kNumInputs = number_of_inputs; |
Austin Schuh | e349062 | 2013-03-13 01:24:30 -0700 | [diff] [blame] | 180 | |
| 181 | private: |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 182 | Eigen::Matrix<double, number_of_states, 1> X_; |
| 183 | Eigen::Matrix<double, number_of_outputs, 1> Y_; |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 184 | |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 185 | ::std::vector<::std::unique_ptr<StateFeedbackPlantCoefficients< |
Austin Schuh | 64f17a5 | 2017-02-25 14:41:58 -0800 | [diff] [blame] | 186 | number_of_states, number_of_inputs, number_of_outputs>>> |
| 187 | coefficients_; |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 188 | |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 189 | int index_; |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 190 | |
| 191 | DISALLOW_COPY_AND_ASSIGN(StateFeedbackPlant); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 194 | // A container for all the controller coefficients. |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 195 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 196 | struct StateFeedbackControllerCoefficients final { |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 197 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 198 | |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 199 | const Eigen::Matrix<double, number_of_inputs, number_of_states> K; |
Austin Schuh | 86093ad | 2016-02-06 14:29:34 -0800 | [diff] [blame] | 200 | const Eigen::Matrix<double, number_of_inputs, number_of_states> Kff; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 201 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 202 | StateFeedbackControllerCoefficients( |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 203 | const Eigen::Matrix<double, number_of_inputs, number_of_states> &K, |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 204 | const Eigen::Matrix<double, number_of_inputs, number_of_states> &Kff) |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 205 | : K(K), Kff(Kff) {} |
| 206 | }; |
| 207 | |
| 208 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
| 209 | class StateFeedbackController { |
| 210 | public: |
| 211 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
| 212 | |
| 213 | explicit StateFeedbackController( |
| 214 | ::std::vector<::std::unique_ptr<StateFeedbackControllerCoefficients< |
| 215 | number_of_states, number_of_inputs, number_of_outputs>>> *controllers) |
| 216 | : coefficients_(::std::move(*controllers)) {} |
| 217 | |
| 218 | StateFeedbackController(StateFeedbackController &&other) |
| 219 | : index_(other.index_) { |
| 220 | ::std::swap(coefficients_, other.coefficients_); |
| 221 | } |
| 222 | |
| 223 | const Eigen::Matrix<double, number_of_inputs, number_of_states> &K() const { |
| 224 | return coefficients().K; |
| 225 | } |
| 226 | double K(int i, int j) const { return K()(i, j); } |
| 227 | const Eigen::Matrix<double, number_of_inputs, number_of_states> &Kff() const { |
| 228 | return coefficients().Kff; |
| 229 | } |
| 230 | double Kff(int i, int j) const { return Kff()(i, j); } |
| 231 | const Eigen::Matrix<double, number_of_states, number_of_outputs> &L() const { |
| 232 | return coefficients().L; |
| 233 | } |
| 234 | double L(int i, int j) const { return L()(i, j); } |
| 235 | |
| 236 | // Sets the current controller to be index, clamped to be within range. |
| 237 | void set_index(int index) { |
| 238 | if (index < 0) { |
| 239 | index_ = 0; |
| 240 | } else if (index >= static_cast<int>(coefficients_.size())) { |
| 241 | index_ = static_cast<int>(coefficients_.size()) - 1; |
| 242 | } else { |
| 243 | index_ = index; |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | int index() const { return index_; } |
| 248 | |
| 249 | const StateFeedbackControllerCoefficients<number_of_states, number_of_inputs, |
| 250 | number_of_outputs> |
| 251 | &coefficients(int index) const { |
| 252 | return *coefficients_[index]; |
| 253 | } |
| 254 | |
| 255 | const StateFeedbackControllerCoefficients<number_of_states, number_of_inputs, |
| 256 | number_of_outputs> |
| 257 | &coefficients() const { |
| 258 | return *coefficients_[index_]; |
| 259 | } |
| 260 | |
| 261 | private: |
| 262 | int index_ = 0; |
| 263 | ::std::vector<::std::unique_ptr<StateFeedbackControllerCoefficients< |
| 264 | number_of_states, number_of_inputs, number_of_outputs>>> |
| 265 | coefficients_; |
| 266 | }; |
| 267 | |
| 268 | |
| 269 | // A container for all the observer coefficients. |
| 270 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
| 271 | struct StateFeedbackObserverCoefficients final { |
| 272 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
| 273 | |
| 274 | const Eigen::Matrix<double, number_of_states, number_of_outputs> L; |
| 275 | |
| 276 | StateFeedbackObserverCoefficients( |
| 277 | const Eigen::Matrix<double, number_of_states, number_of_outputs> &L) |
| 278 | : L(L) {} |
| 279 | }; |
| 280 | |
| 281 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
| 282 | class StateFeedbackObserver { |
| 283 | public: |
| 284 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
| 285 | |
| 286 | explicit StateFeedbackObserver( |
| 287 | ::std::vector<::std::unique_ptr<StateFeedbackObserverCoefficients< |
| 288 | number_of_states, number_of_inputs, number_of_outputs>>> *observers) |
| 289 | : coefficients_(::std::move(*observers)) {} |
| 290 | |
| 291 | StateFeedbackObserver(StateFeedbackObserver &&other) |
| 292 | : index_(other.index_) { |
| 293 | ::std::swap(coefficients_, other.coefficients_); |
| 294 | } |
| 295 | |
| 296 | const Eigen::Matrix<double, number_of_states, number_of_outputs> &L() const { |
| 297 | return coefficients().L; |
| 298 | } |
| 299 | double L(int i, int j) const { return L()(i, j); } |
| 300 | |
| 301 | // Sets the current controller to be index, clamped to be within range. |
| 302 | void set_index(int index) { |
| 303 | if (index < 0) { |
| 304 | index_ = 0; |
| 305 | } else if (index >= static_cast<int>(coefficients_.size())) { |
| 306 | index_ = static_cast<int>(coefficients_.size()) - 1; |
| 307 | } else { |
| 308 | index_ = index; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | int index() const { return index_; } |
| 313 | |
| 314 | const StateFeedbackObserverCoefficients<number_of_states, number_of_inputs, |
| 315 | number_of_outputs> |
| 316 | &coefficients(int index) const { |
| 317 | return *coefficients_[index]; |
| 318 | } |
| 319 | |
| 320 | const StateFeedbackObserverCoefficients<number_of_states, number_of_inputs, |
| 321 | number_of_outputs> |
| 322 | &coefficients() const { |
| 323 | return *coefficients_[index_]; |
| 324 | } |
| 325 | |
| 326 | private: |
| 327 | int index_ = 0; |
| 328 | ::std::vector<::std::unique_ptr<StateFeedbackObserverCoefficients< |
| 329 | number_of_states, number_of_inputs, number_of_outputs>>> |
| 330 | coefficients_; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 331 | }; |
| 332 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 333 | template <int number_of_states, int number_of_inputs, int number_of_outputs> |
| 334 | class StateFeedbackLoop { |
| 335 | public: |
| 336 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW; |
| 337 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 338 | explicit StateFeedbackLoop( |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 339 | StateFeedbackPlant<number_of_states, number_of_inputs, number_of_outputs> |
| 340 | &&plant, |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 341 | StateFeedbackController<number_of_states, number_of_inputs, |
| 342 | number_of_outputs> &&controller, |
| 343 | StateFeedbackObserver<number_of_states, number_of_inputs, |
| 344 | number_of_outputs> &&observer) |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 345 | : plant_(::std::move(plant)), |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 346 | controller_(::std::move(controller)), |
| 347 | observer_(::std::move(observer)) { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 348 | Reset(); |
| 349 | } |
| 350 | |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 351 | StateFeedbackLoop(StateFeedbackLoop &&other) |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 352 | : plant_(::std::move(other.plant_)), |
| 353 | controller_(::std::move(other.controller_)), |
| 354 | observer_(::std::move(other.observer_)) { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 355 | X_hat_.swap(other.X_hat_); |
| 356 | R_.swap(other.R_); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 357 | next_R_.swap(other.next_R_); |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 358 | U_.swap(other.U_); |
| 359 | U_uncapped_.swap(other.U_uncapped_); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 360 | ff_U_.swap(other.ff_U_); |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Austin Schuh | 1a38796 | 2015-01-31 16:36:20 -0800 | [diff] [blame] | 363 | virtual ~StateFeedbackLoop() {} |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 364 | |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 365 | const Eigen::Matrix<double, number_of_states, number_of_outputs> &L() const { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 366 | return observer().L(); |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 367 | } |
| 368 | double L(int i, int j) const { return L()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 369 | |
| 370 | const Eigen::Matrix<double, number_of_states, 1> &X_hat() const { |
| 371 | return X_hat_; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 372 | } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 373 | double X_hat(int i, int j) const { return X_hat()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 374 | const Eigen::Matrix<double, number_of_states, 1> &R() const { return R_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 375 | double R(int i, int j) const { return R()(i, j); } |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 376 | const Eigen::Matrix<double, number_of_states, 1> &next_R() const { |
| 377 | return next_R_; |
| 378 | } |
| 379 | double next_R(int i, int j) const { return next_R()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 380 | const Eigen::Matrix<double, number_of_inputs, 1> &U() const { return U_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 381 | double U(int i, int j) const { return U()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 382 | const Eigen::Matrix<double, number_of_inputs, 1> &U_uncapped() const { |
| 383 | return U_uncapped_; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 384 | } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 385 | double U_uncapped(int i, int j) const { return U_uncapped()(i, j); } |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 386 | const Eigen::Matrix<double, number_of_inputs, 1> &ff_U() const { |
| 387 | return ff_U_; |
| 388 | } |
| 389 | double ff_U(int i, int j) const { return ff_U()(i, j); } |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 390 | |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 391 | Eigen::Matrix<double, number_of_states, 1> &mutable_X_hat() { return X_hat_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 392 | double &mutable_X_hat(int i, int j) { return mutable_X_hat()(i, j); } |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 393 | Eigen::Matrix<double, number_of_states, 1> &mutable_R() { return R_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 394 | double &mutable_R(int i, int j) { return mutable_R()(i, j); } |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 395 | Eigen::Matrix<double, number_of_states, 1> &mutable_next_R() { |
| 396 | return next_R_; |
| 397 | } |
| 398 | double &mutable_next_R(int i, int j) { return mutable_next_R()(i, j); } |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 399 | Eigen::Matrix<double, number_of_inputs, 1> &mutable_U() { return U_; } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 400 | double &mutable_U(int i, int j) { return mutable_U()(i, j); } |
Brian Silverman | 0ca790b | 2014-06-12 21:33:08 -0700 | [diff] [blame] | 401 | Eigen::Matrix<double, number_of_inputs, 1> &mutable_U_uncapped() { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 402 | return U_uncapped_; |
| 403 | } |
Brian Silverman | a21c3a2 | 2014-06-12 21:49:15 -0700 | [diff] [blame] | 404 | double &mutable_U_uncapped(int i, int j) { |
| 405 | return mutable_U_uncapped()(i, j); |
| 406 | } |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 407 | |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 408 | const StateFeedbackPlant<number_of_states, number_of_inputs, |
| 409 | number_of_outputs> |
| 410 | &plant() const { |
| 411 | return plant_; |
| 412 | } |
| 413 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 414 | const StateFeedbackController<number_of_states, number_of_inputs, |
| 415 | number_of_outputs> |
Austin Schuh | 66c1988 | 2017-02-25 13:36:28 -0800 | [diff] [blame] | 416 | &controller() const { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 417 | return controller_; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 420 | const StateFeedbackObserver<number_of_states, number_of_inputs, |
| 421 | number_of_outputs> |
| 422 | &observer() const { |
| 423 | return observer_; |
Austin Schuh | 2054f5f | 2013-10-27 14:54:10 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 426 | void Reset() { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 427 | X_hat_.setZero(); |
| 428 | R_.setZero(); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 429 | next_R_.setZero(); |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 430 | U_.setZero(); |
| 431 | U_uncapped_.setZero(); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 432 | ff_U_.setZero(); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | // If U is outside the hardware range, limit it before the plant tries to use |
| 436 | // it. |
| 437 | virtual void CapU() { |
Brian Silverman | 5808bcb | 2014-09-14 21:40:43 -0400 | [diff] [blame] | 438 | for (int i = 0; i < kNumInputs; ++i) { |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 439 | if (U(i, 0) > plant().U_max(i, 0)) { |
| 440 | U_(i, 0) = plant().U_max(i, 0); |
| 441 | } else if (U(i, 0) < plant().U_min(i, 0)) { |
| 442 | U_(i, 0) = plant().U_min(i, 0); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 447 | // Corrects X_hat given the observation in Y. |
| 448 | void Correct(const Eigen::Matrix<double, number_of_outputs, 1> &Y) { |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 449 | X_hat_ += |
| 450 | plant().A_inv() * L() * (Y - plant().C() * X_hat_ - plant().D() * U()); |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 451 | } |
| 452 | |
Austin Schuh | 3f862bb | 2016-02-27 14:48:05 -0800 | [diff] [blame] | 453 | const Eigen::Matrix<double, number_of_states, 1> error() const { |
| 454 | return R() - X_hat(); |
| 455 | } |
| 456 | |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 457 | // Returns the calculated controller power. |
| 458 | virtual const Eigen::Matrix<double, number_of_inputs, 1> ControllerOutput() { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 459 | // TODO(austin): Should this live in StateSpaceController? |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 460 | ff_U_ = FeedForward(); |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 461 | return controller().K() * error() + ff_U_; |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | // Calculates the feed forwards power. |
| 465 | virtual const Eigen::Matrix<double, number_of_inputs, 1> FeedForward() { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 466 | // TODO(austin): Should this live in StateSpaceController? |
| 467 | return controller().Kff() * (next_R() - plant().A() * R()); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 468 | } |
| 469 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 470 | // stop_motors is whether or not to output all 0s. |
Austin Schuh | f9286cd | 2014-02-11 00:51:09 -0800 | [diff] [blame] | 471 | void Update(bool stop_motors) { |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 472 | if (stop_motors) { |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 473 | U_.setZero(); |
| 474 | U_uncapped_.setZero(); |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 475 | ff_U_.setZero(); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 476 | } else { |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 477 | U_ = U_uncapped_ = ControllerOutput(); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 478 | CapU(); |
| 479 | } |
| 480 | |
Austin Schuh | c2b7774 | 2015-11-26 16:18:27 -0800 | [diff] [blame] | 481 | UpdateObserver(U_); |
Austin Schuh | 093535c | 2016-03-05 23:21:00 -0800 | [diff] [blame] | 482 | |
| 483 | UpdateFFReference(); |
| 484 | } |
| 485 | |
| 486 | // Updates R() after any CapU operations happen on U(). |
| 487 | void UpdateFFReference() { |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 488 | ff_U_ -= U_uncapped() - U(); |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 489 | if (!controller().Kff().isZero(0)) { |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 490 | R_ = plant().A() * R() + plant().B() * ff_U_; |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 491 | } |
Ben Fredrickson | 890c3fe | 2014-03-02 00:15:16 +0000 | [diff] [blame] | 492 | } |
| 493 | |
Austin Schuh | c2b7774 | 2015-11-26 16:18:27 -0800 | [diff] [blame] | 494 | void UpdateObserver(const Eigen::Matrix<double, number_of_inputs, 1> &new_u) { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 495 | // TODO(austin): Should this live in StateSpacePlant? |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 496 | X_hat_ = plant().A() * X_hat() + plant().B() * new_u; |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 497 | } |
| 498 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 499 | // Sets the current controller to be index. |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 500 | void set_index(int index) { |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 501 | controller_.set_index(index); |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 502 | plant_.set_index(index); |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 505 | int index() const { return plant_.index(); } |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 506 | |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 507 | protected: |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 508 | StateFeedbackPlant<number_of_states, number_of_inputs, number_of_outputs> |
| 509 | plant_; |
| 510 | |
Austin Schuh | 3250183 | 2017-02-25 18:32:56 -0800 | [diff] [blame^] | 511 | StateFeedbackController<number_of_states, number_of_inputs, number_of_outputs> |
| 512 | controller_; |
| 513 | |
| 514 | StateFeedbackObserver<number_of_states, number_of_inputs, number_of_outputs> |
| 515 | observer_; |
Austin Schuh | 2054f5f | 2013-10-27 14:54:10 -0700 | [diff] [blame] | 516 | |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 517 | // These are accessible from non-templated subclasses. |
Austin Schuh | f59b6bc | 2016-03-11 21:26:19 -0800 | [diff] [blame] | 518 | static constexpr int kNumStates = number_of_states; |
| 519 | static constexpr int kNumOutputs = number_of_outputs; |
| 520 | static constexpr int kNumInputs = number_of_inputs; |
| 521 | |
| 522 | // Portion of U which is based on the feed-forwards. |
| 523 | Eigen::Matrix<double, number_of_inputs, 1> ff_U_; |
Austin Schuh | 9644e1c | 2013-03-12 00:40:36 -0700 | [diff] [blame] | 524 | |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 525 | private: |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 526 | // Internal state estimate. |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 527 | Eigen::Matrix<double, number_of_states, 1> X_hat_; |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 528 | // Current goal (Used by the feed-back controller). |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 529 | Eigen::Matrix<double, number_of_states, 1> R_; |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 530 | // Goal to go to in the next cycle (Used by Feed-Forward controller.) |
| 531 | Eigen::Matrix<double, number_of_states, 1> next_R_; |
| 532 | // Computed output after being capped. |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 533 | Eigen::Matrix<double, number_of_inputs, 1> U_; |
Austin Schuh | b6a6d82 | 2016-02-08 00:20:40 -0800 | [diff] [blame] | 534 | // Computed output before being capped. |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 535 | Eigen::Matrix<double, number_of_inputs, 1> U_uncapped_; |
| 536 | |
Austin Schuh | c5fceb8 | 2017-02-25 16:24:12 -0800 | [diff] [blame] | 537 | int index_; |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 538 | |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 539 | DISALLOW_COPY_AND_ASSIGN(StateFeedbackLoop); |
Austin Schuh | dc1c84a | 2013-02-23 16:33:10 -0800 | [diff] [blame] | 540 | }; |
| 541 | |
Brian Silverman | 273d8a3 | 2014-05-10 22:19:09 -0700 | [diff] [blame] | 542 | #endif // FRC971_CONTROL_LOOPS_STATE_FEEDBACK_LOOP_H_ |