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" |
Kai Tinkess | 10943cf | 2020-02-01 15:49:57 -0800 | [diff] [blame] | 15 | #include "y2020/control_loops/superstructure/turret/turret_plant.h" |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 16 | |
| 17 | namespace y2020 { |
| 18 | namespace constants { |
| 19 | |
| 20 | struct Values { |
| 21 | static const int kZeroingSampleSize = 200; |
| 22 | |
| 23 | static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; } |
| 24 | static constexpr double kDrivetrainEncoderCountsPerRevolution() { |
| 25 | return kDrivetrainCyclesPerRevolution() * 4; |
| 26 | } |
| 27 | static constexpr double kDrivetrainEncoderRatio() { return (24.0 / 52.0); } |
| 28 | static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() { |
| 29 | return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) * |
| 30 | control_loops::drivetrain::kHighOutputRatio / |
| 31 | constants::Values::kDrivetrainEncoderRatio() * |
| 32 | kDrivetrainEncoderCountsPerRevolution(); |
| 33 | } |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 34 | |
| 35 | // Hood |
| 36 | static constexpr double kHoodEncoderCountsPerRevolution() { return 4096.0; } |
| 37 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame] | 38 | // TODO(sabina): Update constants |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 39 | static constexpr double kHoodEncoderRatio() { return 1.0; } |
| 40 | |
| 41 | static constexpr double kMaxHoodEncoderPulsesPerSecond() { |
| 42 | return control_loops::superstructure::hood::kFreeSpeed * |
| 43 | control_loops::superstructure::hood::kOutputRatio / |
| 44 | kHoodEncoderRatio() / (2.0 * M_PI) * |
| 45 | kHoodEncoderCountsPerRevolution(); |
| 46 | } |
| 47 | |
| 48 | static constexpr ::frc971::constants::Range kHoodRange() { |
| 49 | return ::frc971::constants::Range{ |
| 50 | 0.00, // Back Hard |
| 51 | 0.79, // Front Hard |
| 52 | 0.14, // Back Soft |
| 53 | 0.78 // Front Soft |
| 54 | }; |
| 55 | } |
| 56 | |
Kai Tinkess | 10943cf | 2020-02-01 15:49:57 -0800 | [diff] [blame] | 57 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 58 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator> |
| 59 | hood; |
| 60 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame] | 61 | // Intake |
| 62 | static constexpr double kIntakeEncoderCountsPerRevolution() { return 4096.0; } |
| 63 | |
| 64 | static constexpr double kIntakeEncoderRatio() { return (16.0 / 32.0); } |
| 65 | |
| 66 | static constexpr double kMaxIntakeEncoderPulsesPerSecond() { |
| 67 | return control_loops::superstructure::intake::kFreeSpeed * |
| 68 | control_loops::superstructure::intake::kOutputRatio / |
| 69 | kIntakeEncoderRatio() / (2.0 * M_PI) * |
| 70 | kIntakeEncoderCountsPerRevolution(); |
| 71 | } |
| 72 | |
| 73 | // TODO(sabina): update range |
| 74 | static constexpr ::frc971::constants::Range kIntakeRange() { |
| 75 | return ::frc971::constants::Range{ |
| 76 | -1, // Back Hard |
| 77 | 1, // Front Hard |
| 78 | -0.95, // Back Soft |
| 79 | 0.95 // Front Soft |
| 80 | }; |
| 81 | } |
| 82 | |
Sabina Davis | a587fbd | 2020-01-31 22:11:15 -0800 | [diff] [blame] | 83 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 84 | ::frc971::zeroing::AbsoluteEncoderZeroingEstimator> |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame] | 85 | intake; |
Kai Tinkess | 10943cf | 2020-02-01 15:49:57 -0800 | [diff] [blame] | 86 | |
| 87 | // Turret |
| 88 | static constexpr double kTurretEncoderCountsPerRevolution() { return 4096.0; } |
| 89 | |
| 90 | static constexpr double kTurretEncoderRatio() { |
| 91 | return 1.0; // TODO (Kai): Get Gear Ratios when ready |
| 92 | } |
| 93 | |
| 94 | static constexpr double kMaxTurretEncoderPulsesPerSecond() { |
| 95 | return control_loops::superstructure::turret::kFreeSpeed * |
| 96 | control_loops::superstructure::turret::kOutputRatio / |
| 97 | kTurretEncoderRatio() / (2.0 * M_PI) * |
| 98 | kTurretEncoderCountsPerRevolution(); |
| 99 | } |
| 100 | |
| 101 | // TODO(austin): Figure out the actual constant here. |
| 102 | static constexpr double kTurretPotRatio() { return 1.0; } |
| 103 | |
| 104 | static constexpr ::frc971::constants::Range kTurretRange() { |
| 105 | return ::frc971::constants::Range{ |
| 106 | // TODO (Kai): Placeholders right now. |
| 107 | -3.2, // Back Hard |
| 108 | 3.2, // Front Hard |
| 109 | -3.14, // Back Soft |
| 110 | 3.14 // Front Soft |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | struct PotAndAbsEncoderConstants { |
| 115 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 116 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 117 | subsystem_params; |
| 118 | double potentiometer_offset; |
| 119 | }; |
| 120 | |
| 121 | PotAndAbsEncoderConstants turret; |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber() and |
| 125 | // returns a reference to it. |
| 126 | const Values &GetValues(); |
| 127 | |
Sabina Davis | e8d3899 | 2020-02-02 15:00:31 -0800 | [diff] [blame] | 128 | // Creates Values instances for each team number it is called with and |
| 129 | // returns them. |
Stephan Massalt | d021f97 | 2020-01-05 20:41:23 -0800 | [diff] [blame] | 130 | const Values &GetValuesForTeam(uint16_t team_number); |
| 131 | |
| 132 | } // namespace constants |
| 133 | } // namespace y2020 |
| 134 | |
| 135 | #endif // y2020_CONSTANTS_H_ |