milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 1 | #ifndef Y2022_CONSTANTS_H_ |
| 2 | #define Y2022_CONSTANTS_H_ |
| 3 | |
| 4 | #include <array> |
| 5 | #include <cmath> |
| 6 | #include <cstdint> |
| 7 | |
| 8 | #include "frc971/constants.h" |
| 9 | #include "frc971/control_loops/pose.h" |
| 10 | #include "frc971/control_loops/static_zeroing_single_dof_profiled_subsystem.h" |
| 11 | #include "y2022/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 12 | #include "y2022/control_loops/superstructure/intake/intake_plant.h" |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 13 | |
| 14 | namespace y2022 { |
| 15 | namespace constants { |
| 16 | |
| 17 | struct Values { |
| 18 | static const int kZeroingSampleSize = 200; |
| 19 | |
| 20 | static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; } |
| 21 | static constexpr double kDrivetrainEncoderCountsPerRevolution() { |
| 22 | return kDrivetrainCyclesPerRevolution() * 4; |
| 23 | } |
Griffin Bui | 6f27af2 | 2022-01-30 13:47:28 -0800 | [diff] [blame] | 24 | static constexpr double kDrivetrainEncoderRatio() { |
| 25 | return (14.0 / 54.0) * (22.0 / 56.0); |
| 26 | } |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 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 | } |
| 33 | static constexpr double kRollerSupplyCurrentLimit() { return 30.0; } |
| 34 | static constexpr double kRollerStatorCurrentLimit() { return 40.0; } |
| 35 | |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 36 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 37 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 38 | intake; |
| 39 | |
| 40 | // TODO (Yash): Constants need to be tuned |
| 41 | static constexpr ::frc971::constants::Range kIntakeRange() { |
| 42 | return ::frc971::constants::Range{ |
| 43 | .lower_hard = -0.5, // Back Hard |
| 44 | .upper_hard = 2.85 + 0.05, // Front Hard |
| 45 | .lower = -0.300, // Back Soft |
| 46 | .upper = 2.725 // Front Soft |
| 47 | }; |
| 48 | } |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 49 | // Climber |
| 50 | static constexpr double kClimberSupplyCurrentLimit() { return 60.0; } |
Milo Lin | 6b5e458 | 2022-01-29 14:51:37 -0800 | [diff] [blame] | 51 | |
| 52 | // Intake |
| 53 | // two encoders with same gear ratio for intake |
| 54 | static constexpr double kIntakeEncoderCountsPerRevolution() { return 512.0; } |
| 55 | |
| 56 | static constexpr double kIntakeEncoderRatio() { |
| 57 | return ((16.0 / 60.0) * (18.0 / 62.0)); |
| 58 | } |
| 59 | |
| 60 | // TODO(Milo): Also need to add specific PPR (Pulse per revolution) |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber(). Should |
| 64 | // be called before realtime because this allocates memory. |
| 65 | void InitValues(); |
| 66 | |
| 67 | // Returns a reference to the Values instance for |
| 68 | // ::aos::network::GetTeamNumber(). Values must be initialized through |
| 69 | // InitValues() before calling this. |
| 70 | const Values &GetValues(); |
| 71 | |
| 72 | } // namespace constants |
| 73 | } // namespace y2022 |
| 74 | |
| 75 | #endif // Y2022_CONSTANTS_H_ |