blob: 92f3a4826acb7ad8a60b498037357cd4b41ee3cc [file] [log] [blame]
milind-u086d7262022-01-19 20:44:18 -08001#ifndef Y2022_CONSTANTS_H_
2#define Y2022_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 "y2022/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
Yash Chainani997a7492022-01-29 15:48:56 -080012#include "y2022/control_loops/superstructure/intake/intake_plant.h"
milind-u086d7262022-01-19 20:44:18 -080013
14namespace y2022 {
15namespace constants {
16
17struct Values {
18 static const int kZeroingSampleSize = 200;
19
20 static constexpr double kDrivetrainCyclesPerRevolution() { return 512.0; }
21 static constexpr double kDrivetrainEncoderCountsPerRevolution() {
22 return kDrivetrainCyclesPerRevolution() * 4;
23 }
Griffin Bui6f27af22022-01-30 13:47:28 -080024 static constexpr double kDrivetrainEncoderRatio() {
25 return (14.0 / 54.0) * (22.0 / 56.0);
26 }
milind-u086d7262022-01-19 20:44:18 -080027 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 }
James Kuszmaul53507e12022-02-12 18:36:40 -080033
34 static double DrivetrainEncoderToMeters(int32_t in) {
35 return ((static_cast<double>(in) /
36 kDrivetrainEncoderCountsPerRevolution()) *
37 (2.0 * M_PI)) *
38 kDrivetrainEncoderRatio() *
39 control_loops::drivetrain::kWheelRadius;
40 }
41
milind-u086d7262022-01-19 20:44:18 -080042 static constexpr double kRollerSupplyCurrentLimit() { return 30.0; }
43 static constexpr double kRollerStatorCurrentLimit() { return 40.0; }
44
Yash Chainani997a7492022-01-29 15:48:56 -080045 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams<
46 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
47 intake;
48
49 // TODO (Yash): Constants need to be tuned
50 static constexpr ::frc971::constants::Range kIntakeRange() {
51 return ::frc971::constants::Range{
52 .lower_hard = -0.5, // Back Hard
53 .upper_hard = 2.85 + 0.05, // Front Hard
54 .lower = -0.300, // Back Soft
55 .upper = 2.725 // Front Soft
56 };
57 }
milind-u086d7262022-01-19 20:44:18 -080058 // Climber
59 static constexpr double kClimberSupplyCurrentLimit() { return 60.0; }
Milo Lin6b5e4582022-01-29 14:51:37 -080060
61 // Intake
62 // two encoders with same gear ratio for intake
63 static constexpr double kIntakeEncoderCountsPerRevolution() { return 512.0; }
64
65 static constexpr double kIntakeEncoderRatio() {
66 return ((16.0 / 60.0) * (18.0 / 62.0));
67 }
68
69 // TODO(Milo): Also need to add specific PPR (Pulse per revolution)
milind-u086d7262022-01-19 20:44:18 -080070};
71
72// Creates (once) a Values instance for ::aos::network::GetTeamNumber(). Should
73// be called before realtime because this allocates memory.
74void InitValues();
75
76// Returns a reference to the Values instance for
77// ::aos::network::GetTeamNumber(). Values must be initialized through
78// InitValues() before calling this.
79const Values &GetValues();
80
81} // namespace constants
82} // namespace y2022
83
84#endif // Y2022_CONSTANTS_H_