blob: 29899fb15cf9bf6f95856c2c045227db80f57e41 [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"
James Kuszmaulec635d22023-08-12 18:39:24 -07005#include "frc971/zeroing/pot_and_absolute_encoder.h"
Austin Schuhd5ccb862017-03-11 22:06:36 -08006#include "y2017/constants.h"
Alex Perrycb7da4b2019-08-28 19:35:56 -07007#include "y2017/control_loops/superstructure/superstructure_goal_generated.h"
Adam Snaider79900c22017-02-08 20:23:15 -08008
9namespace y2017 {
10namespace control_loops {
11namespace superstructure {
12namespace intake {
13
14class Intake {
15 public:
Ojas Upadhye3abe8862017-02-11 17:06:53 -080016 Intake();
17 double goal(int row, int col) const {
18 return profiled_subsystem_.goal(row, col);
19 }
Adam Snaider79900c22017-02-08 20:23:15 -080020
Austin Schuhd5ccb862017-03-11 22:06:36 -080021 // Sets the minimum position we'll allow the intake to be at. This forces the
22 // intake to stay out far enough to avoid collisions.
23 void set_min_position(double min_position) { min_position_ = min_position; }
24
Philipp Schrader790cb542023-07-05 21:06:52 -070025 // Moves min_position_ to a position which won't affect any other goal
26 // requests.
Austin Schuhd5ccb862017-03-11 22:06:36 -080027 void clear_min_position() {
28 min_position_ = constants::Values::kIntakeRange.lower_hard;
29 }
30
31 double position() const { return profiled_subsystem_.position(); }
32
Ojas Upadhye3abe8862017-02-11 17:06:53 -080033 // The zeroing and operating voltages.
34 static constexpr double kZeroingVoltage = 2.5;
35 static constexpr double kOperatingVoltage = 12.0;
Adam Snaider79900c22017-02-08 20:23:15 -080036
Alex Perrycb7da4b2019-08-28 19:35:56 -070037 flatbuffers::Offset<
38 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>
39 Iterate(const IntakeGoal *unsafe_goal,
40 const ::frc971::PotAndAbsolutePosition *position, double *output,
41 flatbuffers::FlatBufferBuilder *fbb);
Adam Snaider79900c22017-02-08 20:23:15 -080042
Ojas Upadhye3abe8862017-02-11 17:06:53 -080043 void Reset();
Adam Snaider79900c22017-02-08 20:23:15 -080044
Ojas Upadhye3abe8862017-02-11 17:06:53 -080045 enum class State : int32_t {
46 UNINITIALIZED,
47 DISABLED_INITIALIZED,
48 ZEROING,
49 RUNNING,
50 ESTOP,
51 };
Adam Snaider79900c22017-02-08 20:23:15 -080052
Ojas Upadhye3abe8862017-02-11 17:06:53 -080053 State state() const { return state_; }
Adam Snaider79900c22017-02-08 20:23:15 -080054
Ojas Upadhye3abe8862017-02-11 17:06:53 -080055 private:
Austin Schuhd5ccb862017-03-11 22:06:36 -080056 State state_ = State::UNINITIALIZED;
57 double min_position_;
58
59 // The number of times in a row we've been asked to disable.
60 int disable_count_ = 0;
Adam Snaider79900c22017-02-08 20:23:15 -080061
Ojas Upadhye3abe8862017-02-11 17:06:53 -080062 ::frc971::control_loops::SingleDOFProfiledSubsystem<
Austin Schuh72db9a12019-01-21 18:02:51 -080063 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
64 profiled_subsystem_;
Adam Snaider79900c22017-02-08 20:23:15 -080065};
66
67} // namespace intake
68} // namespace superstructure
69} // namespace control_loops
70} // namespace y2017
71
72#endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_