blob: 050c5c71e1bd6c4ceb5e45fe927594965c24e893 [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 }
33 static constexpr double kRollerSupplyCurrentLimit() { return 30.0; }
34 static constexpr double kRollerStatorCurrentLimit() { return 40.0; }
35
Yash Chainani997a7492022-01-29 15:48:56 -080036 ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams<
37 ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator>
38 intake;
39
40 // TODO (Yash): Constants need to be tuned
41 static constexpr ::frc971::constants::Range kIntakeRange() {
42 return ::frc971::constants::Range{
43 .lower_hard = -0.5, // Back Hard
44 .upper_hard = 2.85 + 0.05, // Front Hard
45 .lower = -0.300, // Back Soft
46 .upper = 2.725 // Front Soft
47 };
48 }
milind-u086d7262022-01-19 20:44:18 -080049 // Climber
50 static constexpr double kClimberSupplyCurrentLimit() { return 60.0; }
Milo Lin6b5e4582022-01-29 14:51:37 -080051
52 // Intake
53 // two encoders with same gear ratio for intake
54 static constexpr double kIntakeEncoderCountsPerRevolution() { return 512.0; }
55
56 static constexpr double kIntakeEncoderRatio() {
57 return ((16.0 / 60.0) * (18.0 / 62.0));
58 }
59
60 // TODO(Milo): Also need to add specific PPR (Pulse per revolution)
milind-u086d7262022-01-19 20:44:18 -080061};
62
63// Creates (once) a Values instance for ::aos::network::GetTeamNumber(). Should
64// be called before realtime because this allocates memory.
65void InitValues();
66
67// Returns a reference to the Values instance for
68// ::aos::network::GetTeamNumber(). Values must be initialized through
69// InitValues() before calling this.
70const Values &GetValues();
71
72} // namespace constants
73} // namespace y2022
74
75#endif // Y2022_CONSTANTS_H_