Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #ifndef y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 2 | #define y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |
| 3 | |
James Kuszmaul | 6175066 | 2021-06-21 21:32:33 -0700 | [diff] [blame] | 4 | #include "frc971/control_loops/control_loop.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 5 | #include "aos/events/event_loop.h" |
James Kuszmaul | b1b2d8e | 2020-02-21 21:11:46 -0800 | [diff] [blame] | 6 | #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h" |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 7 | #include "frc971/input/joystick_state_generated.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 8 | #include "y2020/constants.h" |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 9 | #include "y2020/control_loops/superstructure/climber.h" |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 10 | #include "y2020/control_loops/superstructure/shooter/shooter.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 11 | #include "y2020/control_loops/superstructure/superstructure_goal_generated.h" |
| 12 | #include "y2020/control_loops/superstructure/superstructure_output_generated.h" |
| 13 | #include "y2020/control_loops/superstructure/superstructure_position_generated.h" |
| 14 | #include "y2020/control_loops/superstructure/superstructure_status_generated.h" |
James Kuszmaul | b1b2d8e | 2020-02-21 21:11:46 -0800 | [diff] [blame] | 15 | #include "y2020/control_loops/superstructure/turret/aiming.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 16 | |
| 17 | namespace y2020 { |
| 18 | namespace control_loops { |
| 19 | namespace superstructure { |
| 20 | |
| 21 | class Superstructure |
James Kuszmaul | 6175066 | 2021-06-21 21:32:33 -0700 | [diff] [blame] | 22 | : public ::frc971::controls::ControlLoop<Goal, Position, Status, Output> { |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 23 | public: |
| 24 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 25 | const ::std::string &name = "/superstructure"); |
| 26 | |
Austin Schuh | 2fb2364 | 2020-02-29 15:10:51 -0800 | [diff] [blame] | 27 | // Terms to control the velocity gain for the friction compensation, and the |
| 28 | // voltage cap. |
milind-u | f70e8e1 | 2021-10-02 12:36:00 -0700 | [diff] [blame] | 29 | static constexpr double kTurretFrictionGain = 0.0; |
Austin Schuh | 2fb2364 | 2020-02-29 15:10:51 -0800 | [diff] [blame] | 30 | static constexpr double kTurretFrictionVoltageLimit = 1.5; |
milind-u | f70e8e1 | 2021-10-02 12:36:00 -0700 | [diff] [blame] | 31 | static constexpr double kTurretDitherGain = 0.0; |
Austin Schuh | 2fb2364 | 2020-02-29 15:10:51 -0800 | [diff] [blame] | 32 | |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 33 | using PotAndAbsoluteEncoderSubsystem = |
| 34 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 35 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 36 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 37 | using AbsoluteEncoderSubsystem = |
| 38 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 39 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 40 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 41 | using AbsoluteAndAbsoluteEncoderSubsystem = |
| 42 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 43 | ::frc971::zeroing::AbsoluteAndAbsoluteEncoderZeroingEstimator, |
| 44 | ::frc971::control_loops:: |
| 45 | AbsoluteAndAbsoluteEncoderProfiledJointStatus>; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 46 | |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 47 | const AbsoluteAndAbsoluteEncoderSubsystem &hood() const { return hood_; } |
Sabina Davis | 0f2d38c | 2020-02-08 17:01:21 -0800 | [diff] [blame] | 48 | const AbsoluteEncoderSubsystem &intake_joint() const { return intake_joint_; } |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 49 | const PotAndAbsoluteEncoderSubsystem &turret() const { return turret_; } |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 50 | const shooter::Shooter &shooter() const { return shooter_; } |
milind upadhyay | aec1aee | 2020-10-13 13:44:33 -0700 | [diff] [blame] | 51 | double robot_speed() const; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 52 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 53 | protected: |
| 54 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 55 | aos::Sender<Output>::Builder *output, |
| 56 | aos::Sender<Status>::Builder *status) override; |
| 57 | |
| 58 | private: |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 59 | AbsoluteAndAbsoluteEncoderSubsystem hood_; |
Sabina Davis | 0f2d38c | 2020-02-08 17:01:21 -0800 | [diff] [blame] | 60 | AbsoluteEncoderSubsystem intake_joint_; |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 61 | PotAndAbsoluteEncoderSubsystem turret_; |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 62 | shooter::Shooter shooter_; |
James Kuszmaul | b1b2d8e | 2020-02-21 21:11:46 -0800 | [diff] [blame] | 63 | turret::Aimer aimer_; |
| 64 | |
| 65 | aos::Fetcher<frc971::control_loops::drivetrain::Status> |
| 66 | drivetrain_status_fetcher_; |
James Kuszmaul | a53c3ac | 2020-02-22 19:36:01 -0800 | [diff] [blame] | 67 | aos::Fetcher<aos::JoystickState> joystick_state_fetcher_; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 68 | |
John Park | 0a245a0 | 2020-02-02 14:10:15 -0800 | [diff] [blame] | 69 | Climber climber_; |
Austin Schuh | 78f0bfd | 2020-02-29 23:04:21 -0800 | [diff] [blame] | 70 | |
Austin Schuh | 13e5552 | 2020-02-29 23:11:17 -0800 | [diff] [blame] | 71 | aos::monotonic_clock::time_point shooting_start_time_ = |
| 72 | aos::monotonic_clock::min_time; |
| 73 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 74 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 75 | }; |
| 76 | |
| 77 | } // namespace superstructure |
| 78 | } // namespace control_loops |
| 79 | } // namespace y2020 |
| 80 | |
| 81 | #endif // y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |