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