James Kuszmaul | fb0e0ae | 2014-03-25 07:04:47 -0700 | [diff] [blame] | 1 | #ifndef FRC971_CONTROL_LOOPS_COERCE_GOAL_H_ |
| 2 | #define FRC971_CONTROL_LOOPS_COERCE_GOAL_H_ |
| 3 | |
| 4 | #include "Eigen/Dense" |
| 5 | |
| 6 | #include "aos/controls/polytope.h" |
| 7 | |
| 8 | namespace frc971 { |
| 9 | namespace control_loops { |
| 10 | |
Brian Silverman | 6dd2c53 | 2014-03-29 23:34:39 -0700 | [diff] [blame^] | 11 | Eigen::Matrix<double, 2, 1> DoCoerceGoal(const aos::controls::HPolytope<2> ®ion, |
| 12 | const Eigen::Matrix<double, 1, 2> &K, |
| 13 | double w, |
| 14 | const Eigen::Matrix<double, 2, 1> &R, |
| 15 | bool *is_inside); |
| 16 | |
James Kuszmaul | fb0e0ae | 2014-03-25 07:04:47 -0700 | [diff] [blame] | 17 | // Intersects a line with a region, and finds the closest point to R. |
| 18 | // Finds a point that is closest to R inside the region, and on the line |
| 19 | // defined by K X = w. If it is not possible to find a point on the line, |
| 20 | // finds a point that is inside the region and closest to the line. |
Brian Silverman | 6dd2c53 | 2014-03-29 23:34:39 -0700 | [diff] [blame^] | 21 | static inline Eigen::Matrix<double, 2, 1> |
| 22 | CoerceGoal(const aos::controls::HPolytope<2> ®ion, |
| 23 | const Eigen::Matrix<double, 1, 2> &K, |
| 24 | double w, |
| 25 | const Eigen::Matrix<double, 2, 1> &R) { |
| 26 | return DoCoerceGoal(region, K, w, R, nullptr); |
| 27 | } |
James Kuszmaul | fb0e0ae | 2014-03-25 07:04:47 -0700 | [diff] [blame] | 28 | |
| 29 | } // namespace control_loops |
| 30 | } // namespace frc971 |
| 31 | |
| 32 | #endif // FRC971_CONTROL_LOOPS_COERCE_GOAL_H_ |