blob: 9c25cb98ba304e855533ddfc56c11f75dc2ef70d [file] [log] [blame]
Austin Schuh87c10632017-02-05 19:02:17 -08001#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
7namespace y2017 {
8namespace control_loops {
9namespace superstructure {
10namespace hood {
11
Austin Schuh6a90cd92017-02-19 20:55:33 -080012// 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.
16class 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 Schuh87c10632017-02-05 19:02:17 -080026class Hood {
27 public:
Austin Schuh6a90cd92017-02-19 20:55:33 -080028 Hood();
29 double goal(int row, int col) const {
30 return profiled_subsystem_.goal(row, col);
31 }
Austin Schuh87c10632017-02-05 19:02:17 -080032
Austin Schuh6a90cd92017-02-19 20:55:33 -080033 // The zeroing and operating voltages.
Austin Schuh410e3812017-02-21 16:44:03 -080034 static constexpr double kZeroingVoltage = 2.0;
35 static constexpr double kOperatingVoltage = 3.0;
Austin Schuh87c10632017-02-05 19:02:17 -080036
Austin Schuh6a90cd92017-02-19 20:55:33 -080037 void Iterate(const control_loops::HoodGoal *unsafe_goal,
38 const ::frc971::IndexPosition *position, double *output,
39 ::frc971::control_loops::IndexProfiledJointStatus *status);
Austin Schuh87c10632017-02-05 19:02:17 -080040
Austin Schuh6a90cd92017-02-19 20:55:33 -080041 void Reset();
Austin Schuh87c10632017-02-05 19:02:17 -080042
Austin Schuh6a90cd92017-02-19 20:55:33 -080043 enum class State : int32_t {
44 UNINITIALIZED,
45 DISABLED_INITIALIZED,
46 ZEROING,
47 RUNNING,
48 ESTOP,
49 };
Austin Schuh87c10632017-02-05 19:02:17 -080050
Austin Schuh6a90cd92017-02-19 20:55:33 -080051 State state() const { return state_; }
Austin Schuh87c10632017-02-05 19:02:17 -080052
Austin Schuh6a90cd92017-02-19 20:55:33 -080053 private:
54 State state_;
Austin Schuh87c10632017-02-05 19:02:17 -080055
Austin Schuh6a90cd92017-02-19 20:55:33 -080056 IndexPulseProfiledSubsystem profiled_subsystem_;
Austin Schuh87c10632017-02-05 19:02:17 -080057};
58
59} // namespace hood
60} // namespace superstructure
61} // namespace control_loops
62} // namespace y2017
63
64#endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_HOOD_HOOD_H_