Brian Silverman | b691f5e | 2015-08-02 11:37:55 -0700 | [diff] [blame] | 1 | #include "y2015/constants.h" |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 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 | b691f5e | 2015-08-02 11:37:55 -0700 | [diff] [blame] | 18 | #include "y2015/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h" |
| 19 | #include "y2015/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 | |
Austin Schuh | 88af085 | 2016-12-04 20:31:32 -0800 | [diff] [blame] | 25 | namespace y2015 { |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 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. |
Austin Schuh | 58baa35 | 2015-02-20 22:08:26 -0800 | [diff] [blame] | 35 | const double kDrivetrainEncoderRatio = 20.0 / 50.0; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 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 | |
Austin Schuh | 88af085 | 2016-12-04 20:31:32 -0800 | [diff] [blame] | 39 | const ::frc971::constants::ShifterHallEffect kCompRightDriveShifter{ |
| 40 | 555, 657, 660, 560, 0.2, 0.7}; |
| 41 | const ::frc971::constants::ShifterHallEffect kCompLeftDriveShifter{ |
| 42 | 555, 660, 644, 552, 0.2, 0.7}; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 43 | |
Austin Schuh | 88af085 | 2016-12-04 20:31:32 -0800 | [diff] [blame] | 44 | const ::frc971::constants::ShifterHallEffect kPracticeRightDriveShifter{ |
| 45 | 2.95, 3.95, 3.95, 2.95, 0.2, 0.7}; |
| 46 | const ::frc971::constants::ShifterHallEffect kPracticeLeftDriveShifter{ |
| 47 | 2.95, 4.2, 3.95, 3.0, 0.2, 0.7}; |
Austin Schuh | d8b2a24 | 2015-02-22 21:46:53 -0800 | [diff] [blame] | 48 | const double kToteHeight = 0.3; |
Brian Silverman | e5db0c6 | 2014-03-13 15:53:18 -0700 | [diff] [blame] | 49 | |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 50 | // Set by Daniel on 2/13/15. |
| 51 | // Distance from the center of the left wheel to the center of the right wheel. |
| 52 | const double kRobotWidth = 37.806 /*inches*/ * 0.0254; |
Brian Silverman | 6eb51f1 | 2013-11-02 14:39:01 -0700 | [diff] [blame] | 53 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 54 | // ///// Superstructure Constants |
| 55 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 56 | // Elevator gearbox pulley output constants. |
| 57 | const int kElevatorGearboxOutputPulleyTeeth = 32; // 32 teeth |
| 58 | const double kElevatorGearboxOutputPitch = 0.005; // 5 mm/tooth |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 59 | const double kElevatorGearboxOutputRadianDistance = |
| 60 | kElevatorGearboxOutputPulleyTeeth * kElevatorGearboxOutputPitch / |
| 61 | (2.0 * M_PI); |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 62 | |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 63 | const double kArmZeroingHeight = 0.2; |
| 64 | |
Brian Silverman | 10b8f4c | 2015-03-21 23:44:46 -0700 | [diff] [blame] | 65 | const double kMaxAllowedLeftRightArmDifference = 0.12; // radians |
| 66 | const double kMaxAllowedLeftRightElevatorDifference = 0.04; // meters |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 67 | |
Benjamin Fredrickson | a74b0bd | 2015-03-07 00:32:52 -0800 | [diff] [blame] | 68 | const Values::ClawGeometry kClawGeometry{ |
| 69 | // Horizontal distance from the center of the grabber to the end. |
| 70 | 0.5 * 18.0 * 0.0254, |
| 71 | // Vertical distance from the arm rotation center to the bottom of |
| 72 | // the |
| 73 | // grabber. Distance measured with arm vertical (theta = 0). |
| 74 | 5.1 * 0.0254, |
| 75 | // Vertical separation of the claw and arm rotation centers with the |
| 76 | // elevator at 0.0 and the arm angle set to zero. |
| 77 | 10.5 * 0.0254, |
| 78 | // Horizontal separation of the claw and arm rotation centers with |
| 79 | // the |
| 80 | // elevator at 0.0 and the arm angle set to zero. |
| 81 | 6.5 * 0.0254, |
| 82 | // Distance between the center of the claw to the top of the claw. |
| 83 | // 2.75 inches would work most of the time. Using 3.5 inches because |
| 84 | // of the |
| 85 | // pnumatics fitting on the piston. |
| 86 | 3.5 * 0.0254, |
| 87 | // The grabber is safe at any height if it is behind this location. |
| 88 | // The location of the grabber is used here and not the location of |
| 89 | // the end |
| 90 | // of the grabber. The grabber location is (0, 0) when the elevator |
| 91 | // is at 0 |
| 92 | // and the arm angle is 0. |
| 93 | (18.0 - 0.3) * 0.0254, |
| 94 | // The grabber is safe at any x if it is above this location. |
| 95 | // The location of the grabber is used here and not the location of |
| 96 | // the end |
| 97 | // of the grabber. The grabber location is (0, 0) when the elevator |
| 98 | // is at 0 |
| 99 | // and the arm angle is 0. |
| 100 | // The "-5.4" is the location of the bottom of the grabber when |
| 101 | // the elevator is at the bottom (-0.3 inches) and arm angle is 0. |
| 102 | -8.0 * 0.0254, |
| 103 | }; |
| 104 | |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 105 | // Gearing ratios of the pots and encoders for the elevator and arm. |
| 106 | // Ratio is output shaft rotations per encoder/pot rotation |
| 107 | // Checked by Daniel on 2/13/15. |
| 108 | const double kArmEncoderRatio = 18.0 / 48.0 * 16.0 / 72.0; |
| 109 | const double kArmPotRatio = 48.0 / 48.0 * 16.0 / 72.0; |
| 110 | const double kElevatorEncoderRatio = 14.0 / 84.0; |
| 111 | const double kElevatorPotRatio = 1.0; |
| 112 | const double kClawEncoderRatio = 18.0 / 72.0; |
| 113 | const double kClawPotRatio = 18.0 / 72.0; |
| 114 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 115 | // Number of radians between each index pulse on the arm. |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 116 | const double kArmEncoderIndexDifference = 2.0 * M_PI * kArmEncoderRatio; |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 117 | // Number of meters between each index pulse on the elevator. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 118 | const double kElevatorEncoderIndexDifference = |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 119 | kElevatorEncoderRatio * 2.0 * M_PI * // radians |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 120 | kElevatorGearboxOutputRadianDistance; |
| 121 | // Number of radians between index pulses on the claw. |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 122 | const double kClawEncoderIndexDifference = 2.0 * M_PI * kClawEncoderRatio; |
| 123 | |
Austin Schuh | 44cd580 | 2015-03-01 00:06:09 -0800 | [diff] [blame] | 124 | const int kZeroingSampleSize = 200; |
Brian Silverman | edcfd2d | 2014-04-03 13:04:16 -0700 | [diff] [blame] | 125 | |
Philipp Schrader | 085bf01 | 2015-03-15 01:43:11 +0000 | [diff] [blame] | 126 | // The length of the arm. |
| 127 | const double kArmLength = 0.7366; |
| 128 | |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 129 | // TODO(danielp): All these values might need to change. |
Austin Schuh | f2a50ba | 2016-12-24 16:16:26 -0800 | [diff] [blame] | 130 | constexpr ::aos::monotonic_clock::duration kClawPistonSwitchTime = |
| 131 | ::std::chrono::milliseconds(400); |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 132 | const double kClawZeroingRange = 0.3; |
| 133 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 134 | const Values *DoGetValuesForTeam(uint16_t team) { |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 135 | switch (team) { |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 136 | case 1: // for tests |
| 137 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 138 | kDrivetrainEncoderRatio, |
| 139 | kArmEncoderRatio, |
| 140 | kArmPotRatio, |
| 141 | kElevatorEncoderRatio, |
| 142 | kElevatorPotRatio, |
| 143 | kElevatorGearboxOutputRadianDistance, |
| 144 | kClawEncoderRatio, |
| 145 | kClawPotRatio, |
Daniel Petti | dfc90ba | 2015-02-17 21:42:15 -0800 | [diff] [blame] | 146 | kToteHeight, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 147 | kLowGearRatio, |
| 148 | kHighGearRatio, |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 149 | kCompLeftDriveShifter, |
| 150 | kCompRightDriveShifter, |
Austin Schuh | 1172621 | 2014-03-02 14:01:02 -0800 | [diff] [blame] | 151 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 152 | 0.5, |
Austin Schuh | 70810b9 | 2016-11-26 14:55:34 -0800 | [diff] [blame] | 153 | ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop, |
| 154 | ::y2015::control_loops::drivetrain::MakeDrivetrainLoop, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 155 | 5.0, // drivetrain max speed |
| 156 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 157 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 158 | // soft_lower_limit, soft_upper_limit |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 159 | {// Claw values, in radians. |
| 160 | // 0 is level with the ground. |
| 161 | // Positive moves in the direction of positive encoder values. |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame] | 162 | {-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] | 163 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 164 | // Zeroing constants for wrist. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 165 | {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9, 0.3}, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 166 | |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame] | 167 | 6.308141, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 168 | kClawPistonSwitchTime, |
| 169 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 170 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 171 | {// Elevator values, in meters. |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame] | 172 | // 0 is the portion of the elevator carriage that Spencer removed |
| 173 | // lining up with the bolt. |
| 174 | // Positive is up. |
Austin Schuh | 813b9af | 2015-03-08 18:46:58 -0700 | [diff] [blame] | 175 | {-0.005, 0.689000, 0.010000, 0.680000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 176 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 177 | // Arm values, in radians. |
| 178 | // 0 is sticking straight out horizontally over the intake/front. |
| 179 | // Positive is rotating up and into the robot (towards the back). |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame] | 180 | {-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] | 181 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 182 | // Elevator zeroing constants: left, right. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 183 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3}, |
| 184 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3}, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 185 | // Arm zeroing constants: left, right. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 186 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3}, |
| 187 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3}, |
Brian Silverman | 24e37ad | 2015-02-18 01:58:08 -0500 | [diff] [blame] | 188 | 0.7, |
| 189 | -0.08, |
| 190 | -3.5 - 0.01 - -0.02, |
| 191 | 3.5 - 0.17 - -0.15, |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 192 | |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 193 | kArmZeroingHeight, |
Philipp Schrader | 085bf01 | 2015-03-15 01:43:11 +0000 | [diff] [blame] | 194 | kArmLength, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 195 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 196 | // End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 197 | |
| 198 | kMaxAllowedLeftRightArmDifference, |
| 199 | kMaxAllowedLeftRightElevatorDifference, |
Benjamin Fredrickson | a74b0bd | 2015-03-07 00:32:52 -0800 | [diff] [blame] | 200 | kClawGeometry, |
Brian Silverman | 0d2b7cb | 2014-02-18 20:25:57 -0800 | [diff] [blame] | 201 | }; |
| 202 | break; |
Austin Schuh | 58baa35 | 2015-02-20 22:08:26 -0800 | [diff] [blame] | 203 | case kPracticeTeamNumber: |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 204 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 205 | kDrivetrainEncoderRatio, |
| 206 | kArmEncoderRatio, |
| 207 | kArmPotRatio, |
| 208 | kElevatorEncoderRatio, |
| 209 | kElevatorPotRatio, |
| 210 | kElevatorGearboxOutputRadianDistance, |
| 211 | kClawEncoderRatio, |
| 212 | kClawPotRatio, |
Daniel Petti | dfc90ba | 2015-02-17 21:42:15 -0800 | [diff] [blame] | 213 | kToteHeight, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 214 | kLowGearRatio, |
| 215 | kHighGearRatio, |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 216 | kCompLeftDriveShifter, |
| 217 | kCompRightDriveShifter, |
Brian Silverman | edcfd2d | 2014-04-03 13:04:16 -0700 | [diff] [blame] | 218 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 219 | kRobotWidth, |
Austin Schuh | 70810b9 | 2016-11-26 14:55:34 -0800 | [diff] [blame] | 220 | ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop, |
| 221 | ::y2015::control_loops::drivetrain::MakeDrivetrainLoop, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 222 | 5.0, // drivetrain max speed |
| 223 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 224 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 225 | // soft_lower_limit, soft_upper_limit |
| 226 | // TODO(sensors): Get actual bounds before turning on robot. |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 227 | {// Claw values, in radians. |
| 228 | // 0 is level with the ground. |
| 229 | // Positive moves in the direction of positive encoder values. |
| 230 | {-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] | 231 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 232 | // Zeroing constants for wrist. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 233 | {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9104180000000001, |
| 234 | 0.3}, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 235 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 236 | 6.308141, |
| 237 | kClawPistonSwitchTime, |
| 238 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 239 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 240 | {// Elevator values, in meters. |
| 241 | // 0 is the portion of the elevator carriage that Spencer removed |
| 242 | // lining up with the bolt. |
| 243 | // Positive is up. |
Austin Schuh | 813b9af | 2015-03-08 18:46:58 -0700 | [diff] [blame] | 244 | {-0.00500, 0.689000, 0.010000, 0.680000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 245 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 246 | // Arm values, in radians. |
| 247 | // 0 is sticking straight out horizontally over the intake/front. |
| 248 | // Positive is rotating up and into the robot (towards the back). |
| 249 | {-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] | 250 | |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 251 | // Elevator zeroing constants: left, right. |
Michael Schuh | 2fe80a8 | 2015-03-28 14:22:34 -0700 | [diff] [blame] | 252 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.110677, 0.3}, // Was 0.088984 (3 mm too high) |
| 253 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.109974, 0.3}, // Was 0.104557 (4 mm too low) |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 254 | // Arm zeroing constants: left, right. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 255 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.324437, 0.3}, |
| 256 | {kZeroingSampleSize, kArmEncoderIndexDifference, -0.064683, 0.3}, |
Michael Schuh | 2fe80a8 | 2015-03-28 14:22:34 -0700 | [diff] [blame] | 257 | 0.722230 - -0.000594 - -0.026183 - 0.003442, // Left Elevator Poteniometer adjustment |
| 258 | -0.081354 - -0.000374 - -0.024793 - -0.006916, // Right Elevator Poteniometer adjustment |
Austin Schuh | 0b406bb | 2015-02-17 02:28:48 -0800 | [diff] [blame] | 259 | -3.509611 - 0.007415 - -0.019081, |
| 260 | 3.506927 - 0.170017 - -0.147970, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 261 | |
| 262 | kArmZeroingHeight, |
Philipp Schrader | 085bf01 | 2015-03-15 01:43:11 +0000 | [diff] [blame] | 263 | kArmLength, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 264 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 265 | // End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 266 | |
| 267 | kMaxAllowedLeftRightArmDifference, |
| 268 | kMaxAllowedLeftRightElevatorDifference, |
Benjamin Fredrickson | a74b0bd | 2015-03-07 00:32:52 -0800 | [diff] [blame] | 269 | kClawGeometry, |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 270 | }; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 271 | break; |
Austin Schuh | 58baa35 | 2015-02-20 22:08:26 -0800 | [diff] [blame] | 272 | case kCompTeamNumber: |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 273 | return new Values{ |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 274 | kDrivetrainEncoderRatio, |
| 275 | kArmEncoderRatio, |
| 276 | kArmPotRatio, |
| 277 | kElevatorEncoderRatio, |
| 278 | kElevatorPotRatio, |
| 279 | kElevatorGearboxOutputRadianDistance, |
| 280 | kClawEncoderRatio, |
| 281 | kClawPotRatio, |
Daniel Petti | dfc90ba | 2015-02-17 21:42:15 -0800 | [diff] [blame] | 282 | kToteHeight, |
Daniel Petti | a782741 | 2015-02-13 20:55:57 -0800 | [diff] [blame] | 283 | kLowGearRatio, |
| 284 | kHighGearRatio, |
Austin Schuh | 288c8c3 | 2014-02-16 17:20:17 -0800 | [diff] [blame] | 285 | kPracticeLeftDriveShifter, |
| 286 | kPracticeRightDriveShifter, |
| 287 | false, |
Brian Silverman | ad9e000 | 2014-04-13 14:55:57 -0700 | [diff] [blame] | 288 | kRobotWidth, |
Austin Schuh | 70810b9 | 2016-11-26 14:55:34 -0800 | [diff] [blame] | 289 | ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop, |
| 290 | ::y2015::control_loops::drivetrain::MakeDrivetrainLoop, |
| 291 | 5.0, // drivetrain max speed |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 292 | |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 293 | // Motion ranges: hard_lower_limit, hard_upper_limit, |
| 294 | // soft_lower_limit, soft_upper_limit |
| 295 | // TODO(sensors): Get actual bounds before turning on robot. |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 296 | {// Claw values, in radians. |
| 297 | // 0 is level with the ground. |
| 298 | // Positive moves in the direction of positive encoder values. |
| 299 | {-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] | 300 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 301 | // Zeroing constants for wrist. |
| 302 | // TODO(sensors): Get actual offsets for these. |
Brian Silverman | 50fa41c | 2015-03-19 23:37:50 -0700 | [diff] [blame] | 303 | {kZeroingSampleSize, kClawEncoderIndexDifference, 0.952602, 0.3}, |
| 304 | 6.1663463999999992 + 0.015241, |
Daniel Petti | 9cf68c8 | 2015-02-14 14:57:17 -0800 | [diff] [blame] | 305 | |
| 306 | kClawPistonSwitchTime, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 307 | kClawZeroingRange}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 308 | |
Austin Schuh | 70810b9 | 2016-11-26 14:55:34 -0800 | [diff] [blame] | 309 | { |
| 310 | // Elevator values, in meters. |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 311 | // 0 is at the top of the elevator frame. |
| 312 | // Positive is down towards the drivebase. |
Austin Schuh | 813b9af | 2015-03-08 18:46:58 -0700 | [diff] [blame] | 313 | {-0.00500, 0.689000, 0.010000, 0.680000}, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 314 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 315 | // Arm values, in radians. |
| 316 | // 0 is sticking straight out horizontally over the intake/front. |
| 317 | // Positive is rotating up and into the robot (towards the back). |
| 318 | {-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] | 319 | |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 320 | // Elevator zeroing constants: left, right. |
Brian Silverman | 50fa41c | 2015-03-19 23:37:50 -0700 | [diff] [blame] | 321 | // These are the encoder offsets. |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 322 | // TODO(sensors): Get actual offsets for these. |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 323 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, |
Brian Silverman | 50fa41c | 2015-03-19 23:37:50 -0700 | [diff] [blame] | 324 | 0.240286 - 0.007969 - 0.025, 0.3}, |
Daniel Petti | ee4fa80 | 2015-02-17 10:39:27 -0800 | [diff] [blame] | 325 | {kZeroingSampleSize, kElevatorEncoderIndexDifference, |
Brian Silverman | 50fa41c | 2015-03-19 23:37:50 -0700 | [diff] [blame] | 326 | 0.234583 - 0.000143, 0.3}, |
Austin Schuh | bfb8b24 | 2015-02-16 15:45:22 -0800 | [diff] [blame] | 327 | // Arm zeroing constants: left, right. |
Adam Snaider | 3cd11c5 | 2015-02-16 02:16:09 +0000 | [diff] [blame] | 328 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.060592, 0.3}, |
| 329 | {kZeroingSampleSize, kArmEncoderIndexDifference, 0.210155, 0.3}, |
Brian Silverman | 50fa41c | 2015-03-19 23:37:50 -0700 | [diff] [blame] | 330 | // These are the potentiometer offsets. |
| 331 | 0.72069366666666679 - 0.026008 - 0.024948 + 0.025, |
Austin Schuh | 70810b9 | 2016-11-26 14:55:34 -0800 | [diff] [blame] | 332 | -0.078959636363636357 - 0.024646 - 0.020260, |
Austin Schuh | 58baa35 | 2015-02-20 22:08:26 -0800 | [diff] [blame] | 333 | -3.509611 - 0.007415 - -0.019081 - 0.029393 - -0.013585, |
| 334 | 3.506927 - 0.170017 - -0.147970 - 0.005045 - -0.026504, |
Daniel Petti | e1bb13e | 2015-02-17 13:59:15 -0800 | [diff] [blame] | 335 | |
| 336 | kArmZeroingHeight, |
Philipp Schrader | 085bf01 | 2015-03-15 01:43:11 +0000 | [diff] [blame] | 337 | kArmLength, |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 338 | }, |
Comran Morshed | 79bd3db | 2015-02-07 14:51:13 +0000 | [diff] [blame] | 339 | // TODO(sensors): End "sensor" values. |
Austin Schuh | 703b8d4 | 2015-02-01 14:56:34 -0800 | [diff] [blame] | 340 | |
| 341 | kMaxAllowedLeftRightArmDifference, |
| 342 | kMaxAllowedLeftRightElevatorDifference, |
Benjamin Fredrickson | a74b0bd | 2015-03-07 00:32:52 -0800 | [diff] [blame] | 343 | kClawGeometry, |
Brian Silverman | 756f9ff | 2014-01-17 23:40:23 -0800 | [diff] [blame] | 344 | }; |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 345 | break; |
| 346 | default: |
| 347 | LOG(FATAL, "unknown team #%" PRIu16 "\n", team); |
| 348 | } |
| 349 | } |
| 350 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 351 | const Values *DoGetValues() { |
| 352 | uint16_t team = ::aos::network::GetTeamNumber(); |
| 353 | LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team); |
| 354 | return DoGetValuesForTeam(team); |
| 355 | } |
| 356 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 357 | } // namespace |
| 358 | |
| 359 | const Values &GetValues() { |
| 360 | static ::aos::Once<const Values> once(DoGetValues); |
| 361 | return *once.Get(); |
| 362 | } |
| 363 | |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 364 | const Values &GetValuesForTeam(uint16_t team_number) { |
Brian Silverman | 0a151c9 | 2014-05-02 15:28:44 -0700 | [diff] [blame] | 365 | static ::aos::Mutex mutex; |
| 366 | ::aos::MutexLocker locker(&mutex); |
| 367 | |
| 368 | // IMPORTANT: This declaration has to stay after the mutex is locked to avoid |
| 369 | // race conditions. |
| 370 | static ::std::map<uint16_t, const Values *> values; |
| 371 | |
| 372 | if (values.count(team_number) == 0) { |
| 373 | values[team_number] = DoGetValuesForTeam(team_number); |
| 374 | #if __has_feature(address_sanitizer) |
| 375 | __lsan_ignore_object(values[team_number]); |
| 376 | #endif |
| 377 | } |
| 378 | return *values[team_number]; |
Ben Fredrickson | a9dcfa4 | 2014-02-23 02:05:59 +0000 | [diff] [blame] | 379 | } |
| 380 | |
Brian Silverman | 431500a | 2013-10-28 19:50:15 -0700 | [diff] [blame] | 381 | } // namespace constants |
Austin Schuh | 88af085 | 2016-12-04 20:31:32 -0800 | [diff] [blame] | 382 | } // namespace y2015 |