blob: 03a6cae49b1c1ce236123e52b5301f6d284d8bc4 [file] [log] [blame]
Maxwell Hendersonad312342023-01-10 12:07:47 -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 "y2023/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
12
13namespace y2023 {
14namespace constants {
15
16constexpr uint16_t kCompTeamNumber = 971;
17constexpr uint16_t kPracticeTeamNumber = 9971;
18constexpr uint16_t kCodingRobotTeamNumber = 7971;
19
20struct Values {
21 static const int kZeroingSampleSize = 200;
22
23 static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; }
24 static constexpr double kDrivetrainEncoderCountsPerRevolution() {
25 return kDrivetrainCyclesPerRevolution() * 4;
26 }
27 static constexpr double kDrivetrainEncoderRatio() { return 1.0; }
28 static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() {
29 return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) *
30 control_loops::drivetrain::kHighOutputRatio /
31 constants::Values::kDrivetrainEncoderRatio() *
32 kDrivetrainEncoderCountsPerRevolution();
33 }
34
35 static double DrivetrainEncoderToMeters(int32_t in) {
36 return ((static_cast<double>(in) /
37 kDrivetrainEncoderCountsPerRevolution()) *
38 (2.0 * M_PI)) *
39 kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius;
40 }
41
42 struct PotConstants {
43 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams<
44 ::frc971::zeroing::RelativeEncoderZeroingEstimator>
45 subsystem_params;
46 double potentiometer_offset;
47 };
48
49 struct PotAndAbsEncoderConstants {
50 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams<
51 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
52 subsystem_params;
53 double potentiometer_offset;
54 };
55};
56
57// Creates and returns a Values instance for the constants.
58// Should be called before realtime because this allocates memory.
59// Only the first call to either of these will be used.
60Values MakeValues(uint16_t team);
61
62// Calls MakeValues with aos::network::GetTeamNumber()
63Values MakeValues();
64
65} // namespace constants
66} // namespace y2023
67
68#endif // Y2023_CONSTANTS_H_