blob: f0e97e94b6f6994d365f2aabfa73c2cd356d0889 [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
Theo Bafrali3274a182019-02-17 20:01:38 -08004#include "aos/controls/control_loop.h"
Tyler Chatow7db827f2019-02-24 00:10:13 -08005#include "y2019/control_loops/superstructure/superstructure.q.h"
Theo Bafrali3274a182019-02-17 20:01:38 -08006
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
Theo Bafrali3274a182019-02-17 20:01:38 -080018 // Voltage to the vaccum pump when we are attempting to acquire a piece
Austin Schuhc2ee66b2019-02-19 13:37:46 -080019 static constexpr double kPumpVoltage = 8.0;
Theo Bafrali3274a182019-02-17 20:01:38 -080020
21 // Voltage to the vaccum pump when we have a piece
Austin Schuh47bb88d2019-02-19 16:49:44 -080022 static constexpr double kPumpHasPieceVoltage = 2.25;
Theo Bafrali3274a182019-02-17 20:01:38 -080023
24 // Time to continue at the higher pump voltage after getting a gamepiece
25 static constexpr aos::monotonic_clock::duration kTimeAtHigherVoltage =
Austin Schuhc2ee66b2019-02-19 13:37:46 -080026 std::chrono::milliseconds(100);
Theo Bafrali3274a182019-02-17 20:01:38 -080027
Tyler Chatow7db827f2019-02-24 00:10:13 -080028 // Time required for the game piece to be released from a vacuum
29 static constexpr aos::monotonic_clock::duration kReleaseTime =
30 std::chrono::milliseconds(250);
Theo Bafrali3274a182019-02-17 20:01:38 -080031
32 private:
33 bool had_piece_ = false;
Tyler Chatow7db827f2019-02-24 00:10:13 -080034 aos::monotonic_clock::time_point last_release_time_ =
Theo Bafrali3274a182019-02-17 20:01:38 -080035 aos::monotonic_clock::epoch();
36 aos::monotonic_clock::time_point time_at_last_acquisition_ =
37 aos::monotonic_clock::epoch();
38 double filtered_pressure_ = 1.0;
39
40 static constexpr double kVacuumThreshold = 0.70;
41
42 static constexpr double kFilterTimeConstant = 0.1;
43 static constexpr double dt = .00505;
44 static constexpr double kSuctionAlpha =
45 dt * (1 - kFilterTimeConstant) / (kFilterTimeConstant);
46
47 DISALLOW_COPY_AND_ASSIGN(Vacuum);
48};
49
50} // namespace superstructure
51} // namespace control_loops
52} // namespace y2019
53
54#endif // Y2019_CONTROL_LOOPS_SUPERSTRUCTURE_SUPERSTRUCTURE_H_