blob: f88393da7e1803f84115f07ff56ff991d39b9e35 [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
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08009namespace y2017::control_loops::superstructure::intake {
Adam Snaider79900c22017-02-08 20:23:15 -080010
11class Intake {
12 public:
Ojas Upadhye3abe8862017-02-11 17:06:53 -080013 Intake();
14 double goal(int row, int col) const {
15 return profiled_subsystem_.goal(row, col);
16 }
Adam Snaider79900c22017-02-08 20:23:15 -080017
Austin Schuhd5ccb862017-03-11 22:06:36 -080018 // Sets the minimum position we'll allow the intake to be at. This forces the
19 // intake to stay out far enough to avoid collisions.
20 void set_min_position(double min_position) { min_position_ = min_position; }
21
Philipp Schrader790cb542023-07-05 21:06:52 -070022 // Moves min_position_ to a position which won't affect any other goal
23 // requests.
Austin Schuhd5ccb862017-03-11 22:06:36 -080024 void clear_min_position() {
25 min_position_ = constants::Values::kIntakeRange.lower_hard;
26 }
27
28 double position() const { return profiled_subsystem_.position(); }
29
Ojas Upadhye3abe8862017-02-11 17:06:53 -080030 // The zeroing and operating voltages.
31 static constexpr double kZeroingVoltage = 2.5;
32 static constexpr double kOperatingVoltage = 12.0;
Adam Snaider79900c22017-02-08 20:23:15 -080033
Alex Perrycb7da4b2019-08-28 19:35:56 -070034 flatbuffers::Offset<
35 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>
36 Iterate(const IntakeGoal *unsafe_goal,
37 const ::frc971::PotAndAbsolutePosition *position, double *output,
38 flatbuffers::FlatBufferBuilder *fbb);
Adam Snaider79900c22017-02-08 20:23:15 -080039
Ojas Upadhye3abe8862017-02-11 17:06:53 -080040 void Reset();
Adam Snaider79900c22017-02-08 20:23:15 -080041
Ojas Upadhye3abe8862017-02-11 17:06:53 -080042 enum class State : int32_t {
43 UNINITIALIZED,
44 DISABLED_INITIALIZED,
45 ZEROING,
46 RUNNING,
47 ESTOP,
48 };
Adam Snaider79900c22017-02-08 20:23:15 -080049
Ojas Upadhye3abe8862017-02-11 17:06:53 -080050 State state() const { return state_; }
Adam Snaider79900c22017-02-08 20:23:15 -080051
Ojas Upadhye3abe8862017-02-11 17:06:53 -080052 private:
Austin Schuhd5ccb862017-03-11 22:06:36 -080053 State state_ = State::UNINITIALIZED;
54 double min_position_;
55
56 // The number of times in a row we've been asked to disable.
57 int disable_count_ = 0;
Adam Snaider79900c22017-02-08 20:23:15 -080058
Ojas Upadhye3abe8862017-02-11 17:06:53 -080059 ::frc971::control_loops::SingleDOFProfiledSubsystem<
Austin Schuh72db9a12019-01-21 18:02:51 -080060 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
61 profiled_subsystem_;
Adam Snaider79900c22017-02-08 20:23:15 -080062};
63
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080064} // namespace y2017::control_loops::superstructure::intake
Adam Snaider79900c22017-02-08 20:23:15 -080065
66#endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_