blob: 7e359f4acc5d7bc26443d579ce1b8f321573fcb1 [file] [log] [blame]
Maxwell Hendersonc3d063a2023-12-26 17:37:22 -08001#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 "frc971/zeroing/absolute_encoder.h"
12#include "frc971/zeroing/pot_and_absolute_encoder.h"
13#include "y2024_defense/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
14
15namespace y2024_defense {
16namespace constants {
17
18constexpr uint16_t kTeamNumber = 9972;
19
20struct Values {
21 static const int kZeroingSampleSize = 200;
22
23 static const int kDrivetrainWriterPriority = 35;
24 static const int kDrivetrainTxPriority = 36;
25 static const int kDrivetrainRxPriority = 36;
26
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
42 static double DrivetrainEncoderToMeters(int32_t in) {
43 return ((static_cast<double>(in) /
44 kDrivetrainEncoderCountsPerRevolution()) *
45 (2.0 * M_PI)) *
46 kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius;
47 }
48
49 static double DrivetrainCANEncoderToMeters(double rotations) {
50 return (rotations * (2.0 * M_PI)) *
51 control_loops::drivetrain::kHighOutputRatio;
52 }
53};
54
55// Creates and returns a Values instance for the constants.
56// Should be called before realtime because this allocates memory.
57// Only the first call to either of these will be used.
58Values MakeValues(uint16_t team);
59
60// Calls MakeValues with aos::network::GetTeamNumber()
61Values MakeValues();
62
63} // namespace constants
64} // namespace y2024_defense
65
66#endif // Y2023_CONSTANTS_H_