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