Theo Bafrali | 3274a18 | 2019-02-17 20:01:38 -0800 | [diff] [blame^] | 1 | #ifndef Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_VACUUM_H_ |
| 2 | #define Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_VACUUM_H_ |
| 3 | |
| 4 | #include "y2019/control_loops/superstructure/superstructure.q.h" |
| 5 | #include "aos/controls/control_loop.h" |
| 6 | |
| 7 | namespace y2019 { |
| 8 | namespace control_loops { |
| 9 | namespace superstructure { |
| 10 | |
| 11 | class Vacuum { |
| 12 | public: |
| 13 | Vacuum() {} |
| 14 | void Iterate(const SuctionGoal *unsafe_goal, float suction_pressure, |
| 15 | SuperstructureQueue::Output *output, bool *has_piece, |
| 16 | aos::EventLoop *event_loop); |
| 17 | |
| 18 | |
| 19 | // Voltage to the vaccum pump when we are attempting to acquire a piece |
| 20 | static constexpr double kPumpVoltage = 12.0; |
| 21 | |
| 22 | // Voltage to the vaccum pump when we have a piece |
| 23 | static constexpr double kPumpHasPieceVoltage = 8.0; |
| 24 | |
| 25 | // Time to continue at the higher pump voltage after getting a gamepiece |
| 26 | static constexpr aos::monotonic_clock::duration kTimeAtHigherVoltage = |
| 27 | std::chrono::milliseconds(200); |
| 28 | |
| 29 | // Time to continue the pump after getting a no suck goal |
| 30 | static constexpr aos::monotonic_clock::duration kTimeToKeepPumpRunning = |
| 31 | std::chrono::milliseconds(1000); |
| 32 | |
| 33 | private: |
| 34 | bool had_piece_ = false; |
| 35 | aos::monotonic_clock::time_point time_at_last_evacuate_goal_ = |
| 36 | aos::monotonic_clock::epoch(); |
| 37 | aos::monotonic_clock::time_point time_at_last_acquisition_ = |
| 38 | aos::monotonic_clock::epoch(); |
| 39 | double filtered_pressure_ = 1.0; |
| 40 | |
| 41 | static constexpr double kVacuumThreshold = 0.70; |
| 42 | |
| 43 | static constexpr double kFilterTimeConstant = 0.1; |
| 44 | static constexpr double dt = .00505; |
| 45 | static constexpr double kSuctionAlpha = |
| 46 | dt * (1 - kFilterTimeConstant) / (kFilterTimeConstant); |
| 47 | |
| 48 | DISALLOW_COPY_AND_ASSIGN(Vacuum); |
| 49 | }; |
| 50 | |
| 51 | } // namespace superstructure |
| 52 | } // namespace control_loops |
| 53 | } // namespace y2019 |
| 54 | |
| 55 | #endif // Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_ |