blob: 3416a3993b2eb246bc4fe270cd179a46452d2c6e [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"
7
brians343bc112013-02-10 01:53:46 +00008namespace frc971 {
9namespace constants {
10
11// Has all of the numbers that change for both robots and makes it easy to
12// retrieve the values for the current one.
brians343bc112013-02-10 01:53:46 +000013
Austin Schuhe7f90d12014-02-17 00:48:25 -080014const uint16_t kCompTeamNumber = 971;
15const uint16_t kPracticeTeamNumber = 8971;
brians343bc112013-02-10 01:53:46 +000016
Brian Silverman6eb51f12013-11-02 14:39:01 -070017// Contains the voltages for an analog hall effect sensor on a shifter.
18struct ShifterHallEffect {
Brian Silvermanc8e21512013-11-03 15:53:11 -080019 // The numbers to use for scaling raw voltages to 0-1.
Brian Silverman6eb51f12013-11-02 14:39:01 -070020 double high, low;
21
Brian Silvermanc8e21512013-11-03 15:53:11 -080022 // The numbers for when the dog is clear of each gear.
Brian Silverman6eb51f12013-11-02 14:39:01 -070023 double clear_high, clear_low;
24};
25
Brian Silverman431500a2013-10-28 19:50:15 -070026// This structure contains current values for all of the things that change.
27struct Values {
Brian Silverman2c793712014-02-16 19:32:32 -080028 // This is useful for representing the 2 sides of a hall effect sensor etc.
Brian Silvermanaae236a2014-02-17 01:49:39 -080029 struct AnglePair {
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080030 // The angles for increasing values (posedge on lower, negedge on upper).
31 double lower_angle, upper_angle;
32 // The angles for decreasing values (negedge on lower, posedge on upper).
33 double lower_decreasing_angle, upper_decreasing_angle;
Brian Silverman2c793712014-02-16 19:32:32 -080034 };
35
Brian Silverman1a6590d2013-11-04 14:46:46 -080036 // The ratio from the encoder shaft to the drivetrain wheels.
37 double drivetrain_encoder_ratio;
38
39 // The gear ratios from motor shafts to the drivetrain wheels for high and low
40 // gear.
41 double low_gear_ratio;
42 double high_gear_ratio;
Brian Silverman431500a2013-10-28 19:50:15 -070043
Brian Silverman6eb51f12013-11-02 14:39:01 -070044 ShifterHallEffect left_drive, right_drive;
45
Brian Silverman1a6590d2013-11-04 14:46:46 -080046 bool clutch_transmission;
47
Brian Silverman2c590c32013-11-04 18:08:54 -080048 ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop;
49 ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop;
Brian Silvermandfdcd582014-02-16 20:50:09 -080050
Austin Schuh60c56662014-02-17 14:37:19 -080051 struct Shooter {
Ben Fredricksonedf0e092014-02-16 10:46:50 +000052 double lower_limit;
53 double upper_limit;
Austin Schuh30537882014-02-18 01:07:23 -080054 double lower_hard_limit;
55 double upper_hard_limit;
56 // If the plunger is further back than this position, it is safe for the
57 // latch to be down. Anything else would be considered a collision.
58 double latch_max_safe_position;
Brian Silvermanaae236a2014-02-17 01:49:39 -080059 AnglePair plunger_back;
60 AnglePair pusher_distal;
61 AnglePair pusher_proximal;
Austin Schuh60c56662014-02-17 14:37:19 -080062 double zeroing_off_speed;
63 double zeroing_speed;
Ben Fredricksonedf0e092014-02-16 10:46:50 +000064 };
65
Austin Schuh60c56662014-02-17 14:37:19 -080066 Shooter shooter;
Austin Schuh3bb9a442014-02-02 16:01:45 -080067
Austin Schuhd27931c2014-02-16 19:18:20 -080068 struct Claws {
69 double claw_zeroing_off_speed;
70 double claw_zeroing_speed;
71 double claw_zeroing_separation;
Austin Schuhcc0bf312014-02-09 00:39:29 -080072
Brian Silverman7c021c42014-02-17 15:15:56 -080073 // claw separation that would be considered a collision
Austin Schuh069143b2014-02-17 02:46:26 -080074 double claw_min_separation;
75 double claw_max_separation;
Austin Schuhcc0bf312014-02-09 00:39:29 -080076
Brian Silverman0d2b7cb2014-02-18 20:25:57 -080077 // We should never get closer/farther than these.
78 double soft_min_separation;
79 double soft_max_separation;
80
Austin Schuhd27931c2014-02-16 19:18:20 -080081 // Three hall effects are known as front, calib and back
Brian Silvermanaae236a2014-02-17 01:49:39 -080082 typedef Values::AnglePair AnglePair;
Austin Schuhd27931c2014-02-16 19:18:20 -080083
84 struct Claw {
85 double lower_hard_limit;
86 double upper_hard_limit;
87 double lower_limit;
88 double upper_limit;
89 AnglePair front;
90 AnglePair calibration;
91 AnglePair back;
92 };
93
94 Claw upper_claw;
95 Claw lower_claw;
96
97 double claw_unimportant_epsilon;
98 double start_fine_tune_pos;
Austin Schuh4cb047f2014-02-16 21:10:19 -080099 double max_zeroing_voltage;
Austin Schuh4b7b5d02014-02-10 21:20:34 -0800100 };
Austin Schuhd27931c2014-02-16 19:18:20 -0800101 Claws claw;
Brian Silverman431500a2013-10-28 19:50:15 -0700102};
103
104// Creates (once) a Values instance and returns a reference to it.
105const Values &GetValues();
brians343bc112013-02-10 01:53:46 +0000106
107} // namespace constants
108} // namespace frc971
Brian Silverman431500a2013-10-28 19:50:15 -0700109
110#endif // FRC971_CONSTANTS_H_