milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 1 | #include "y2022/constants.h" |
| 2 | |
| 3 | #include <cinttypes> |
| 4 | #include <map> |
| 5 | |
| 6 | #if __has_feature(address_sanitizer) |
| 7 | #include "sanitizer/lsan_interface.h" |
| 8 | #endif |
| 9 | |
| 10 | #include "absl/base/call_once.h" |
| 11 | #include "aos/mutex/mutex.h" |
| 12 | #include "aos/network/team_number.h" |
Nathan Leong | 342b85e | 2023-01-08 13:49:33 -0800 | [diff] [blame^] | 13 | #include "frc971/wpilib/wpilib_utils.h" |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 14 | #include "glog/logging.h" |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 15 | #include "y2022/control_loops/superstructure/catapult/integral_catapult_plant.h" |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 16 | #include "y2022/control_loops/superstructure/climber/integral_climber_plant.h" |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 17 | #include "y2022/control_loops/superstructure/intake/integral_intake_plant.h" |
| 18 | #include "y2022/control_loops/superstructure/turret/integral_turret_plant.h" |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 19 | |
| 20 | namespace y2022 { |
| 21 | namespace constants { |
| 22 | |
| 23 | const int Values::kZeroingSampleSize; |
| 24 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 25 | Values MakeValues(uint16_t team) { |
| 26 | LOG(INFO) << "creating a Constants for team: " << team; |
| 27 | |
| 28 | Values r; |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 29 | |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 30 | // Intake constants. |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 31 | auto *const intake_front = &r.intake_front; |
| 32 | auto *const intake_back = &r.intake_back; |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 33 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 34 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 35 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 36 | intake_params; |
| 37 | |
| 38 | intake_params.zeroing_voltage = 3.0; |
| 39 | intake_params.operating_voltage = 12.0; |
| 40 | intake_params.zeroing_profile_params = {0.5, 3.0}; |
| 41 | intake_params.default_profile_params = {6.0, 30.0}; |
| 42 | intake_params.range = Values::kIntakeRange(); |
| 43 | intake_params.make_integral_loop = |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 44 | control_loops::superstructure::intake::MakeIntegralIntakeLoop; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 45 | intake_params.zeroing_constants.average_filter_size = |
| 46 | Values::kZeroingSampleSize; |
| 47 | intake_params.zeroing_constants.one_revolution_distance = |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 48 | M_PI * 2.0 * constants::Values::kIntakeEncoderRatio(); |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 49 | intake_params.zeroing_constants.zeroing_threshold = 0.0005; |
| 50 | intake_params.zeroing_constants.moving_buffer_size = 20; |
| 51 | intake_params.zeroing_constants.allowable_encoder_error = 0.9; |
| 52 | intake_params.zeroing_constants.measured_absolute_position = 0.0; |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 53 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 54 | intake_front->subsystem_params = intake_params; |
| 55 | intake_back->subsystem_params = intake_params; |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 56 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 57 | // Turret constants. |
| 58 | auto *const turret = &r.turret; |
| 59 | auto *const turret_params = &turret->subsystem_params; |
Milind Upadhyay | e9075d1 | 2022-04-12 22:45:16 -0700 | [diff] [blame] | 60 | auto *turret_range = &r.turret_range; |
| 61 | |
| 62 | *turret_range = ::frc971::constants::Range{ |
| 63 | .lower_hard = -7.0, // Back Hard |
| 64 | .upper_hard = 3.4, // Front Hard |
| 65 | .lower = -6.5, // Back Soft |
| 66 | .upper = 3.15 // Front Soft |
| 67 | }; |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 68 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 69 | turret_params->zeroing_voltage = 4.0; |
Austin Schuh | 798be92 | 2022-03-12 12:00:41 -0800 | [diff] [blame] | 70 | turret_params->operating_voltage = 12.0; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 71 | turret_params->zeroing_profile_params = {0.5, 2.0}; |
milind-u | c63d094 | 2022-04-15 12:07:42 -0700 | [diff] [blame] | 72 | turret_params->default_profile_params = {10.0, 20.0}; |
Milind Upadhyay | e9075d1 | 2022-04-12 22:45:16 -0700 | [diff] [blame] | 73 | turret_params->default_profile_params = {15.0, 20.0}; |
| 74 | turret_params->range = *turret_range; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 75 | turret_params->make_integral_loop = |
| 76 | control_loops::superstructure::turret::MakeIntegralTurretLoop; |
| 77 | turret_params->zeroing_constants.average_filter_size = |
| 78 | Values::kZeroingSampleSize; |
| 79 | turret_params->zeroing_constants.one_revolution_distance = |
| 80 | M_PI * 2.0 * constants::Values::kTurretEncoderRatio(); |
| 81 | turret_params->zeroing_constants.zeroing_threshold = 0.0005; |
| 82 | turret_params->zeroing_constants.moving_buffer_size = 20; |
| 83 | turret_params->zeroing_constants.allowable_encoder_error = 0.9; |
| 84 | turret_params->zeroing_constants.measured_absolute_position = 0.0; |
Yash Chainani | 997a749 | 2022-01-29 15:48:56 -0800 | [diff] [blame] | 85 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 86 | // Climber constants |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 87 | auto *const climber = &r.climber; |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 88 | climber->subsystem_params.zeroing_voltage = 3.0; |
| 89 | climber->subsystem_params.operating_voltage = 12.0; |
| 90 | climber->subsystem_params.zeroing_profile_params = {0.5, 0.1}; |
Austin Schuh | 8507c9f | 2022-03-13 18:08:28 -0700 | [diff] [blame] | 91 | climber->subsystem_params.default_profile_params = {5.0, 1.0}; |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 92 | climber->subsystem_params.range = Values::kClimberRange(); |
| 93 | climber->subsystem_params.make_integral_loop = |
| 94 | control_loops::superstructure::climber::MakeIntegralClimberLoop; |
| 95 | |
Griffin Bui | bcbef48 | 2022-02-23 15:32:10 -0800 | [diff] [blame] | 96 | // Flipper arm constants |
| 97 | Values::PotConstants flipper_arms; |
| 98 | flipper_arms.subsystem_params.zeroing_voltage = 3.0; |
| 99 | flipper_arms.subsystem_params.operating_voltage = 12.0; |
| 100 | flipper_arms.subsystem_params.zeroing_profile_params = {0.5, 0.1}; |
| 101 | flipper_arms.subsystem_params.default_profile_params = {6.0, 1.0}; |
| 102 | flipper_arms.subsystem_params.range = Values::kFlipperArmRange(); |
| 103 | |
Austin Schuh | e18df6d | 2022-03-05 14:02:03 -0800 | [diff] [blame] | 104 | auto *const flipper_arm_right = &r.flipper_arm_right; |
| 105 | auto *const flipper_arm_left = &r.flipper_arm_left; |
Griffin Bui | bcbef48 | 2022-02-23 15:32:10 -0800 | [diff] [blame] | 106 | |
| 107 | *flipper_arm_right = flipper_arms; |
| 108 | *flipper_arm_left = flipper_arms; |
| 109 | |
| 110 | // No integral loops for flipper arms |
| 111 | |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 112 | // Catapult |
| 113 | Values::PotAndAbsEncoderConstants *const catapult = &r.catapult; |
| 114 | ::frc971::control_loops::StaticZeroingSingleDOFProfiledSubsystemParams< |
| 115 | ::frc971::zeroing::PotAndAbsoluteEncoderZeroingEstimator> |
| 116 | *const catapult_params = &catapult->subsystem_params; |
| 117 | |
| 118 | catapult_params->zeroing_voltage = 4.0; |
| 119 | catapult_params->operating_voltage = 12.0; |
| 120 | catapult_params->zeroing_profile_params = {0.5, 2.0}; |
| 121 | catapult_params->default_profile_params = {15.0, 40.0}; |
| 122 | catapult_params->range = Values::kCatapultRange(); |
| 123 | catapult_params->make_integral_loop = |
| 124 | &control_loops::superstructure::catapult::MakeIntegralCatapultLoop; |
| 125 | catapult_params->zeroing_constants.average_filter_size = |
| 126 | Values::kZeroingSampleSize; |
| 127 | catapult_params->zeroing_constants.one_revolution_distance = |
| 128 | M_PI * 2.0 * constants::Values::kCatapultEncoderRatio(); |
| 129 | catapult_params->zeroing_constants.zeroing_threshold = 0.0005; |
| 130 | catapult_params->zeroing_constants.moving_buffer_size = 20; |
| 131 | catapult_params->zeroing_constants.allowable_encoder_error = 0.9; |
| 132 | |
Ravago Jones | 3283ce0 | 2022-03-09 19:31:29 -0800 | [diff] [blame] | 133 | // Interpolation table for comp and practice robots |
| 134 | r.shot_interpolation_table = InterpolationTable<Values::ShotParams>({ |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 135 | {1.0, {0.12, 19.4}}, |
| 136 | {1.6, {0.12, 19.4}}, |
| 137 | {1.9, {0.17, 19.4}}, |
| 138 | {2.12, {0.21, 19.4}}, |
| 139 | {2.9, {0.30, 19.9}}, |
Austin Schuh | 1ed66ab | 2022-04-02 22:39:17 -0700 | [diff] [blame] | 140 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 141 | {3.2, {0.33, 20.1}}, |
Austin Schuh | 9628b8b | 2022-04-16 10:18:59 -0700 | [diff] [blame] | 142 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 143 | {3.60, {0.39, 20.65}}, |
| 144 | {4.50, {0.44, 22.3}}, |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 145 | {4.9, {0.43, 22.75}}, // up to here |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 146 | {5.4, {0.43, 23.85}}, |
Austin Schuh | 1ed66ab | 2022-04-02 22:39:17 -0700 | [diff] [blame] | 147 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 148 | {6.0, {0.42, 25.3}}, |
| 149 | {7.0, {0.40, 27.7}}, |
Austin Schuh | 9628b8b | 2022-04-16 10:18:59 -0700 | [diff] [blame] | 150 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 151 | {10.0, {0.40, 27.7}}, |
Ravago Jones | 3283ce0 | 2022-03-09 19:31:29 -0800 | [diff] [blame] | 152 | }); |
| 153 | |
James Kuszmaul | b9ba9a5 | 2022-03-31 22:16:01 -0700 | [diff] [blame] | 154 | if (false) { |
| 155 | // 1.5 meters -> 2.7 |
| 156 | // 2.3 meters -> 4.7 |
| 157 | // 4.5 meters -> 7.0 |
| 158 | // 7.0 meters -> 9.0 |
| 159 | |
| 160 | constexpr double kShotVelocity = 9.0; |
| 161 | r.shot_velocity_interpolation_table = |
| 162 | InterpolationTable<Values::ShotVelocityParams>({ |
| 163 | {1.0, {kShotVelocity}}, |
| 164 | {10.0, {kShotVelocity}}, |
| 165 | }); |
| 166 | } else { |
| 167 | r.shot_velocity_interpolation_table = |
| 168 | InterpolationTable<Values::ShotVelocityParams>({ |
| 169 | {1.0, {2.7}}, |
| 170 | {1.5, {2.7}}, |
| 171 | {2.3, {4.7}}, |
| 172 | {4.5, {7.0}}, |
| 173 | {7.0, {9.0}}, |
| 174 | {10.0, {9.0}}, |
| 175 | }); |
| 176 | } |
| 177 | |
Milind Upadhyay | c76bb4c | 2022-09-21 09:31:48 -0700 | [diff] [blame] | 178 | Values::BallColorParams *const ball_color = &r.ball_color; |
| 179 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 180 | switch (team) { |
| 181 | // A set of constants for tests. |
| 182 | case 1: |
Ravago Jones | 3283ce0 | 2022-03-09 19:31:29 -0800 | [diff] [blame] | 183 | r.shot_interpolation_table = InterpolationTable<Values::ShotParams>({ |
| 184 | {2, {0.08, 8.0}}, |
| 185 | {5, {0.6, 10.0}}, |
| 186 | }); |
| 187 | |
James Kuszmaul | b9ba9a5 | 2022-03-31 22:16:01 -0700 | [diff] [blame] | 188 | r.shot_velocity_interpolation_table = |
| 189 | InterpolationTable<Values::ShotVelocityParams>({ |
| 190 | {2, {2.0}}, |
| 191 | {5, {4.0}}, |
| 192 | }); |
| 193 | |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 194 | climber->potentiometer_offset = -0.035; |
| 195 | intake_front->potentiometer_offset = 3.122; |
Nathan Leong | 7fdbd66 | 2022-11-19 15:53:13 -0800 | [diff] [blame] | 196 | intake_front->subsystem_params.zeroing_constants |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 197 | .measured_absolute_position = 0.175; |
| 198 | intake_back->potentiometer_offset = 3.365; |
Nathan Leong | 7fdbd66 | 2022-11-19 15:53:13 -0800 | [diff] [blame] | 199 | intake_back->subsystem_params.zeroing_constants |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 200 | .measured_absolute_position = 0.051; |
| 201 | turret->potentiometer_offset = -7.932; |
Nathan Leong | 7fdbd66 | 2022-11-19 15:53:13 -0800 | [diff] [blame] | 202 | turret->subsystem_params.zeroing_constants.measured_absolute_position = |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 203 | 1.166; |
| 204 | flipper_arm_left->potentiometer_offset = -6.40; |
| 205 | flipper_arm_right->potentiometer_offset = 5.56; |
Nathan Leong | 7fdbd66 | 2022-11-19 15:53:13 -0800 | [diff] [blame] | 206 | |
James Kuszmaul | 00c730d | 2022-12-14 20:29:53 -0800 | [diff] [blame] | 207 | catapult_params->zeroing_constants.measured_absolute_position = 0.0; |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 208 | catapult->potentiometer_offset = -2.033; |
Milind Upadhyay | c76bb4c | 2022-09-21 09:31:48 -0700 | [diff] [blame] | 209 | |
| 210 | ball_color->reference_red = {0, 0, 1, 1}; |
| 211 | ball_color->reference_blue = {0, 0, 1, 1}; |
| 212 | ball_color->ball_location = {0, 0, 1, 1}; |
| 213 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 214 | break; |
| 215 | |
| 216 | case kCompTeamNumber: |
milind-u | 6e7d8d4 | 2022-04-06 18:30:43 -0700 | [diff] [blame] | 217 | climber->potentiometer_offset = -0.0463847608752 - 0.0376876182111 + |
| 218 | 0.0629263851579 - 0.00682128836400001 + |
Austin Schuh | 69379ac | 2022-04-29 21:27:05 -0700 | [diff] [blame] | 219 | 0.0172237531191 - 0.0172237531191 + |
| 220 | 0.00443383743660001 - 0.0117667224279; |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 221 | |
James Kuszmaul | 4072704 | 2023-01-07 18:01:01 -0800 | [diff] [blame] | 222 | intake_front->potentiometer_offset = + 3.572389; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 223 | intake_front->subsystem_params.zeroing_constants |
James Kuszmaul | 4072704 | 2023-01-07 18:01:01 -0800 | [diff] [blame] | 224 | .measured_absolute_position = 0.238611243887673; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 225 | |
Austin Schuh | 463abe2 | 2022-04-15 19:15:49 -0700 | [diff] [blame] | 226 | intake_back->potentiometer_offset = |
| 227 | 3.1409576474047 + 0.278653334013286 + 0.00879137908308503 + |
Austin Schuh | 69379ac | 2022-04-29 21:27:05 -0700 | [diff] [blame] | 228 | 0.0837134053818833 + 0.832945730100298 - 0.00759895654985426 - |
| 229 | 2.03114758819475 + 0.318379597392509 + 0.675664531140745 + |
James Kuszmaul | 4072704 | 2023-01-07 18:01:01 -0800 | [diff] [blame] | 230 | 0.0650864893911517 - 0.0202318432257168 - 0.0561212375592096; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 231 | intake_back->subsystem_params.zeroing_constants |
James Kuszmaul | 4072704 | 2023-01-07 18:01:01 -0800 | [diff] [blame] | 232 | .measured_absolute_position = 0.292329083185933; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 233 | |
milind-u | c63d094 | 2022-04-15 12:07:42 -0700 | [diff] [blame] | 234 | turret->potentiometer_offset = |
| 235 | -9.99970387166721 + 0.06415943 + 0.073290115367682 - |
| 236 | 0.0634440443622909 + 0.213601224728352 + 0.0657973101027296 - |
| 237 | 0.114726411377978 - 0.980314029089968 - 0.0266013159299456 + |
Austin Schuh | 69379ac | 2022-04-29 21:27:05 -0700 | [diff] [blame] | 238 | 0.0631240002215899 + 0.222882504808653 + 0.0370686419434252 - |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 239 | 0.0965027214840068 - 0.126737479717192 - 0.0773753775457 + |
| 240 | 2.8132444751306; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 241 | turret->subsystem_params.zeroing_constants.measured_absolute_position = |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 242 | 1.16683731504739; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 243 | |
| 244 | flipper_arm_left->potentiometer_offset = -6.4; |
Austin Schuh | 6b1e4d9 | 2022-03-12 12:02:46 -0800 | [diff] [blame] | 245 | flipper_arm_right->potentiometer_offset = 5.56; |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 246 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 247 | *turret_range = ::frc971::constants::Range{ |
| 248 | .lower_hard = -7.0, // Back Hard |
| 249 | .upper_hard = 3.4, // Front Hard |
| 250 | .lower = -6.4, // Back Soft |
| 251 | .upper = 2.9 // Front Soft |
| 252 | }; |
| 253 | turret_params->range = *turret_range; |
| 254 | |
Austin Schuh | 275f981 | 2022-03-05 14:02:37 -0800 | [diff] [blame] | 255 | catapult_params->zeroing_constants.measured_absolute_position = |
| 256 | 1.71723370408082; |
| 257 | catapult->potentiometer_offset = -2.03383240293769; |
Milind Upadhyay | c76bb4c | 2022-09-21 09:31:48 -0700 | [diff] [blame] | 258 | |
| 259 | ball_color->reference_red = {440, 150, 50, 130}; |
| 260 | ball_color->reference_blue = {440, 350, 30, 100}; |
| 261 | ball_color->ball_location = {100, 400, 140, 50}; |
| 262 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 263 | break; |
| 264 | |
| 265 | case kPracticeTeamNumber: |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 266 | catapult_params->range.lower = -0.885; |
| 267 | |
Milind Upadhyay | d02ae80 | 2022-09-21 09:33:48 -0700 | [diff] [blame] | 268 | r.shot_interpolation_table = InterpolationTable<Values::ShotParams>({ |
| 269 | {1.0, {0.08, 20.0}}, |
| 270 | {1.6, {0.08, 20.0}}, |
| 271 | {1.9, {0.11, 20.0}}, |
| 272 | {2.12, {0.15, 20.5}}, |
| 273 | {2.9, {0.27, 20.2}}, |
| 274 | |
| 275 | {3.2, {0.29, 20.6}}, |
| 276 | |
| 277 | {3.60, {0.36, 21.0}}, |
| 278 | {4.50, {0.41, 22.7}}, |
| 279 | {4.9, {0.42, 23.3}}, |
| 280 | {5.4, {0.42, 24.6}}, |
| 281 | |
| 282 | {6.0, {0.42, 26.25}}, |
| 283 | {7.0, {0.39, 28.25}}, |
| 284 | |
| 285 | {10.0, {0.39, 28.25}}, |
| 286 | }); |
| 287 | |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 288 | climber->potentiometer_offset = |
| 289 | -0.1209073362519 + 0.0760598 - 0.0221716219244 - 0.00321684; |
Milind Upadhyay | a10e5e0 | 2022-09-10 22:57:25 -0700 | [diff] [blame] | 290 | intake_front->potentiometer_offset = 3.06604378582351 - 0.60745632979918; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 291 | intake_front->subsystem_params.zeroing_constants |
Milind Upadhyay | a10e5e0 | 2022-09-10 22:57:25 -0700 | [diff] [blame] | 292 | .measured_absolute_position = 0.143667561169188; |
Milind Upadhyay | d7b9eca | 2022-09-26 21:28:03 -0700 | [diff] [blame] | 293 | intake_back->potentiometer_offset = |
| 294 | 3.10861174832838 + 0.431432052414186 - 0.171422335492571 + |
| 295 | 0.0414174770317617 + 0.0908883523752557 - 0.0632767010207473; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 296 | intake_back->subsystem_params.zeroing_constants |
Milind Upadhyay | d7b9eca | 2022-09-26 21:28:03 -0700 | [diff] [blame] | 297 | .measured_absolute_position = 0.404628372743507; |
Milind Upadhyay | 4e9f260 | 2022-09-22 14:47:54 -0700 | [diff] [blame] | 298 | |
Milind Upadhyay | ac29d02 | 2022-09-24 20:43:52 -0700 | [diff] [blame] | 299 | turret->potentiometer_offset = |
| 300 | -8.14418207451834 + 0.342635491808218 - 0.944807955598189 - |
| 301 | 0.0718028442723373 - 0.0793332946417493 + 0.233707527214682 + |
| 302 | 0.0828349540635251 + 0.677740533247017 - 0.0828349540635251 - |
| 303 | 0.0903654044329345 - 0.105426305171759 - 0.150609007388226 - |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 304 | 0.0338870266623506 - 0.0677740533247011 - 0.135548106649404 - 0.6852; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 305 | turret->subsystem_params.zeroing_constants.measured_absolute_position = |
Austin Schuh | d84d431 | 2022-11-07 09:04:48 -0800 | [diff] [blame] | 306 | 0.8306; |
| 307 | *turret_range = ::frc971::constants::Range{ |
| 308 | .lower_hard = -7.0, // Back Hard |
| 309 | .upper_hard = 3.4, // Front Hard |
| 310 | .lower = -6.4, // Back Soft |
| 311 | .upper = 2.9 // Front Soft |
| 312 | }; |
Milind Upadhyay | e9075d1 | 2022-04-12 22:45:16 -0700 | [diff] [blame] | 313 | turret_params->range = *turret_range; |
Nathan Leong | 4afefdb | 2022-12-21 21:17:19 -0800 | [diff] [blame] | 314 | flipper_arm_left->potentiometer_offset = |
| 315 | -4.39536583413615 - 0.108401297910291; |
| 316 | flipper_arm_right->potentiometer_offset = |
| 317 | 4.36264091401229 + 0.175896445665755; |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 318 | |
Milind Upadhyay | e9075d1 | 2022-04-12 22:45:16 -0700 | [diff] [blame] | 319 | catapult_params->zeroing_constants.measured_absolute_position = |
| 320 | 1.62909518684227; |
| 321 | catapult->potentiometer_offset = -1.52951814169821 - 0.0200812009850977; |
Milind Upadhyay | c76bb4c | 2022-09-21 09:31:48 -0700 | [diff] [blame] | 322 | |
| 323 | ball_color->reference_red = {526, 75, 110, 220}; |
| 324 | ball_color->reference_blue = {526, 340, 110, 100}; |
| 325 | ball_color->ball_location = {40, 440, 200, 30}; |
| 326 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 327 | break; |
| 328 | |
| 329 | case kCodingRobotTeamNumber: |
Ravago Jones | 3283ce0 | 2022-03-09 19:31:29 -0800 | [diff] [blame] | 330 | r.shot_interpolation_table = InterpolationTable<Values::ShotParams>({ |
| 331 | {2, {0.08, 8.0}}, |
| 332 | {5, {0.6, 10.0}}, |
| 333 | }); |
| 334 | |
James Kuszmaul | b9ba9a5 | 2022-03-31 22:16:01 -0700 | [diff] [blame] | 335 | r.shot_velocity_interpolation_table = |
| 336 | InterpolationTable<Values::ShotVelocityParams>({ |
| 337 | {2, {2.0}}, |
| 338 | {5, {4.0}}, |
| 339 | }); |
| 340 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 341 | climber->potentiometer_offset = 0.0; |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 342 | intake_front->potentiometer_offset = 0.0; |
| 343 | intake_front->subsystem_params.zeroing_constants |
| 344 | .measured_absolute_position = 0.0; |
| 345 | intake_back->potentiometer_offset = 0.0; |
| 346 | intake_back->subsystem_params.zeroing_constants |
| 347 | .measured_absolute_position = 0.0; |
| 348 | turret->potentiometer_offset = 0.0; |
| 349 | turret->subsystem_params.zeroing_constants.measured_absolute_position = |
| 350 | 0.0; |
Griffin Bui | bcbef48 | 2022-02-23 15:32:10 -0800 | [diff] [blame] | 351 | flipper_arm_left->potentiometer_offset = 0.0; |
| 352 | flipper_arm_right->potentiometer_offset = 0.0; |
Austin Schuh | 39f26f6 | 2022-02-24 21:34:46 -0800 | [diff] [blame] | 353 | |
| 354 | catapult_params->zeroing_constants.measured_absolute_position = 0.0; |
| 355 | catapult->potentiometer_offset = 0.0; |
Milind Upadhyay | c76bb4c | 2022-09-21 09:31:48 -0700 | [diff] [blame] | 356 | |
| 357 | ball_color->reference_red = {0, 0, 1, 1}; |
| 358 | ball_color->reference_blue = {0, 0, 1, 1}; |
| 359 | ball_color->ball_location = {0, 0, 1, 1}; |
| 360 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 361 | break; |
| 362 | |
| 363 | default: |
| 364 | LOG(FATAL) << "unknown team: " << team; |
| 365 | } |
| 366 | |
Nathan Leong | 342b85e | 2023-01-08 13:49:33 -0800 | [diff] [blame^] | 367 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 368 | Values::kClimberRange(), climber->potentiometer_offset, |
| 369 | [](double meters) { return meters / Values::kClimberPotMetersPerVolt(); }, |
| 370 | false)) |
| 371 | << "Couldn't translate climber pot"; |
| 372 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 373 | Values::kFlipperArmRange(), flipper_arm_left->potentiometer_offset, |
| 374 | [](double radians) { |
| 375 | return radians / Values::kFlipperArmsPotRadiansPerVolt(); |
| 376 | }, |
| 377 | false)) |
| 378 | << "Couldn't translate flipper left pot"; |
| 379 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 380 | Values::kFlipperArmRange(), flipper_arm_right->potentiometer_offset, |
| 381 | [](double radians) { |
| 382 | return radians / Values::kFlipperArmsPotRadiansPerVolt(); |
| 383 | }, |
| 384 | true)) |
| 385 | << "Couldn't translate flipper right pot"; |
| 386 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 387 | Values::kIntakeRange(), intake_front->potentiometer_offset, |
| 388 | [](double radians) { |
| 389 | return radians / Values::kIntakePotRadiansPerVolt(); |
| 390 | }, |
| 391 | true)) |
| 392 | << "Couldn't translate front intake pot"; |
| 393 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 394 | Values::kIntakeRange(), intake_back->potentiometer_offset, |
| 395 | [](double radians) { |
| 396 | return radians / Values::kIntakePotRadiansPerVolt(); |
| 397 | }, |
| 398 | true)) |
| 399 | << "Couldn't translate back intake pot"; |
| 400 | CHECK(frc971::wpilib::SafePotVoltageRange( |
| 401 | *turret_range, turret->potentiometer_offset, |
| 402 | [](double radians) { |
| 403 | return radians / Values::kTurretPotRadiansPerVolt(); |
| 404 | }, |
| 405 | false)) |
| 406 | << "Couldn't translate turret pot"; |
| 407 | |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 408 | return r; |
| 409 | } |
| 410 | |
Henry Speiser | 55aa3ba | 2022-02-21 23:21:12 -0800 | [diff] [blame] | 411 | Values MakeValues() { return MakeValues(aos::network::GetTeamNumber()); } |
milind-u | 086d726 | 2022-01-19 20:44:18 -0800 | [diff] [blame] | 412 | |
| 413 | } // namespace constants |
| 414 | } // namespace y2022 |