blob: 40f49fc64fb4a12becd2de0f8dea30f299ac90cc [file] [log] [blame]
Adam Snaider79900c22017-02-08 20:23:15 -08001#ifndef Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_
2#define Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_
3
4#include "frc971/control_loops/profiled_subsystem.h"
Austin Schuhd5ccb862017-03-11 22:06:36 -08005#include "y2017/constants.h"
Adam Snaider79900c22017-02-08 20:23:15 -08006#include "y2017/control_loops/superstructure/superstructure.q.h"
7
8namespace y2017 {
9namespace control_loops {
10namespace superstructure {
11namespace intake {
12
13class Intake {
14 public:
Ojas Upadhye3abe8862017-02-11 17:06:53 -080015 Intake();
16 double goal(int row, int col) const {
17 return profiled_subsystem_.goal(row, col);
18 }
Adam Snaider79900c22017-02-08 20:23:15 -080019
Austin Schuhd5ccb862017-03-11 22:06:36 -080020 // Sets the minimum position we'll allow the intake to be at. This forces the
21 // intake to stay out far enough to avoid collisions.
22 void set_min_position(double min_position) { min_position_ = min_position; }
23
24 // Moves min_position_ to a position which won't affect any other goal requests.
25 void clear_min_position() {
26 min_position_ = constants::Values::kIntakeRange.lower_hard;
27 }
28
29 double position() const { return profiled_subsystem_.position(); }
30
Ojas Upadhye3abe8862017-02-11 17:06:53 -080031 // The zeroing and operating voltages.
32 static constexpr double kZeroingVoltage = 2.5;
33 static constexpr double kOperatingVoltage = 12.0;
Adam Snaider79900c22017-02-08 20:23:15 -080034
Ojas Upadhye3abe8862017-02-11 17:06:53 -080035 void Iterate(const control_loops::IntakeGoal *unsafe_goal,
36 const ::frc971::PotAndAbsolutePosition *position, double *output,
37 ::frc971::control_loops::AbsoluteProfiledJointStatus *status);
Adam Snaider79900c22017-02-08 20:23:15 -080038
Ojas Upadhye3abe8862017-02-11 17:06:53 -080039 void Reset();
Adam Snaider79900c22017-02-08 20:23:15 -080040
Ojas Upadhye3abe8862017-02-11 17:06:53 -080041 enum class State : int32_t {
42 UNINITIALIZED,
43 DISABLED_INITIALIZED,
44 ZEROING,
45 RUNNING,
46 ESTOP,
47 };
Adam Snaider79900c22017-02-08 20:23:15 -080048
Ojas Upadhye3abe8862017-02-11 17:06:53 -080049 State state() const { return state_; }
Adam Snaider79900c22017-02-08 20:23:15 -080050
Ojas Upadhye3abe8862017-02-11 17:06:53 -080051 private:
Austin Schuhd5ccb862017-03-11 22:06:36 -080052 State state_ = State::UNINITIALIZED;
53 double min_position_;
54
55 // The number of times in a row we've been asked to disable.
56 int disable_count_ = 0;
Adam Snaider79900c22017-02-08 20:23:15 -080057
Ojas Upadhye3abe8862017-02-11 17:06:53 -080058 ::frc971::control_loops::SingleDOFProfiledSubsystem<
Austin Schuh72db9a12019-01-21 18:02:51 -080059 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
60 profiled_subsystem_;
Adam Snaider79900c22017-02-08 20:23:15 -080061};
62
63} // namespace intake
64} // namespace superstructure
65} // namespace control_loops
66} // namespace y2017
67
68#endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_