Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 1 | #ifndef Y2017_CONSTANTS_H_ |
| 2 | #define Y2017_CONSTANTS_H_ |
| 3 | |
| 4 | #include <stdint.h> |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 5 | #include <math.h> |
| 6 | |
| 7 | #include "frc971/constants.h" |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 8 | |
| 9 | namespace y2017 { |
| 10 | namespace constants { |
| 11 | |
Brian Silverman | db8498a | 2017-02-11 17:16:09 -0800 | [diff] [blame^] | 12 | // Has all of our "constants", except the ones that come from other places. The |
| 13 | // ones which change between robots are put together with a workable way to |
| 14 | // retrieve the values for the current robot. |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 15 | |
| 16 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 17 | // Some of these values are related to the conversion between raw values |
| 18 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
Brian Silverman | db8498a | 2017-02-11 17:16:09 -0800 | [diff] [blame^] | 19 | // |
| 20 | // All ratios are from the encoder shaft to the output units. |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 21 | |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 22 | struct Values { |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 23 | // TODO(constants): Update/check these with what we're using this year. |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 24 | |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 25 | struct Intake { |
| 26 | double pot_offset; |
| 27 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 28 | }; |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 29 | |
| 30 | struct Turret { |
| 31 | double pot_offset; |
| 32 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 33 | }; |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 34 | |
| 35 | struct Hood { |
| 36 | double pot_offset; |
| 37 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 38 | }; |
Brian Silverman | db8498a | 2017-02-11 17:16:09 -0800 | [diff] [blame^] | 39 | |
| 40 | static const int kZeroingSampleSize = 200; |
| 41 | |
| 42 | // TODO(Brian): This isn't all the way to the output yet. |
| 43 | static constexpr double kDrivetrainEncoderRatio = 1.0 ; |
| 44 | |
| 45 | static constexpr double kShooterEncoderRatio = 32.0 / 48.0; |
| 46 | |
| 47 | static constexpr double kIntakeEncoderRatio = |
| 48 | (16.0 * 0.25) * (20.0 / 40.0) / (2.0 * M_PI) * 0.0254; |
| 49 | static constexpr double kIntakePotRatio = (16 * 0.25) / (2.0 * M_PI) * 0.0254; |
| 50 | static constexpr double kIntakeEncoderIndexDifference = |
| 51 | 2.0 * M_PI * kIntakeEncoderRatio; |
| 52 | |
| 53 | static constexpr ::frc971::constants::Range kIntakeRange{ |
| 54 | // Lower hard stop in meters (from inches). |
| 55 | -0.600 * 0.0254, |
| 56 | // Upper hard stop in meters (from inches). |
| 57 | 8.655 * 0.0254, |
| 58 | // Lower soft stop in meters (from inches). |
| 59 | 0.000, |
| 60 | // Upper soft stop in meters (from inches). |
| 61 | 8.530 * 0.0254}; |
| 62 | |
| 63 | static constexpr double kHoodEncoderRatio = 20.0 / 345.0; |
| 64 | static constexpr double kHoodPotRatio = 20.0 / 345.0; |
| 65 | static constexpr double kHoodEncoderIndexDifference = |
| 66 | 2.0 * M_PI * kHoodEncoderRatio; |
| 67 | |
| 68 | static constexpr ::frc971::constants::Range kHoodRange{ |
| 69 | // Lower hard stop in radians. |
| 70 | -1.0 / 345.0 * 2.0 * M_PI, |
| 71 | // Upper hard stop in radians. |
| 72 | 39.0 / 345.0 * 2.0 * M_PI, |
| 73 | // Lower soft stop in radians. |
| 74 | 0.0, |
| 75 | // Upper soft stop in radians. |
| 76 | (39.0 - 1.0) / 345.0 * 2.0 * M_PI}; |
| 77 | |
| 78 | static constexpr double kTurretEncoderRatio = 16.0 / 92.0; |
| 79 | static constexpr double kTurretPotRatio = 16.0 / 92.0; |
| 80 | static constexpr double kTurretEncoderIndexDifference = |
| 81 | 2.0 * M_PI * kTurretEncoderRatio; |
| 82 | |
| 83 | static constexpr ::frc971::constants::Range kTurretRange{ |
| 84 | // Lower hard stop in radians. |
| 85 | -460.0 / 2.0 * M_PI / 180.0, |
| 86 | // Upper hard stop in radians. |
| 87 | 460.0 / 2.0 * M_PI / 180.0, |
| 88 | // Lower soft stop in radians. |
| 89 | -450.0 / 2.0 * M_PI / 180.0, |
| 90 | // Upper soft stop in radians. |
| 91 | 450.0 / 2.0 * M_PI / 180.0}; |
| 92 | |
| 93 | static constexpr double kIndexerEncoderRatio = (18.0 / 36.0) * (12.0 / 84.0); |
| 94 | static constexpr double kIndexerEncoderIndexDifference = |
| 95 | 2.0 * M_PI * kIndexerEncoderRatio; |
| 96 | |
| 97 | double drivetrain_max_speed; |
| 98 | |
| 99 | Intake intake; |
| 100 | |
| 101 | Turret turret; |
| 102 | |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 103 | Hood hood; |
| 104 | |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 105 | double down_error; |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame] | 106 | const char *vision_name; |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 110 | // returns a reference to it. |
| 111 | const Values &GetValues(); |
| 112 | |
| 113 | // Creates Values instances for each team number it is called with and returns |
| 114 | // them. |
| 115 | const Values &GetValuesForTeam(uint16_t team_number); |
| 116 | |
| 117 | } // namespace constants |
| 118 | } // namespace y2017 |
| 119 | |
| 120 | #endif // Y2017_CONSTANTS_H_ |