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