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