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 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 10 | namespace y2016 { |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 11 | namespace constants { |
| 12 | |
| 13 | using ::frc971::constants::ShifterHallEffect; |
Tyler Chatow | f8f0311 | 2017-02-05 14:31:34 -0800 | [diff] [blame] | 14 | using ::frc971::constants::PotAndIndexPulseZeroingConstants; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 15 | |
| 16 | // Has all of the numbers that change for both robots and makes it easy to |
| 17 | // retrieve the values for the current one. |
| 18 | |
| 19 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 20 | // Some of these values are related to the conversion between raw values |
| 21 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
| 22 | |
| 23 | // This structure contains current values for all of the things that change. |
| 24 | struct Values { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 25 | // ///// Mutual constants between robots. ///// |
| 26 | // TODO(constants): Update/check these with what we're using this year. |
| 27 | static const int kZeroingSampleSize = 200; |
| 28 | |
| 29 | // The ratio from the encoder shaft to the drivetrain wheels. |
| 30 | static constexpr double kDrivetrainEncoderRatio = |
Austin Schuh | 9f77fd2 | 2016-02-21 02:53:58 -0800 | [diff] [blame] | 31 | (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0) /*encoder gears*/; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 32 | |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 33 | // Ratios for our subsystems. |
| 34 | static constexpr double kShooterEncoderRatio = 1.0; |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame] | 35 | static constexpr double kIntakeEncoderRatio = |
Campbell Crowley | 3b6977e | 2016-08-07 16:27:03 -0700 | [diff] [blame] | 36 | 14.0 / 64.0 * 18.0 / 72.0 * 16.0 / 48.0; |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame] | 37 | static constexpr double kShoulderEncoderRatio = |
Campbell Crowley | 3b6977e | 2016-08-07 16:27:03 -0700 | [diff] [blame] | 38 | 14.0 / 64.0 * 18.0 / 72.0 * 12.0 / 42.0; |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame] | 39 | static constexpr double kWristEncoderRatio = |
Campbell Crowley | 3b6977e | 2016-08-07 16:27:03 -0700 | [diff] [blame] | 40 | 14.0 / 54.0 * 18.0 / 64.0 * 16.0 / 48.0; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 41 | |
Campbell Crowley | 3b6977e | 2016-08-07 16:27:03 -0700 | [diff] [blame] | 42 | static constexpr double kIntakePotRatio = 18.0 / 72.0 * 16.0 / 48.0; |
| 43 | static constexpr double kShoulderPotRatio = 12.0 / 42.0; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 44 | static constexpr double kWristPotRatio = 16.0 / 48.0; |
| 45 | |
| 46 | // Difference in radians between index pulses. |
Comran Morshed | 1b3290d | 2016-02-14 16:35:51 +0000 | [diff] [blame] | 47 | static constexpr double kIntakeEncoderIndexDifference = |
| 48 | 2.0 * M_PI * kIntakeEncoderRatio; |
| 49 | static constexpr double kShoulderEncoderIndexDifference = |
| 50 | 2.0 * M_PI * kShoulderEncoderRatio; |
| 51 | static constexpr double kWristEncoderIndexDifference = |
| 52 | 2.0 * M_PI * kWristEncoderRatio; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 53 | |
| 54 | // Subsystem motion ranges, in whatever units that their respective queues say |
| 55 | // the use. |
Austin Schuh | 6aeae0c | 2016-03-20 16:45:28 -0700 | [diff] [blame] | 56 | static constexpr ::frc971::constants::Range kIntakeRange{// Lower hard stop |
Austin Schuh | e54b987 | 2016-05-01 12:29:17 -0700 | [diff] [blame] | 57 | -0.5, |
Austin Schuh | 6aeae0c | 2016-03-20 16:45:28 -0700 | [diff] [blame] | 58 | // Upper hard stop |
Adam Snaider | a5aa3f9 | 2016-04-17 13:31:59 -0700 | [diff] [blame] | 59 | 2.85 + 0.05, |
Austin Schuh | 6aeae0c | 2016-03-20 16:45:28 -0700 | [diff] [blame] | 60 | // Lower soft stop |
| 61 | -0.300, |
| 62 | // Uppper soft stop |
| 63 | 2.725}; |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 64 | static constexpr ::frc971::constants::Range kShoulderRange{// Lower hard stop |
Austin Schuh | e54b987 | 2016-05-01 12:29:17 -0700 | [diff] [blame] | 65 | -0.150, |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 66 | // Upper hard stop |
| 67 | 2.8, |
| 68 | // Lower soft stop |
Austin Schuh | 449966b | 2016-03-11 21:27:05 -0800 | [diff] [blame] | 69 | -0.010, |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 70 | // Uppper soft stop |
| 71 | 2.0}; |
| 72 | static constexpr ::frc971::constants::Range kWristRange{// Lower hard stop |
Austin Schuh | e54b987 | 2016-05-01 12:29:17 -0700 | [diff] [blame] | 73 | -3.0, |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 74 | // Upper hard stop |
Austin Schuh | e54b987 | 2016-05-01 12:29:17 -0700 | [diff] [blame] | 75 | 3.0, |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 76 | // Lower soft stop |
Austin Schuh | a3240bd | 2016-03-13 15:31:01 -0700 | [diff] [blame] | 77 | -2.6, |
Austin Schuh | 3480e93 | 2016-02-21 13:06:51 -0800 | [diff] [blame] | 78 | // Uppper soft stop |
Austin Schuh | a3240bd | 2016-03-13 15:31:01 -0700 | [diff] [blame] | 79 | 2.6}; |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 80 | |
| 81 | // ///// Dynamic constants. ///// |
| 82 | double drivetrain_max_speed; |
| 83 | |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 84 | struct Intake { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 85 | double pot_offset; |
Tyler Chatow | f8f0311 | 2017-02-05 14:31:34 -0800 | [diff] [blame] | 86 | PotAndIndexPulseZeroingConstants zeroing; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 87 | }; |
| 88 | Intake intake; |
| 89 | |
| 90 | struct Shoulder { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 91 | double pot_offset; |
Tyler Chatow | f8f0311 | 2017-02-05 14:31:34 -0800 | [diff] [blame] | 92 | PotAndIndexPulseZeroingConstants zeroing; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 93 | }; |
| 94 | Shoulder shoulder; |
| 95 | |
| 96 | struct Wrist { |
Comran Morshed | 225f0b9 | 2016-02-10 20:34:27 +0000 | [diff] [blame] | 97 | double pot_offset; |
Tyler Chatow | f8f0311 | 2017-02-05 14:31:34 -0800 | [diff] [blame] | 98 | PotAndIndexPulseZeroingConstants zeroing; |
Austin Schuh | 2fc10fa | 2016-02-08 00:44:34 -0800 | [diff] [blame] | 99 | }; |
| 100 | Wrist wrist; |
Brian Silverman | 2ccf8c5 | 2016-03-15 00:22:26 -0400 | [diff] [blame] | 101 | |
Austin Schuh | 889fee8 | 2016-04-13 22:16:36 -0700 | [diff] [blame] | 102 | const double down_error; |
Brian Silverman | 2ccf8c5 | 2016-03-15 00:22:26 -0400 | [diff] [blame] | 103 | const char *vision_name; |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 107 | // returns a reference to it. |
| 108 | const Values &GetValues(); |
| 109 | |
| 110 | // Creates Values instances for each team number it is called with and returns |
| 111 | // them. |
| 112 | const Values &GetValuesForTeam(uint16_t team_number); |
| 113 | |
| 114 | } // namespace constants |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 115 | } // namespace y2016 |
Comran Morshed | 9a9948c | 2016-01-16 15:58:04 +0000 | [diff] [blame] | 116 | |
Comran Morshed | 6c6a0a9 | 2016-01-17 12:45:16 +0000 | [diff] [blame] | 117 | #endif // Y2016_CONSTANTS_H_ |