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 | |
| 12 | // Has all of the numbers that change for both robots and makes it easy to |
| 13 | // retrieve the values for the current one. |
| 14 | |
| 15 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 16 | // Some of these values are related to the conversion between raw values |
| 17 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
| 18 | |
| 19 | // This structure contains current values for all of the things that change. |
| 20 | struct Values { |
| 21 | // ///// Mutual constants between robots. ///// |
| 22 | // TODO(constants): Update/check these with what we're using this year. |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame^] | 23 | |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 24 | static const int kZeroingSampleSize = 200; |
| 25 | |
| 26 | // The ratio from the encoder shaft to the drivetrain wheels. |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 27 | |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame^] | 28 | static constexpr double kDrivetrainEncoderRatio = 1.0 ; |
| 29 | |
| 30 | // Ratios for our subsystems. |
| 31 | static constexpr double kShooterEncoderRatio = 32.0 / 48.0; //Encoder rotation to shooter wheel revolution |
| 32 | static constexpr double kIntakeEncoderRatio = (16 * 0.25) * (20 / 40) / (2.0 * numpy.pi) * 0.0254; //Encoder rotation per Meter(inch per radian) of movement |
| 33 | static constexpr double kIntakePotRatio = (16 * 0.25) / (2.0 * numpy.pi) * 0.0254; //Pot Rotation per Meter(inch per radian) of movement |
| 34 | static constexpr double kHoodEncoderRatio = 20.0 / 345.0; //Encoder rotation to Hood rotation |
| 35 | static constexpr double kHoodPotRatio = 20.0 / 345.0; //Pot Rotation per Hood rotation |
| 36 | static constexpr double kTurretEncoderRatio = 16.0 / 92.0; //Encoder rotation toTurret rotation |
| 37 | static constexpr double kTurretPotRatio = 16.0 / 92.0; //Pot Rotation per Turret rotation |
| 38 | static constexpr double kIndexerEncoderRatio = (18.0 / 36.0) * (12.0 / 84.0); //Encoder rotation to Inner indexer rotation |
| 39 | |
| 40 | // Difference in radians between index pulses. |
| 41 | static constexpr double kIntakeEncoderIndexDifference = |
| 42 | 2.0 * M_PI * kIntakeEncoderRatio; |
| 43 | static constexpr double kIndexerEncoderIndexDifference = |
| 44 | 2.0 * M_PI * kIndexerEncoderRatio; |
| 45 | static constexpr double kTurretEncoderIndexDifference = |
| 46 | 2.0 * M_PI * kTurretEncoderRatio; |
| 47 | static constexpr double kHoodEncoderIndexDifference = |
| 48 | 2.0 * M_PI * kHoodEncoderRatio; |
| 49 | |
| 50 | static constexpr ::frc971::constants::Range kIntakeRange{ |
| 51 | // Lower hard stop in meters(inches) |
| 52 | -0.600 * 0.0254, |
| 53 | // Upper hard stop |
| 54 | 8.655 * 0.0254, |
| 55 | // Lower soft stop |
| 56 | 0.000, |
| 57 | // Upper soft stop |
| 58 | 8.530 * 0.0254}; |
| 59 | static constexpr ::frc971::constants::Range kHoodRange{ |
| 60 | // Lower hard stop in radians |
| 61 | -1.0 / 345.0 * 2.0 * M_PI, |
| 62 | // Upper hard stop in radians |
| 63 | 39.0 / 345.0 * 2.0 * M_PI, |
| 64 | // Lower soft stop in radians |
| 65 | 0.0, |
| 66 | // Upper soft stop in radians |
| 67 | (39.0 - 1.0) / 345.0 * 2.0 * M_PI}; |
| 68 | static constexpr ::frc971::constants::Range kTurretRange{ |
| 69 | // Lower hard stop in radians |
| 70 | -460.0 / 2.0 * M_PI / 180.0, |
| 71 | // Upper hard stop in radians |
| 72 | 460.0 / 2.0 * M_PI / 180.0, |
| 73 | // Lower soft stop in radians |
| 74 | -450.0 / 2.0 * M_PI / 180.0, |
| 75 | // Upper soft stop in radians |
| 76 | 450.0 / 2.0 * M_PI / 180.0}; |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 77 | // ///// Dynamic constants. ///// |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame^] | 78 | double drivetrain_max_speed; |
| 79 | |
| 80 | struct Intake { |
| 81 | double pot_offset; |
| 82 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 83 | }; |
| 84 | Intake intake; |
| 85 | |
| 86 | struct Turret { |
| 87 | double pot_offset; |
| 88 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 89 | }; |
| 90 | Turret turret; |
| 91 | |
| 92 | struct Hood { |
| 93 | double pot_offset; |
| 94 | ::frc971::constants::PotAndIndexPulseZeroingConstants zeroing; |
| 95 | }; |
| 96 | Hood hood; |
| 97 | |
Diana Vandenberg | 223703d | 2017-01-28 17:39:53 -0800 | [diff] [blame] | 98 | double down_error; |
Ed Jordan | 8683f43 | 2017-02-12 00:13:26 +0000 | [diff] [blame^] | 99 | const char *vision_name; |
Tyler Chatow | 6107aba | 2017-01-22 01:39:40 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 103 | // returns a reference to it. |
| 104 | const Values &GetValues(); |
| 105 | |
| 106 | // Creates Values instances for each team number it is called with and returns |
| 107 | // them. |
| 108 | const Values &GetValuesForTeam(uint16_t team_number); |
| 109 | |
| 110 | } // namespace constants |
| 111 | } // namespace y2017 |
| 112 | |
| 113 | #endif // Y2017_CONSTANTS_H_ |