blob: 4baeb24c5bffc716afb0df32d9ca3bdac3250fea [file] [log] [blame]
Brian Silverman17f503e2015-08-02 18:17:18 -07001#ifndef Y2014_CONSTANTS_H_
2#define Y2014_CONSTANTS_H_
3
Tyler Chatowbf0609c2021-07-31 16:13:27 -07004#include <cstdint>
Brian Silverman17f503e2015-08-02 18:17:18 -07005
6#include "frc971/control_loops/state_feedback_loop.h"
7#include "frc971/shifter_hall_effect.h"
8
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08009namespace y2014::constants {
Brian Silverman17f503e2015-08-02 18:17:18 -070010
Sabina Davis415bb6c2017-10-16 23:30:52 -070011using ::frc971::constants::DualHallShifterHallEffect;
Austin Schuh6197a182015-11-28 16:04:40 -080012
Brian Silverman17f503e2015-08-02 18:17:18 -070013// Has all of the numbers that change for both robots and makes it easy to
14// retrieve the values for the current one.
15
16// Everything is in SI units (volts, radians, meters, seconds, etc).
17// Some of these values are related to the conversion between raw values
18// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
19
20// This structure contains current values for all of the things that change.
21struct Values {
22 // This is useful for representing the 2 sides of a hall effect sensor etc.
23 struct AnglePair {
24 // The angles for increasing values (posedge on lower, negedge on upper).
25 double lower_angle, upper_angle;
26 // The angles for decreasing values (negedge on lower, posedge on upper).
27 double lower_decreasing_angle, upper_decreasing_angle;
28 };
29
30 // The ratio from the encoder shaft to the drivetrain wheels.
31 double drivetrain_encoder_ratio;
32
33 // The gear ratios from motor shafts to the drivetrain wheels for high and low
34 // gear.
35 double low_gear_ratio;
36 double high_gear_ratio;
Sabina Davis415bb6c2017-10-16 23:30:52 -070037 DualHallShifterHallEffect left_drive, right_drive;
Brian Silverman17f503e2015-08-02 18:17:18 -070038 bool clutch_transmission;
39
Brian Silverman17f503e2015-08-02 18:17:18 -070040 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
41 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
42
Brian Silverman17f503e2015-08-02 18:17:18 -070043 double drivetrain_max_speed;
44
Tyler Chatowf8f03112017-02-05 14:31:34 -080045 struct PotAndIndexPulseZeroingConstants {
Brian Silverman17f503e2015-08-02 18:17:18 -070046 // The number of samples in the moving average filter.
47 int average_filter_size;
48 // The difference in scaled units between two index pulses.
49 double index_difference;
50 // The absolute position in scaled units of one of the index pulses.
51 double measured_index_position;
52 // Value between 0 and 1 which determines a fraction of the index_diff
53 // you want to use.
54 double allowable_encoder_error;
55 };
56
57 // Defines a range of motion for a subsystem.
58 // These are all absolute positions in scaled units.
59 struct Range {
60 double lower_limit;
61 double upper_limit;
62 double lower_hard_limit;
63 double upper_hard_limit;
64 };
65
66 struct Shooter {
67 double lower_limit;
68 double upper_limit;
69 double lower_hard_limit;
70 double upper_hard_limit;
71 // If the plunger is further back than this position, it is safe for the
72 // latch to be down. Anything else would be considered a collision.
73 double latch_max_safe_position;
74 AnglePair plunger_back;
75 AnglePair pusher_distal;
76 AnglePair pusher_proximal;
77 double zeroing_speed;
78 double unload_speed;
79 };
80
81 Shooter shooter;
82
83 struct Claws {
84 double claw_zeroing_off_speed;
85 double claw_zeroing_speed;
86 double claw_zeroing_separation;
87
88 // claw separation that would be considered a collision
89 double claw_min_separation;
90 double claw_max_separation;
91
92 // We should never get closer/farther than these.
93 double soft_min_separation;
94 double soft_max_separation;
95
96 // Three hall effects are known as front, calib and back
97 typedef Values::AnglePair AnglePair;
98
99 struct Claw {
100 double lower_hard_limit;
101 double upper_hard_limit;
102 double lower_limit;
103 double upper_limit;
104 AnglePair front;
105 AnglePair calibration;
106 AnglePair back;
107 };
108
109 Claw upper_claw;
110 Claw lower_claw;
111
112 double claw_unimportant_epsilon;
113 double start_fine_tune_pos;
114 double max_zeroing_voltage;
115 };
116 Claws claw;
117
118 // Has all the constants for the ShootAction class.
119 struct ShooterAction {
120 // Minimum separation required between the claws in order to be able to
121 // shoot.
122 double claw_shooting_separation;
123
124 // Goal to send to the claw when opening it up in preparation for shooting;
125 // should be larger than claw_shooting_separation so that we can shoot
126 // promptly.
127 double claw_separation_goal;
Tyler Chatowf8f03112017-02-05 14:31:34 -0800128 };
Brian Silverman17f503e2015-08-02 18:17:18 -0700129 ShooterAction shooter_action;
130};
131
132// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
133// returns a reference to it.
134const Values &GetValues();
135
136// Creates Values instances for each team number it is called with and returns
137// them.
138const Values &GetValuesForTeam(uint16_t team_number);
139
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -0800140} // namespace y2014::constants
Brian Silverman17f503e2015-08-02 18:17:18 -0700141
142#endif // Y2014_CONSTANTS_H_