blob: 2dcd15006ac534e38666aa56cbf74d009546c70d [file] [log] [blame]
Brian Silverman431500a2013-10-28 19:50:15 -07001#ifndef FRC971_CONSTANTS_H_
2#define FRC971_CONSTANTS_H_
3
brians343bc112013-02-10 01:53:46 +00004#include <stdint.h>
5
Brian Silverman2c590c32013-11-04 18:08:54 -08006#include "frc971/control_loops/state_feedback_loop.h"
Daniel Pettiaece37f2014-10-25 17:13:44 -07007#include "frc971/shifter_hall_effect.h"
Brian Silverman2c590c32013-11-04 18:08:54 -08008
brians343bc112013-02-10 01:53:46 +00009namespace 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.
brians343bc112013-02-10 01:53:46 +000014
Brian Silverman431500a2013-10-28 19:50:15 -070015// This structure contains current values for all of the things that change.
16struct Values {
Brian Silverman2c793712014-02-16 19:32:32 -080017 // This is useful for representing the 2 sides of a hall effect sensor etc.
Brian Silvermanaae236a2014-02-17 01:49:39 -080018 struct AnglePair {
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080019 // The angles for increasing values (posedge on lower, negedge on upper).
20 double lower_angle, upper_angle;
21 // The angles for decreasing values (negedge on lower, posedge on upper).
22 double lower_decreasing_angle, upper_decreasing_angle;
Brian Silverman2c793712014-02-16 19:32:32 -080023 };
24
Brian Silverman1a6590d2013-11-04 14:46:46 -080025 // The ratio from the encoder shaft to the drivetrain wheels.
26 double drivetrain_encoder_ratio;
27
28 // The gear ratios from motor shafts to the drivetrain wheels for high and low
29 // gear.
30 double low_gear_ratio;
31 double high_gear_ratio;
Brian Silverman431500a2013-10-28 19:50:15 -070032
Brian Silverman6eb51f12013-11-02 14:39:01 -070033 ShifterHallEffect left_drive, right_drive;
34
Brian Silverman1a6590d2013-11-04 14:46:46 -080035 bool clutch_transmission;
36
Brian Silvermanad9e0002014-04-13 14:55:57 -070037 double turn_width;
38
Brian Silverman2c590c32013-11-04 18:08:54 -080039 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
40 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
Brian Silvermandfdcd582014-02-16 20:50:09 -080041
Austin Schuh60c56662014-02-17 14:37:19 -080042 struct Shooter {
Ben Fredricksonedf0e092014-02-16 10:46:50 +000043 double lower_limit;
44 double upper_limit;
Austin Schuh30537882014-02-18 01:07:23 -080045 double lower_hard_limit;
46 double upper_hard_limit;
47 // If the plunger is further back than this position, it is safe for the
48 // latch to be down. Anything else would be considered a collision.
49 double latch_max_safe_position;
Brian Silvermanaae236a2014-02-17 01:49:39 -080050 AnglePair plunger_back;
51 AnglePair pusher_distal;
52 AnglePair pusher_proximal;
Austin Schuh60c56662014-02-17 14:37:19 -080053 double zeroing_speed;
Austin Schuh6b428602014-02-22 21:02:00 -080054 double unload_speed;
Ben Fredricksonedf0e092014-02-16 10:46:50 +000055 };
56
Austin Schuh60c56662014-02-17 14:37:19 -080057 Shooter shooter;
Austin Schuh3bb9a442014-02-02 16:01:45 -080058
Austin Schuhd27931c2014-02-16 19:18:20 -080059 struct Claws {
60 double claw_zeroing_off_speed;
61 double claw_zeroing_speed;
62 double claw_zeroing_separation;
Austin Schuhcc0bf312014-02-09 00:39:29 -080063
Brian Silverman7c021c42014-02-17 15:15:56 -080064 // claw separation that would be considered a collision
Austin Schuh069143b2014-02-17 02:46:26 -080065 double claw_min_separation;
66 double claw_max_separation;
Austin Schuhcc0bf312014-02-09 00:39:29 -080067
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080068 // We should never get closer/farther than these.
69 double soft_min_separation;
70 double soft_max_separation;
71
Austin Schuhd27931c2014-02-16 19:18:20 -080072 // Three hall effects are known as front, calib and back
Brian Silvermanaae236a2014-02-17 01:49:39 -080073 typedef Values::AnglePair AnglePair;
Austin Schuhd27931c2014-02-16 19:18:20 -080074
75 struct Claw {
76 double lower_hard_limit;
77 double upper_hard_limit;
78 double lower_limit;
79 double upper_limit;
80 AnglePair front;
81 AnglePair calibration;
82 AnglePair back;
83 };
84
85 Claw upper_claw;
86 Claw lower_claw;
87
88 double claw_unimportant_epsilon;
89 double start_fine_tune_pos;
Austin Schuh4cb047f2014-02-16 21:10:19 -080090 double max_zeroing_voltage;
Austin Schuh4b7b5d02014-02-10 21:20:34 -080091 };
Austin Schuhd27931c2014-02-16 19:18:20 -080092 Claws claw;
James Kuszmaul9ead1de2014-02-28 21:24:39 -080093
94 // Has all the constants for the ShootAction class.
95 struct ShooterAction {
96 // Minimum separation required between the claws in order to be able to
97 // shoot.
98 double claw_shooting_separation;
99
100 // Goal to send to the claw when opening it up in preparation for shooting;
101 // should be larger than claw_shooting_separation so that we can shoot
102 // promptly.
103 double claw_separation_goal;
104 };
105 ShooterAction shooter_action;
Ben Fredrickson890c3fe2014-03-02 00:15:16 +0000106 double drivetrain_done_distance;
107 double drivetrain_max_speed;
Brian Silverman431500a2013-10-28 19:50:15 -0700108};
109
Brian Silverman0a151c92014-05-02 15:28:44 -0700110// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
111// returns a reference to it.
Brian Silverman431500a2013-10-28 19:50:15 -0700112const Values &GetValues();
Brian Silverman0a151c92014-05-02 15:28:44 -0700113
114// Creates Values instances for each team number it is called with and returns
115// them.
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000116const Values &GetValuesForTeam(uint16_t team_number);
brians343bc112013-02-10 01:53:46 +0000117
118} // namespace constants
119} // namespace frc971
Brian Silverman431500a2013-10-28 19:50:15 -0700120
121#endif // FRC971_CONSTANTS_H_