Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 1 | #ifndef Y2022_BOT3_CONSTANTS_H_ |
| 2 | #define Y2022_BOT3_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 "frc971/shooter_interpolation/interpolation.h" |
| 12 | #include "y2022_bot3/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
| 13 | |
| 14 | using ::frc971::shooter_interpolation::InterpolationTable; |
| 15 | |
| 16 | namespace y2022_bot3 { |
| 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 1.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 | } |
| 33 | |
| 34 | static double DrivetrainEncoderToMeters(int32_t in) { |
| 35 | return ((static_cast<double>(in) / |
| 36 | kDrivetrainEncoderCountsPerRevolution()) * |
| 37 | (2.0 * M_PI)) * |
| 38 | kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius; |
| 39 | } |
| 40 | |
| 41 | struct PotAndAbsEncoderConstants { |
| 42 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 43 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 44 | subsystem_params; |
| 45 | double potentiometer_offset; |
| 46 | }; |
Nikita Narang | 869ebf3 | 2022-08-20 13:09:49 -0700 | [diff] [blame] | 47 | |
| 48 | // Intake rollers |
| 49 | static constexpr double kIntakeRollerSupplyCurrentLimit() { return 40.0; } |
| 50 | static constexpr double kIntakeRollerStatorCurrentLimit() { return 60.0; } |
| 51 | |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 52 | }; |
Nikita Narang | 869ebf3 | 2022-08-20 13:09:49 -0700 | [diff] [blame] | 53 | |
Henry Speiser | 354d278 | 2022-07-22 13:56:48 -0700 | [diff] [blame] | 54 | // Creates and returns a Values instance for the constants. |
| 55 | // Should be called before realtime because this allocates memory. |
| 56 | // Only the first call to either of these will be used. |
| 57 | Values MakeValues(uint16_t team); |
| 58 | |
| 59 | // Calls MakeValues with aos::network::GetTeamNumber() |
| 60 | Values MakeValues(); |
| 61 | |
| 62 | } // namespace constants |
| 63 | } // namespace y2022_bot3 |
| 64 | |
| 65 | #endif // Y2022_CONSTANTS_H_ |