blob: 3fd5a49518201c4ca88017e251a8c235a4b8a60c [file] [log] [blame]
Theo Bafrali3274a182019-02-17 20:01:38 -08001#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
7namespace y2019 {
8namespace control_loops {
9namespace superstructure {
10
11class 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
Austin Schuhc2ee66b2019-02-19 13:37:46 -080020 static constexpr double kPumpVoltage = 8.0;
Theo Bafrali3274a182019-02-17 20:01:38 -080021
22 // Voltage to the vaccum pump when we have a piece
Austin Schuhc2ee66b2019-02-19 13:37:46 -080023 static constexpr double kPumpHasPieceVoltage = 2.0;
Theo Bafrali3274a182019-02-17 20:01:38 -080024
25 // Time to continue at the higher pump voltage after getting a gamepiece
26 static constexpr aos::monotonic_clock::duration kTimeAtHigherVoltage =
Austin Schuhc2ee66b2019-02-19 13:37:46 -080027 std::chrono::milliseconds(100);
Theo Bafrali3274a182019-02-17 20:01:38 -080028
29 // Time to continue the pump after getting a no suck goal
30 static constexpr aos::monotonic_clock::duration kTimeToKeepPumpRunning =
Austin Schuhc2ee66b2019-02-19 13:37:46 -080031 std::chrono::milliseconds(750);
Theo Bafrali3274a182019-02-17 20:01:38 -080032
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_