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