Maxwell Henderson | 43684fa | 2023-11-06 11:08:06 -0800 | [diff] [blame] | 1 | #ifndef Y2023_BOT3_CONSTANTS_H_ |
| 2 | #define Y2023_BOT3_CONSTANTS_H_ |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 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" |
Maxwell Henderson | 43684fa | 2023-11-06 11:08:06 -0800 | [diff] [blame] | 11 | #include "frc971/zeroing/pot_and_absolute_encoder.h" |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 12 | #include "y2023_bot3/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 13 | namespace y2023_bot3::constants { |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 14 | |
Maxwell Henderson | 20fa069 | 2023-12-22 15:37:38 -0800 | [diff] [blame] | 15 | constexpr uint16_t kThirdRobotTeamNumber = 9984; |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 16 | |
| 17 | struct Values { |
| 18 | static const int kZeroingSampleSize = 200; |
| 19 | |
| 20 | static const int kSuperstructureCANWriterPriority = 35; |
| 21 | static const int kDrivetrainWriterPriority = 35; |
| 22 | static const int kDrivetrainTxPriority = 36; |
| 23 | static const int kDrivetrainRxPriority = 36; |
| 24 | |
| 25 | // TODO(max): Change these constants based on 3rd drivetrain CAD |
| 26 | static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; } |
| 27 | static constexpr double kDrivetrainEncoderCountsPerRevolution() { |
| 28 | return kDrivetrainCyclesPerRevolution() * 4; |
| 29 | } |
| 30 | static constexpr double kDrivetrainEncoderRatio() { return 1.0; } |
| 31 | static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() { |
| 32 | return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) * |
| 33 | control_loops::drivetrain::kHighOutputRatio / |
| 34 | constants::Values::kDrivetrainEncoderRatio() * |
| 35 | kDrivetrainEncoderCountsPerRevolution(); |
| 36 | } |
| 37 | |
| 38 | static constexpr double kDrivetrainSupplyCurrentLimit() { return 35.0; } |
| 39 | static constexpr double kDrivetrainStatorCurrentLimit() { return 60.0; } |
| 40 | |
Ariv Diggi | c892e92 | 2023-10-21 15:52:06 -0700 | [diff] [blame] | 41 | // timeout to ensure code doesn't get stuck after releasing the "intake" |
| 42 | // button |
| 43 | static constexpr std::chrono::milliseconds kExtraIntakingTime() { |
| 44 | return std::chrono::milliseconds{100}; |
| 45 | } |
| 46 | |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 47 | static double DrivetrainEncoderToMeters(int32_t in) { |
| 48 | return ((static_cast<double>(in) / |
| 49 | kDrivetrainEncoderCountsPerRevolution()) * |
| 50 | (2.0 * M_PI)) * |
| 51 | kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius; |
| 52 | } |
| 53 | |
| 54 | static double DrivetrainCANEncoderToMeters(double rotations) { |
| 55 | return (rotations * (2.0 * M_PI)) * |
Maxwell Henderson | f1cfe7f | 2023-12-26 10:48:26 -0800 | [diff] [blame] | 56 | control_loops::drivetrain::kHighOutputRatio; |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 57 | } |
| 58 | }; |
| 59 | |
| 60 | // Creates and returns a Values instance for the constants. |
| 61 | // Should be called before realtime because this allocates memory. |
| 62 | // Only the first call to either of these will be used. |
| 63 | Values MakeValues(uint16_t team); |
| 64 | |
| 65 | // Calls MakeValues with aos::network::GetTeamNumber() |
| 66 | Values MakeValues(); |
| 67 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 68 | } // namespace y2023_bot3::constants |
Ariv Diggi | 0af59c0 | 2023-10-07 13:15:39 -0700 | [diff] [blame] | 69 | |
Maxwell Henderson | 43684fa | 2023-11-06 11:08:06 -0800 | [diff] [blame] | 70 | #endif // Y2023_BOT3_CONSTANTS_H_ |