blob: a91d2f04c2418b533598d2b2153b54089126fabc [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"
Alex Perrycb7da4b2019-08-28 19:35:56 -07006#include "y2017/control_loops/superstructure/superstructure_goal_generated.h"
Adam Snaider79900c22017-02-08 20:23:15 -08007
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
Philipp Schrader790cb542023-07-05 21:06:52 -070024 // Moves min_position_ to a position which won't affect any other goal
25 // requests.
Austin Schuhd5ccb862017-03-11 22:06:36 -080026 void clear_min_position() {
27 min_position_ = constants::Values::kIntakeRange.lower_hard;
28 }
29
30 double position() const { return profiled_subsystem_.position(); }
31
Ojas Upadhye3abe8862017-02-11 17:06:53 -080032 // The zeroing and operating voltages.
33 static constexpr double kZeroingVoltage = 2.5;
34 static constexpr double kOperatingVoltage = 12.0;
Adam Snaider79900c22017-02-08 20:23:15 -080035
Alex Perrycb7da4b2019-08-28 19:35:56 -070036 flatbuffers::Offset<
37 ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>
38 Iterate(const IntakeGoal *unsafe_goal,
39 const ::frc971::PotAndAbsolutePosition *position, double *output,
40 flatbuffers::FlatBufferBuilder *fbb);
Adam Snaider79900c22017-02-08 20:23:15 -080041
Ojas Upadhye3abe8862017-02-11 17:06:53 -080042 void Reset();
Adam Snaider79900c22017-02-08 20:23:15 -080043
Ojas Upadhye3abe8862017-02-11 17:06:53 -080044 enum class State : int32_t {
45 UNINITIALIZED,
46 DISABLED_INITIALIZED,
47 ZEROING,
48 RUNNING,
49 ESTOP,
50 };
Adam Snaider79900c22017-02-08 20:23:15 -080051
Ojas Upadhye3abe8862017-02-11 17:06:53 -080052 State state() const { return state_; }
Adam Snaider79900c22017-02-08 20:23:15 -080053
Ojas Upadhye3abe8862017-02-11 17:06:53 -080054 private:
Austin Schuhd5ccb862017-03-11 22:06:36 -080055 State state_ = State::UNINITIALIZED;
56 double min_position_;
57
58 // The number of times in a row we've been asked to disable.
59 int disable_count_ = 0;
Adam Snaider79900c22017-02-08 20:23:15 -080060
Ojas Upadhye3abe8862017-02-11 17:06:53 -080061 ::frc971::control_loops::SingleDOFProfiledSubsystem<
Austin Schuh72db9a12019-01-21 18:02:51 -080062 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
63 profiled_subsystem_;
Adam Snaider79900c22017-02-08 20:23:15 -080064};
65
66} // namespace intake
67} // namespace superstructure
68} // namespace control_loops
69} // namespace y2017
70
71#endif // Y2017_CONTROL_LOOPS_SUPERSTRUCTURE_INTAKE_INTAKE_H_