Tyler Chatow | 37ecdcd | 2019-01-26 20:18:42 -0800 | [diff] [blame] | 1 | #ifndef Y2019_CONSTANTS_H_ |
| 2 | #define Y2019_CONSTANTS_H_ |
| 3 | |
Tyler Chatow | 37ecdcd | 2019-01-26 20:18:42 -0800 | [diff] [blame] | 4 | #include <math.h> |
Sabina Davis | 1b84afa | 2019-02-09 01:20:21 -0800 | [diff] [blame] | 5 | #include <stdint.h> |
Tyler Chatow | 37ecdcd | 2019-01-26 20:18:42 -0800 | [diff] [blame] | 6 | |
| 7 | #include "frc971/constants.h" |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 8 | #include "y2019/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Tyler Chatow | 37ecdcd | 2019-01-26 20:18:42 -0800 | [diff] [blame] | 9 | |
| 10 | namespace y2019 { |
| 11 | namespace constants { |
| 12 | |
| 13 | // Has all of our "constants", except the ones that come from other places. The |
| 14 | // ones which change between robots are put together with a workable way to |
| 15 | // retrieve the values for the current robot. |
| 16 | |
| 17 | // Everything is in SI units (volts, radians, meters, seconds, etc). |
| 18 | // Some of these values are related to the conversion between raw values |
| 19 | // (encoder counts, voltage, etc) to scaled units (radians, meters, etc). |
| 20 | // |
| 21 | // All ratios are from the encoder shaft to the output units. |
| 22 | |
| 23 | struct Values { |
| 24 | static const int kZeroingSampleSize = 200; |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 25 | |
| 26 | static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; } |
| 27 | static constexpr double kDrivetrainEncoderCountsPerRevolution() { |
| 28 | return kDrivetrainCyclesPerRevolution() * 4; |
| 29 | } |
| 30 | static constexpr double kDrivetrainEncoderRatio() { |
Sabina Davis | 1b84afa | 2019-02-09 01:20:21 -0800 | [diff] [blame] | 31 | return (24.0 / 52.0); |
Sabina Davis | 7be49f3 | 2019-02-02 00:30:19 -0800 | [diff] [blame] | 32 | } |
| 33 | static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() { |
| 34 | return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) * |
| 35 | control_loops::drivetrain::kHighOutputRatio / |
| 36 | constants::Values::kDrivetrainEncoderRatio() * |
| 37 | kDrivetrainEncoderCountsPerRevolution(); |
| 38 | } |
Tyler Chatow | 37ecdcd | 2019-01-26 20:18:42 -0800 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 42 | // returns a reference to it. |
| 43 | const Values &GetValues(); |
| 44 | |
| 45 | // Creates Values instances for each team number it is called with and returns |
| 46 | // them. |
| 47 | const Values &GetValuesForTeam(uint16_t team_number); |
| 48 | |
| 49 | } // namespace constants |
| 50 | } // namespace y2019 |
| 51 | |
| 52 | #endif // Y2019_CONSTANTS_H_ |