Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 1 | #ifndef Y2016_CONSTANTS_H_ |
| 2 | #define Y2016_CONSTANTS_H_ |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 6 | #include "frc971/control_loops/state_feedback_loop.h" |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 7 | #include "frc971/shifter_hall_effect.h" |
| 8 | #include "frc971/constants.h" |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 9 | |
Austin Schuh | c5467a1 | 2016-02-13 20:25:13 -0800 | [diff] [blame^] | 10 | #define INTAKE_ENCODER_RATIO (16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0) |
| 11 | #define INTAKE_POT_RATIO (16.0 / 58.0) |
| 12 | #define INTAKE_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * INTAKE_ENCODER_RATIO) |
| 13 | |
| 14 | #define SHOULDER_ENCODER_RATIO (16.0 / 58.0 * 18.0 / 72.0 * 14.0 / 64.0) |
| 15 | #define SHOULDER_POT_RATIO (16.0 / 58.0) |
| 16 | #define SHOULDER_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * SHOULDER_ENCODER_RATIO) |
| 17 | |
| 18 | #define WRIST_ENCODER_RATIO (16.0 / 48.0 * 18.0 / 64.0 * 14.0 / 54.0) |
| 19 | #define WRIST_POT_RATIO (16.0 / 48.0) |
| 20 | #define WRIST_ENCODER_INDEX_DIFFERENCE (2.0 * M_PI * WRIST_ENCODER_RATIO) |
| 21 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 22 | namespace y2016 { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 23 | namespace constants { |
| 24 | |
| 25 | using ::frc971::constants::ShifterHallEffect; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 26 | using ::frc971::constants::ZeroingConstants; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 27 | |
| 28 | // Has all of the numbers that change for both robots and makes it easy to |
| 29 | // retrieve the values for the current one. |
| 30 | |
| 31 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 32 | // Some of these values are related to the conversion between raw values |
| 33 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
| 34 | |
| 35 | // This structure contains current values for all of the things that change. |
| 36 | struct Values { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 37 | // The ratio from the encoder shaft to the drivetrain wheels. |
| 38 | double drivetrain_encoder_ratio; |
| 39 | |
| 40 | // The gear ratios from motor shafts to the drivetrain wheels for high and low |
| 41 | // gear. |
| 42 | double low_gear_ratio; |
| 43 | double high_gear_ratio; |
| 44 | ShifterHallEffect left_drive, right_drive; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 45 | |
| 46 | double turn_width; |
| 47 | |
| 48 | ::std::function<StateFeedbackLoop<2, 2, 2>()> make_v_drivetrain_loop; |
| 49 | ::std::function<StateFeedbackLoop<4, 2, 2>()> make_drivetrain_loop; |
| 50 | |
| 51 | double drivetrain_max_speed; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 52 | |
| 53 | // Defines a range of motion for a subsystem. |
| 54 | // These are all absolute positions in scaled units. |
| 55 | struct Range { |
| 56 | double lower_hard; |
| 57 | double upper_hard; |
| 58 | double lower; |
| 59 | double upper; |
| 60 | }; |
| 61 | |
| 62 | struct Intake { |
| 63 | Range limits; |
| 64 | ZeroingConstants zeroing; |
| 65 | }; |
| 66 | Intake intake; |
| 67 | |
| 68 | struct Shoulder { |
| 69 | Range limits; |
| 70 | ZeroingConstants zeroing; |
| 71 | }; |
| 72 | Shoulder shoulder; |
| 73 | |
| 74 | struct Wrist { |
| 75 | Range limits; |
| 76 | ZeroingConstants zeroing; |
| 77 | }; |
| 78 | Wrist wrist; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 82 | // returns a reference to it. |
| 83 | const Values &GetValues(); |
| 84 | |
| 85 | // Creates Values instances for each team number it is called with and returns |
| 86 | // them. |
| 87 | const Values &GetValuesForTeam(uint16_t team_number); |
| 88 | |
| 89 | } // namespace constants |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 90 | } // namespace y2016 |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 91 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 92 | #endif // Y2016_CONSTANTS_H_ |