Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 1 | #ifndef Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_HOOD_HOOD_H_ |
| 2 | #define Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_HOOD_HOOD_H_ |
| 3 | |
| 4 | #include "frc971/control_loops/profiled_subsystem.h" |
| 5 | #include "y2017/control_loops/superstructure/superstructure.q.h" |
| 6 | |
| 7 | namespace y2017 { |
| 8 | namespace control_loops { |
| 9 | namespace superstructure { |
| 10 | namespace hood { |
| 11 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 12 | // Profiled subsystem class with significantly relaxed limits while zeroing. We |
| 13 | // need relaxed limits, because if you start at the top of the range, you need |
| 14 | // to go to -range, and if you start at the bottom of the range, you need to go |
| 15 | // to +range. The standard subsystem doesn't support that. |
| 16 | class IndexPulseProfiledSubsystem |
| 17 | : public ::frc971::control_loops::SingleDOFProfiledSubsystem< |
| 18 | ::frc971::zeroing::PulseIndexZeroingEstimator> { |
| 19 | public: |
| 20 | IndexPulseProfiledSubsystem(); |
| 21 | |
| 22 | private: |
| 23 | void CapGoal(const char *name, Eigen::Matrix<double, 3, 1> *goal) override; |
| 24 | }; |
| 25 | |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 26 | class Hood { |
| 27 | public: |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 28 | Hood(); |
| 29 | double goal(int row, int col) const { |
| 30 | return profiled_subsystem_.goal(row, col); |
| 31 | } |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 32 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 33 | // The zeroing and operating voltages. |
Austin Schuh | 410e381 | 2017-02-21 16:44:03 -0800 | [diff] [blame] | 34 | static constexpr double kZeroingVoltage = 2.0; |
Austin Schuh | bed25dc | 2017-03-22 22:35:08 -0700 | [diff] [blame] | 35 | static constexpr double kOperatingVoltage = 4.0; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 36 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 37 | void Iterate(const control_loops::HoodGoal *unsafe_goal, |
| 38 | const ::frc971::IndexPosition *position, double *output, |
| 39 | ::frc971::control_loops::IndexProfiledJointStatus *status); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 40 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 41 | void Reset(); |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 42 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 43 | enum class State : int32_t { |
| 44 | UNINITIALIZED, |
| 45 | DISABLED_INITIALIZED, |
| 46 | ZEROING, |
| 47 | RUNNING, |
| 48 | ESTOP, |
| 49 | }; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 50 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 51 | State state() const { return state_; } |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 52 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 53 | private: |
| 54 | State state_; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 55 | |
Austin Schuh | 6a90cd9 | 2017-02-19 20:55:33 -0800 | [diff] [blame] | 56 | IndexPulseProfiledSubsystem profiled_subsystem_; |
Austin Schuh | 87c1063 | 2017-02-05 19:02:17 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | } // namespace hood |
| 60 | } // namespace superstructure |
| 61 | } // namespace control_loops |
| 62 | } // namespace y2017 |
| 63 | |
| 64 | #endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_HOOD_HOOD_H_ |