blob: b9e5a7d28b4d9d0c7cc2c4ab40b362ed2aa6e700 [file] [log] [blame]
Niko Sohmers3860f8a2024-01-12 21:05:19 -08001#ifndef Y2024_CONSTANTS_H_
2#define Y2024_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/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
14
15namespace y2024 {
16namespace constants {
17
18constexpr uint16_t kCompTeamNumber = 971;
19constexpr uint16_t kPracticeTeamNumber = 9971;
20constexpr uint16_t kCodingRobotTeamNumber = 7971;
21
22struct Values {
23 static const int kZeroingSampleSize = 200;
24
25 static const int kSuperstructureCANWriterPriority = 35;
26 static const int kDrivetrainWriterPriority = 35;
27 static const int kDrivetrainTxPriority = 36;
28 static const int kDrivetrainRxPriority = 36;
29
30 // TODO: These values will need to be changed for the 2024 robot.
31 static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; }
32 static constexpr double kDrivetrainEncoderCountsPerRevolution() {
33 return kDrivetrainCyclesPerRevolution() * 4;
34 }
35 static constexpr double kDrivetrainEncoderRatio() { return 1.0; }
36 static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() {
37 return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) *
38 control_loops::drivetrain::kHighOutputRatio /
39 constants::Values::kDrivetrainEncoderRatio() *
40 kDrivetrainEncoderCountsPerRevolution();
41 }
42
43 static constexpr double kDrivetrainSupplyCurrentLimit() { return 35.0; }
44 static constexpr double kDrivetrainStatorCurrentLimit() { return 60.0; }
45
46 static double DrivetrainEncoderToMeters(int32_t in) {
47 return ((static_cast<double>(in) /
48 kDrivetrainEncoderCountsPerRevolution()) *
49 (2.0 * M_PI)) *
50 kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius;
51 }
52
53 static double DrivetrainCANEncoderToMeters(double rotations) {
54 return (rotations * (2.0 * M_PI)) *
55 control_loops::drivetrain::kHighOutputRatio;
56 }
57};
58
59// Creates and returns a Values instance for the constants.
60// Should be called before realtime because this allocates memory.
61// Only the first call to either of these will be used.
62constants::Values MakeValues(uint16_t team);
63
64// Calls MakeValues with aos::network::GetTeamNumber()
65constants::Values MakeValues();
66
67} // namespace constants
68} // namespace y2024
69
70#endif // Y2024_CONSTANTS_H_