blob: 1081a570fe7b43458415f2fb6f93d8f27bce5c8c [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
Austin Schuh6197a182015-11-28 16:04:40 -080012using ::frc971::constants::ShifterHallEffect;
13
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;
38 ShifterHallEffect left_drive, right_drive;
39 bool clutch_transmission;
40
41 double turn_width;
42
43 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
44 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
45
46 double drivetrain_done_distance;
47 double drivetrain_max_speed;
48
49 struct ZeroingConstants {
50 // The number of samples in the moving average filter.
51 int average_filter_size;
52 // The difference in scaled units between two index pulses.
53 double index_difference;
54 // The absolute position in scaled units of one of the index pulses.
55 double measured_index_position;
56 // Value between 0 and 1 which determines a fraction of the index_diff
57 // you want to use.
58 double allowable_encoder_error;
59 };
60
61 // Defines a range of motion for a subsystem.
62 // These are all absolute positions in scaled units.
63 struct Range {
64 double lower_limit;
65 double upper_limit;
66 double lower_hard_limit;
67 double upper_hard_limit;
68 };
69
70 struct Shooter {
71 double lower_limit;
72 double upper_limit;
73 double lower_hard_limit;
74 double upper_hard_limit;
75 // If the plunger is further back than this position, it is safe for the
76 // latch to be down. Anything else would be considered a collision.
77 double latch_max_safe_position;
78 AnglePair plunger_back;
79 AnglePair pusher_distal;
80 AnglePair pusher_proximal;
81 double zeroing_speed;
82 double unload_speed;
83 };
84
85 Shooter shooter;
86
87 struct Claws {
88 double claw_zeroing_off_speed;
89 double claw_zeroing_speed;
90 double claw_zeroing_separation;
91
92 // claw separation that would be considered a collision
93 double claw_min_separation;
94 double claw_max_separation;
95
96 // We should never get closer/farther than these.
97 double soft_min_separation;
98 double soft_max_separation;
99
100 // Three hall effects are known as front, calib and back
101 typedef Values::AnglePair AnglePair;
102
103 struct Claw {
104 double lower_hard_limit;
105 double upper_hard_limit;
106 double lower_limit;
107 double upper_limit;
108 AnglePair front;
109 AnglePair calibration;
110 AnglePair back;
111 };
112
113 Claw upper_claw;
114 Claw lower_claw;
115
116 double claw_unimportant_epsilon;
117 double start_fine_tune_pos;
118 double max_zeroing_voltage;
119 };
120 Claws claw;
121
122 // Has all the constants for the ShootAction class.
123 struct ShooterAction {
124 // Minimum separation required between the claws in order to be able to
125 // shoot.
126 double claw_shooting_separation;
127
128 // Goal to send to the claw when opening it up in preparation for shooting;
129 // should be larger than claw_shooting_separation so that we can shoot
130 // promptly.
131 double claw_separation_goal;
132 };
133 ShooterAction shooter_action;
134};
135
136// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
137// returns a reference to it.
138const Values &GetValues();
139
140// Creates Values instances for each team number it is called with and returns
141// them.
142const Values &GetValuesForTeam(uint16_t team_number);
143
144} // namespace constants
Austin Schuh6197a182015-11-28 16:04:40 -0800145} // namespace y2014
Brian Silverman17f503e2015-08-02 18:17:18 -0700146
147#endif // Y2014_CONSTANTS_H_