blob: 877cff568416df09eac158222d1e41499175f29f [file] [log] [blame]
Henry Speiser354d2782022-07-22 13:56:48 -07001#ifndef Y2022_BOT3_CONSTANTS_H_
2#define Y2022_BOT3_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/shooter_interpolation/interpolation.h"
12#include "y2022_bot3/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
13
14using ::frc971::shooter_interpolation::InterpolationTable;
15
16namespace y2022_bot3 {
17namespace constants {
18
19struct Values {
20 static const int kZeroingSampleSize = 200;
21
22 static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; }
23 static constexpr double kDrivetrainEncoderCountsPerRevolution() {
24 return kDrivetrainCyclesPerRevolution() * 4;
25 }
26 static constexpr double kDrivetrainEncoderRatio() { return 1.0; }
27 static constexpr double kMaxDrivetrainEncoderPulsesPerSecond() {
28 return control_loops::drivetrain::kFreeSpeed / (2.0 * M_PI) *
29 control_loops::drivetrain::kHighOutputRatio /
30 constants::Values::kDrivetrainEncoderRatio() *
31 kDrivetrainEncoderCountsPerRevolution();
32 }
33
34 static double DrivetrainEncoderToMeters(int32_t in) {
35 return ((static_cast<double>(in) /
36 kDrivetrainEncoderCountsPerRevolution()) *
37 (2.0 * M_PI)) *
38 kDrivetrainEncoderRatio() * control_loops::drivetrain::kWheelRadius;
39 }
40
41 struct PotAndAbsEncoderConstants {
42 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams<
43 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
44 subsystem_params;
45 double potentiometer_offset;
46 };
47};
48// Creates and returns a Values instance for the constants.
49// Should be called before realtime because this allocates memory.
50// Only the first call to either of these will be used.
51Values MakeValues(uint16_t team);
52
53// Calls MakeValues with aos::network::GetTeamNumber()
54Values MakeValues();
55
56} // namespace constants
57} // namespace y2022_bot3
58
59#endif // Y2022_CONSTANTS_H_