Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 1 | #ifndef y2020_CONSTANTS_H_ |
| 2 | #define y2020_CONSTANTS_H_ |
| 3 | |
| 4 | #include <math.h> |
| 5 | #include <stdint.h> |
| 6 | |
| 7 | #include <array> |
| 8 | |
| 9 | #include "frc971/constants.h" |
| 10 | #include "frc971/control_loops/pose.h" |
| 11 | #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h" |
| 12 | #include "y2020/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 13 | #include "y2020/control_loops/superstructure/hood/hood_plant.h" |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame^] | 14 | #include "y2020/control_loops/superstructure/intake/intake_plant.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 15 | |
| 16 | namespace y2020 { |
| 17 | namespace constants { |
| 18 | |
| 19 | struct Values { |
| 20 | static const int kZeroingSampleSize = 200; |
| 21 | |
| 22 | static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; } |
| 23 | static constexpr double kDrivetrainEncoderCountsPerRevolution() { |
| 24 | return kDrivetrainCyclesPerRevolution() * 4; |
| 25 | } |
| 26 | static constexpr double kDrivetrainEncoderRatio() { return (24.0 / 52.0); } |
| 27 | static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() { |
| 28 | return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) * |
| 29 | control_loops::drivetrain::kHighOutputRatio / |
| 30 | constants::Values::kDrivetrainEncoderRatio() * |
| 31 | kDrivetrainEncoderCountsPerRevolution(); |
| 32 | } |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 33 | |
| 34 | // Hood |
| 35 | static constexpr double kHoodEncoderCountsPerRevolution() { return 4096.0; } |
| 36 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame^] | 37 | // TODO(sabina): Update constants |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 38 | static constexpr double kHoodEncoderRatio() { return 1.0; } |
| 39 | |
| 40 | static constexpr double kMaxHoodEncoderPulsesPerSecond() { |
| 41 | return control_loops::superstructure::hood::kFreeSpeed * |
| 42 | control_loops::superstructure::hood::kOutputRatio / |
| 43 | kHoodEncoderRatio() / (2.0 * M_PI) * |
| 44 | kHoodEncoderCountsPerRevolution(); |
| 45 | } |
| 46 | |
| 47 | static constexpr ::frc971::constants::Range kHoodRange() { |
| 48 | return ::frc971::constants::Range{ |
| 49 | 0.00, // Back Hard |
| 50 | 0.79, // Front Hard |
| 51 | 0.14, // Back Soft |
| 52 | 0.78 // Front Soft |
| 53 | }; |
| 54 | } |
| 55 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame^] | 56 | // Intake |
| 57 | static constexpr double kIntakeEncoderCountsPerRevolution() { return 4096.0; } |
| 58 | |
| 59 | static constexpr double kIntakeEncoderRatio() { return (16.0 / 32.0); } |
| 60 | |
| 61 | static constexpr double kMaxIntakeEncoderPulsesPerSecond() { |
| 62 | return control_loops::superstructure::intake::kFreeSpeed * |
| 63 | control_loops::superstructure::intake::kOutputRatio / |
| 64 | kIntakeEncoderRatio() / (2.0 * M_PI) * |
| 65 | kIntakeEncoderCountsPerRevolution(); |
| 66 | } |
| 67 | |
| 68 | // TODO(sabina): update range |
| 69 | static constexpr ::frc971::constants::Range kIntakeRange() { |
| 70 | return ::frc971::constants::Range{ |
| 71 | -1, // Back Hard |
| 72 | 1, // Front Hard |
| 73 | -0.95, // Back Soft |
| 74 | 0.95 // Front Soft |
| 75 | }; |
| 76 | } |
| 77 | |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 78 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 79 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator> |
| 80 | hood; |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame^] | 81 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 82 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator> |
| 83 | intake; |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 87 | // returns a reference to it. |
| 88 | const Values &GetValues(); |
| 89 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame^] | 90 | // Creates Values instances for each team number it is called with and |
| 91 | // returns them. |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 92 | const Values &GetValuesForTeam(uint16_t team_number); |
| 93 | |
| 94 | } // namespace constants |
| 95 | } // namespace y2020 |
| 96 | |
| 97 | #endif // y2020_CONSTANTS_H_ |