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 | } |
James Kuszmaul | 53507e1 | 2022-02-12 18:36:40 -0800 | [diff] [blame] | 33 | |
| 34 | static double DrivetrainEncoderToMeters(int32_t in) { |
| 35 | return ((static_cast<double>(in) / |
| 36 | kDrivetrainEncoderCountsPerRevolution()) * |
| 37 | (2.0 * M_PI)) * |
| 38 | kDrivetrainEncoderRatio() * |
| 39 | control_loops::drivetrain::kWheelRadius; |
| 40 | } |
| 41 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 42 | static constexpr double kRollerSupplyCurrentLimit() { return 30.0; } |
| 43 | static constexpr double kRollerStatorCurrentLimit() { return 40.0; } |
| 44 | |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 45 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 46 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 47 | intake; |
| 48 | |
| 49 | // TODO (Yash): Constants need to be tuned |
| 50 | static constexpr ::frc971::constants::Range kIntakeRange() { |
| 51 | return ::frc971::constants::Range{ |
| 52 | .lower_hard = -0.5, // Back Hard |
| 53 | .upper_hard = 2.85 + 0.05, // Front Hard |
| 54 | .lower = -0.300, // Back Soft |
| 55 | .upper = 2.725 // Front Soft |
| 56 | }; |
| 57 | } |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 58 | // Climber |
| 59 | static constexpr double kClimberSupplyCurrentLimit() { return 60.0; } |
Milo Lin | 6b5e458 | 2022-01-29 14:51:37 -0800 | [diff] [blame] | 60 | |
| 61 | // Intake |
| 62 | // two encoders with same gear ratio for intake |
| 63 | static constexpr double kIntakeEncoderCountsPerRevolution() { return 512.0; } |
| 64 | |
| 65 | static constexpr double kIntakeEncoderRatio() { |
| 66 | return ((16.0 / 60.0) * (18.0 / 62.0)); |
| 67 | } |
| 68 | |
| 69 | // TODO(Milo): Also need to add specific PPR (Pulse per revolution) |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | // Creates (once) a Values instance for ::aos::network::GetTeamNumber(). Should |
| 73 | // be called before realtime because this allocates memory. |
| 74 | void InitValues(); |
| 75 | |
| 76 | // Returns a reference to the Values instance for |
| 77 | // ::aos::network::GetTeamNumber(). Values must be initialized through |
| 78 | // InitValues() before calling this. |
| 79 | const Values &GetValues(); |
| 80 | |
| 81 | } // namespace constants |
| 82 | } // namespace y2022 |
| 83 | |
| 84 | #endif // Y2022_CONSTANTS_H_ |