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 | |
| 4 | #include "aos/controls/control_loop.h" |
| 5 | #include "aos/events/event_loop.h" |
| 6 | #include "y2020/constants.h" |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 7 | #include "y2020/control_loops/superstructure/shooter/shooter.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 8 | #include "y2020/control_loops/superstructure/superstructure_goal_generated.h" |
| 9 | #include "y2020/control_loops/superstructure/superstructure_output_generated.h" |
| 10 | #include "y2020/control_loops/superstructure/superstructure_position_generated.h" |
| 11 | #include "y2020/control_loops/superstructure/superstructure_status_generated.h" |
John Park | 0a245a0 | 2020-02-02 14:10:15 -0800 | [diff] [blame] | 12 | #include "y2020/control_loops/superstructure/climber.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 13 | |
| 14 | namespace y2020 { |
| 15 | namespace control_loops { |
| 16 | namespace superstructure { |
| 17 | |
| 18 | class Superstructure |
| 19 | : public ::aos::controls::ControlLoop<Goal, Position, Status, Output> { |
| 20 | public: |
| 21 | explicit Superstructure(::aos::EventLoop *event_loop, |
| 22 | const ::std::string &name = "/superstructure"); |
| 23 | |
Austin Schuh | 2fb2364 | 2020-02-29 15:10:51 -0800 | [diff] [blame] | 24 | // Terms to control the velocity gain for the friction compensation, and the |
| 25 | // voltage cap. |
| 26 | static constexpr double kTurretFrictionGain = 10.0; |
| 27 | static constexpr double kTurretFrictionVoltageLimit = 1.5; |
| 28 | |
Austin Schuh | 78f0bfd | 2020-02-29 23:04:21 -0800 | [diff] [blame] | 29 | static constexpr double kHoodFrictionGain = 40.0; |
| 30 | static constexpr double kHoodFrictionVoltageLimit = 1.5; |
| 31 | |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 32 | using PotAndAbsoluteEncoderSubsystem = |
| 33 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 34 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator, |
| 35 | ::frc971::control_loops::PotAndAbsoluteEncoderProfiledJointStatus>; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 36 | using AbsoluteEncoderSubsystem = |
| 37 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystem< |
| 38 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator, |
| 39 | ::frc971::control_loops::AbsoluteEncoderProfiledJointStatus>; |
| 40 | |
| 41 | const AbsoluteEncoderSubsystem &hood() const { return hood_; } |
Sabina Davis | 0f2d38c | 2020-02-08 17:01:21 -0800 | [diff] [blame] | 42 | const AbsoluteEncoderSubsystem &intake_joint() const { return intake_joint_; } |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 43 | const PotAndAbsoluteEncoderSubsystem &turret() const { return turret_; } |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 44 | const shooter::Shooter &shooter() const { return shooter_; } |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 45 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 46 | protected: |
| 47 | virtual void RunIteration(const Goal *unsafe_goal, const Position *position, |
| 48 | aos::Sender<Output>::Builder *output, |
| 49 | aos::Sender<Status>::Builder *status) override; |
| 50 | |
| 51 | private: |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 52 | AbsoluteEncoderSubsystem hood_; |
Sabina Davis | 0f2d38c | 2020-02-08 17:01:21 -0800 | [diff] [blame] | 53 | AbsoluteEncoderSubsystem intake_joint_; |
Kai Tinkess | fb46037 | 2020-02-08 14:05:48 -0800 | [diff] [blame] | 54 | PotAndAbsoluteEncoderSubsystem turret_; |
Sabina Davis | 0f31d3f | 2020-02-20 20:41:00 -0800 | [diff] [blame] | 55 | shooter::Shooter shooter_; |
Sabina Davis | cf08b15 | 2020-01-31 22:12:09 -0800 | [diff] [blame] | 56 | |
John Park | 0a245a0 | 2020-02-02 14:10:15 -0800 | [diff] [blame] | 57 | Climber climber_; |
Austin Schuh | 78f0bfd | 2020-02-29 23:04:21 -0800 | [diff] [blame] | 58 | |
Austin Schuh | 13e5552 | 2020-02-29 23:11:17 -0800 | [diff] [blame] | 59 | aos::monotonic_clock::time_point shooting_start_time_ = |
| 60 | aos::monotonic_clock::min_time; |
| 61 | |
Austin Schuh | 78f0bfd | 2020-02-29 23:04:21 -0800 | [diff] [blame] | 62 | double time_ = 0.0; |
| 63 | |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 64 | DISALLOW_COPY_AND_ASSIGN(Superstructure); |
| 65 | }; |
| 66 | |
| 67 | } // namespace superstructure |
| 68 | } // namespace control_loops |
| 69 | } // namespace y2020 |
| 70 | |
| 71 | #endif // y2020_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |