Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 1 | #include "frc971/constants.h" |
| 2 | |
| 3 | #include <math.h> |
| 4 | #include <stdint.h> |
| 5 | #include <inttypes.h> |
| 6 | |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 7 | #include <map> |
| 8 | |
| 9 | #if __has_feature(address_sanitizer) |
| 10 | #include "sanitizer/lsan_interface.h" |
| 11 | #endif |
| 12 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 13 | #include "aos/common/logging/logging.h" |
| 14 | #include "aos/common/once.h" |
| 15 | #include "aos/common/network/team_number.h" |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 16 | #include "aos/common/mutex.h" |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 17 | |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 18 | #include "frc971/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h" |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 19 | #include "frc971/control_loops/drivetrain/drivetrain_dog_motor_plant.h" |
Brian Silverman | 2c590c3 | 2013-11-04 18:08:54 -0800 | [diff] [blame] | 20 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 21 | #ifndef M_PI |
| 22 | #define M_PI 3.14159265358979323846 |
| 23 | #endif |
| 24 | |
| 25 | namespace frc971 { |
| 26 | namespace constants { |
| 27 | namespace { |
| 28 | |
Brian Silverman | e5db0c6 | 2014-03-13 15:53:18 -0700 | [diff] [blame] | 29 | const uint16_t kCompTeamNumber = 971; |
Brian Silverman | a20703b | 2014-03-20 14:29:37 -0700 | [diff] [blame] | 30 | const uint16_t kPracticeTeamNumber = 9971; |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 31 | |
| 32 | // ///// Drivetrain Constants |
Brian Silverman | e5db0c6 | 2014-03-13 15:53:18 -0700 | [diff] [blame] | 33 | |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 34 | // These three constants were set by Daniel on 2/13/15. |
| 35 | const double kDrivetrainEncoderRatio = 20.0 / 64.0; |
| 36 | const double kLowGearRatio = kDrivetrainEncoderRatio * 20.0 / 50.0; |
| 37 | const double kHighGearRatio = kLowGearRatio; |
Brian Silverman | 1a6590d | 2013-11-04 14:46:46 -0800 | [diff] [blame] | 38 | |
Brian Silverman | e5db0c6 | 2014-03-13 15:53:18 -0700 | [diff] [blame] | 39 | const ShifterHallEffect kCompRightDriveShifter{555, 657, 660, 560, 0.2, 0.7}; |
| 40 | const ShifterHallEffect kCompLeftDriveShifter{555, 660, 644, 552, 0.2, 0.7}; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 41 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 42 | const ShifterHallEffect kPracticeRightDriveShifter{2.95, 3.95, 3.95, |
| 43 | 2.95, 0.2, 0.7}; |
| 44 | const ShifterHallEffect kPracticeLeftDriveShifter{2.95, 4.2, 3.95, |
| 45 | 3.0, 0.2, 0.7}; |
Brian Silverman | e5db0c6 | 2014-03-13 15:53:18 -0700 | [diff] [blame] | 46 | |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 47 | // Set by Daniel on 2/13/15. |
| 48 | // Distance from the center of the left wheel to the center of the right wheel. |
| 49 | const double kRobotWidth = 37.806 /*inches*/ * 0.0254; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 50 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 51 | // ///// Superstructure Constants |
| 52 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 53 | // Elevator gearbox pulley output constants. |
| 54 | const int kElevatorGearboxOutputPulleyTeeth = 32; // 32 teeth |
| 55 | const double kElevatorGearboxOutputPitch = 0.005; // 5 mm/tooth |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 56 | const double kElevatorGearboxOutputRadianDistance = |
| 57 | kElevatorGearboxOutputPulleyTeeth * kElevatorGearboxOutputPitch / |
| 58 | (2.0 * M_PI); |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 59 | |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 60 | const double kArmZeroingHeight = 0.2; |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 61 | const double kElevatorNormalHeight = 0.1; |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 62 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 63 | const double kMaxAllowedLeftRightArmDifference = 0.04; // radians |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 64 | const double kMaxAllowedLeftRightElevatorDifference = 0.01; // meters |
| 65 | |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 66 | // Gearing ratios of the pots and encoders for the elevator and arm. |
| 67 | // Ratio is output shaft rotations per encoder/pot rotation |
| 68 | // Checked by Daniel on 2/13/15. |
| 69 | const double kArmEncoderRatio = 18.0 / 48.0 * 16.0 / 72.0; |
| 70 | const double kArmPotRatio = 48.0 / 48.0 * 16.0 / 72.0; |
| 71 | const double kElevatorEncoderRatio = 14.0 / 84.0; |
| 72 | const double kElevatorPotRatio = 1.0; |
| 73 | const double kClawEncoderRatio = 18.0 / 72.0; |
| 74 | const double kClawPotRatio = 18.0 / 72.0; |
| 75 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 76 | // Number of radians between each index pulse on the arm. |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 77 | const double kArmEncoderIndexDifference = 2.0 * M_PI * kArmEncoderRatio; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 78 | // Number of meters between each index pulse on the elevator. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 79 | const double kElevatorEncoderIndexDifference = |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 80 | kElevatorEncoderRatio * 2.0 * M_PI * // radians |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 81 | kElevatorGearboxOutputRadianDistance; |
| 82 | // Number of radians between index pulses on the claw. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 83 | const double kClawEncoderIndexDifference = 2.0 * M_PI * kClawEncoderRatio; |
| 84 | |
| 85 | const int kZeroingSampleSize = 20; |
Brian Silverman | edcfd2d | 2014-04-03 13:04:16 -0700 | [diff] [blame] | 86 | |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 87 | // TODO(danielp): All these values might need to change. |
| 88 | const double kClawPistonSwitchTime = 0.4; |
| 89 | const double kClawZeroingRange = 0.3; |
| 90 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 91 | const Values *DoGetValuesForTeam(uint16_t team) { |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 92 | switch (team) { |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 93 | case 1: // for tests |
| 94 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 95 | kDrivetrainEncoderRatio, |
| 96 | kArmEncoderRatio, |
| 97 | kArmPotRatio, |
| 98 | kElevatorEncoderRatio, |
| 99 | kElevatorPotRatio, |
| 100 | kElevatorGearboxOutputRadianDistance, |
| 101 | kClawEncoderRatio, |
| 102 | kClawPotRatio, |
| 103 | kLowGearRatio, |
| 104 | kHighGearRatio, |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 105 | kCompLeftDriveShifter, |
| 106 | kCompRightDriveShifter, |
Austin Schuh | 1172621 | 2014-03-02 14:01:02 -0800 | [diff] [blame] | 107 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 108 | 0.5, |
Austin Schuh | a25a041 | 2014-03-09 00:50:04 -0800 | [diff] [blame] | 109 | control_loops::MakeVelocityDrivetrainLoop, |
| 110 | control_loops::MakeDrivetrainLoop, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 111 | 0.02, // drivetrain done delta |
| 112 | 5.0, // drivetrain max speed |
| 113 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 114 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 115 | // soft_lower_limit, soft_upper_limit |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 116 | {// Claw values, in radians. |
| 117 | // 0 is level with the ground. |
| 118 | // Positive moves in the direction of positive encoder values. |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 119 | {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 120 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 121 | // Zeroing constants for wrist. |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 122 | {kZeroingSampleSize, kClawEncoderIndexDifference, |
| 123 | 0.9}, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 124 | |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 125 | 6.308141, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 126 | kClawPistonSwitchTime, |
| 127 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 128 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 129 | {// Elevator values, in meters. |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 130 | // 0 is the portion of the elevator carriage that Spencer removed |
| 131 | // lining up with the bolt. |
| 132 | // Positive is up. |
| 133 | {-0.005, 0.679000, 0.010000, 0.650000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 134 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 135 | // Arm values, in radians. |
| 136 | // 0 is sticking straight out horizontally over the intake/front. |
| 137 | // Positive is rotating up and into the robot (towards the back). |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 138 | {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 139 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 140 | // Elevator zeroing constants: left, right. |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 141 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0}, |
| 142 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0}, |
| 143 | // Arm zeroing constants: left, right. |
| 144 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0}, |
| 145 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0}, |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame^] | 146 | 0.7, |
| 147 | -0.08, |
| 148 | -3.5 - 0.01 - -0.02, |
| 149 | 3.5 - 0.17 - -0.15, |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 150 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 151 | kArmZeroingHeight, |
| 152 | kElevatorNormalHeight, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 153 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 154 | // End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 155 | |
| 156 | kMaxAllowedLeftRightArmDifference, |
| 157 | kMaxAllowedLeftRightElevatorDifference, |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 158 | }; |
| 159 | break; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 160 | case kCompTeamNumber: |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 161 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 162 | kDrivetrainEncoderRatio, |
| 163 | kArmEncoderRatio, |
| 164 | kArmPotRatio, |
| 165 | kElevatorEncoderRatio, |
| 166 | kElevatorPotRatio, |
| 167 | kElevatorGearboxOutputRadianDistance, |
| 168 | kClawEncoderRatio, |
| 169 | kClawPotRatio, |
| 170 | kLowGearRatio, |
| 171 | kHighGearRatio, |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 172 | kCompLeftDriveShifter, |
| 173 | kCompRightDriveShifter, |
Brian Silverman | edcfd2d | 2014-04-03 13:04:16 -0700 | [diff] [blame] | 174 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 175 | kRobotWidth, |
Austin Schuh | a25a041 | 2014-03-09 00:50:04 -0800 | [diff] [blame] | 176 | control_loops::MakeVelocityDrivetrainLoop, |
| 177 | control_loops::MakeDrivetrainLoop, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 178 | 0.02, // drivetrain done delta |
| 179 | 5.0, // drivetrain max speed |
| 180 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 181 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 182 | // soft_lower_limit, soft_upper_limit |
| 183 | // TODO(sensors): Get actual bounds before turning on robot. |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 184 | {// Claw values, in radians. |
| 185 | // 0 is level with the ground. |
| 186 | // Positive moves in the direction of positive encoder values. |
| 187 | {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 188 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 189 | // Zeroing constants for wrist. |
| 190 | {kZeroingSampleSize, kClawEncoderIndexDifference, |
| 191 | 0.9104180000000001}, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 192 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 193 | 6.308141, |
| 194 | kClawPistonSwitchTime, |
| 195 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 196 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 197 | {// Elevator values, in meters. |
| 198 | // 0 is the portion of the elevator carriage that Spencer removed |
| 199 | // lining up with the bolt. |
| 200 | // Positive is up. |
| 201 | {-0.00500, 0.679000, 0.010000, 0.650000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 202 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 203 | // Arm values, in radians. |
| 204 | // 0 is sticking straight out horizontally over the intake/front. |
| 205 | // Positive is rotating up and into the robot (towards the back). |
| 206 | {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 207 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 208 | // Elevator zeroing constants: left, right. |
| 209 | // TODO(sensors): Get actual offsets for these. |
| 210 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.058672}, |
| 211 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.078646}, |
| 212 | // Arm zeroing constants: left, right. |
| 213 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.324437}, |
| 214 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.064683}, |
| 215 | 0.722230, |
| 216 | -0.081354, |
| 217 | -3.509611 - 0.007415 - -0.019081, |
| 218 | 3.506927 - 0.170017 - -0.147970, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 219 | |
| 220 | kArmZeroingHeight, |
| 221 | kElevatorNormalHeight, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 222 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 223 | // End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 224 | |
| 225 | kMaxAllowedLeftRightArmDifference, |
| 226 | kMaxAllowedLeftRightElevatorDifference, |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 227 | }; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 228 | break; |
| 229 | case kPracticeTeamNumber: |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 230 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 231 | kDrivetrainEncoderRatio, |
| 232 | kArmEncoderRatio, |
| 233 | kArmPotRatio, |
| 234 | kElevatorEncoderRatio, |
| 235 | kElevatorPotRatio, |
| 236 | kElevatorGearboxOutputRadianDistance, |
| 237 | kClawEncoderRatio, |
| 238 | kClawPotRatio, |
| 239 | kLowGearRatio, |
| 240 | kHighGearRatio, |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 241 | kPracticeLeftDriveShifter, |
| 242 | kPracticeRightDriveShifter, |
| 243 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 244 | kRobotWidth, |
Austin Schuh | a25a041 | 2014-03-09 00:50:04 -0800 | [diff] [blame] | 245 | control_loops::MakeVelocityDrivetrainLoop, |
| 246 | control_loops::MakeDrivetrainLoop, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 247 | 0.02, // drivetrain done delta |
| 248 | 5.0, // drivetrain max speed |
| 249 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 250 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 251 | // soft_lower_limit, soft_upper_limit |
| 252 | // TODO(sensors): Get actual bounds before turning on robot. |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 253 | {// Claw values, in radians. |
| 254 | // 0 is level with the ground. |
| 255 | // Positive moves in the direction of positive encoder values. |
| 256 | {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 257 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 258 | // Zeroing constants for wrist. |
| 259 | // TODO(sensors): Get actual offsets for these. |
Austin Schuh | 8a436e8 | 2015-02-16 23:31:28 -0800 | [diff] [blame] | 260 | {kZeroingSampleSize, kClawEncoderIndexDifference, 0.973311}, |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 261 | 6.1663463999999992, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 262 | |
| 263 | kClawPistonSwitchTime, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 264 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 265 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 266 | {// Elevator values, in meters. |
| 267 | // 0 is at the top of the elevator frame. |
| 268 | // Positive is down towards the drivebase. |
| 269 | {-0.00500, 0.679000, 0.010000, 0.650000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 270 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 271 | // Arm values, in radians. |
| 272 | // 0 is sticking straight out horizontally over the intake/front. |
| 273 | // Positive is rotating up and into the robot (towards the back). |
| 274 | {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2}, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 275 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 276 | // Elevator zeroing constants: left, right. |
| 277 | // TODO(sensors): Get actual offsets for these. |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 278 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, |
| 279 | 0.016041 + 0.001290}, |
| 280 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, |
| 281 | 0.011367 + 0.003216}, |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 282 | // Arm zeroing constants: left, right. |
| 283 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.312677}, |
| 284 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.40855}, |
| 285 | 0.72069366666666679 - 0.026008, |
| 286 | -0.078959636363636357 - 0.024646, |
| 287 | -3.4952331578947375 + 0.011776, |
| 288 | 3.5263507647058816 - 0.018921 + 0.006545, |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 289 | |
| 290 | kArmZeroingHeight, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 291 | kElevatorNormalHeight, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 292 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 293 | // TODO(sensors): End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 294 | |
| 295 | kMaxAllowedLeftRightArmDifference, |
| 296 | kMaxAllowedLeftRightElevatorDifference, |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 297 | }; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 298 | break; |
| 299 | default: |
| 300 | LOG(FATAL, "unknown team #%" PRIu16 "\n", team); |
| 301 | } |
| 302 | } |
| 303 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 304 | const Values *DoGetValues() { |
| 305 | uint16_t team = ::aos::network::GetTeamNumber(); |
| 306 | LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team); |
| 307 | return DoGetValuesForTeam(team); |
| 308 | } |
| 309 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 310 | } // namespace |
| 311 | |
| 312 | const Values &GetValues() { |
| 313 | static ::aos::Once<const Values> once(DoGetValues); |
| 314 | return *once.Get(); |
| 315 | } |
| 316 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 317 | const Values &GetValuesForTeam(uint16_t team_number) { |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 318 | static ::aos::Mutex mutex; |
| 319 | ::aos::MutexLocker locker(&mutex); |
| 320 | |
| 321 | // IMPORTANT: This declaration has to stay after the mutex is locked to avoid |
| 322 | // race conditions. |
| 323 | static ::std::map<uint16_t, const Values *> values; |
| 324 | |
| 325 | if (values.count(team_number) == 0) { |
| 326 | values[team_number] = DoGetValuesForTeam(team_number); |
| 327 | #if __has_feature(address_sanitizer) |
| 328 | __lsan_ignore_object(values[team_number]); |
| 329 | #endif |
| 330 | } |
| 331 | return *values[team_number]; |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 334 | } // namespace constants |
| 335 | } // namespace frc971 |