blob: 5b02a25c81bd4680362af1b2b85d8e178cb03875 [file] [log] [blame]
Brian Silvermanb691f5e2015-08-02 11:37:55 -07001#include "y2015/constants.h"
Brian Silverman431500a2013-10-28 19:50:15 -07002
3#include <math.h>
4#include <stdint.h>
5#include <inttypes.h>
6
Brian Silverman0a151c92014-05-02 15:28:44 -07007#include <map>
8
9#if __has_feature(address_sanitizer)
10#include "sanitizer/lsan_interface.h"
11#endif
12
Brian Silverman431500a2013-10-28 19:50:15 -070013#include "aos/common/logging/logging.h"
14#include "aos/common/once.h"
15#include "aos/common/network/team_number.h"
Brian Silverman0a151c92014-05-02 15:28:44 -070016#include "aos/common/mutex.h"
Brian Silverman431500a2013-10-28 19:50:15 -070017
Brian Silvermanb691f5e2015-08-02 11:37:55 -070018#include "y2015/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
19#include "y2015/control_loops/drivetrain/drivetrain_dog_motor_plant.h"
Brian Silverman2c590c32013-11-04 18:08:54 -080020
Brian Silverman431500a2013-10-28 19:50:15 -070021#ifndef M_PI
22#define M_PI 3.14159265358979323846
23#endif
24
Austin Schuh88af0852016-12-04 20:31:32 -080025namespace y2015 {
Brian Silverman431500a2013-10-28 19:50:15 -070026namespace constants {
27namespace {
28
Brian Silvermane5db0c62014-03-13 15:53:18 -070029const uint16_t kCompTeamNumber = 971;
Brian Silvermana20703b2014-03-20 14:29:37 -070030const uint16_t kPracticeTeamNumber = 9971;
Comran Morshed79bd3db2015-02-07 14:51:13 +000031
32// ///// Drivetrain Constants
Brian Silvermane5db0c62014-03-13 15:53:18 -070033
Daniel Pettia7827412015-02-13 20:55:57 -080034// These three constants were set by Daniel on 2/13/15.
Austin Schuh58baa352015-02-20 22:08:26 -080035const double kDrivetrainEncoderRatio = 20.0 / 50.0;
Daniel Pettia7827412015-02-13 20:55:57 -080036const double kLowGearRatio = kDrivetrainEncoderRatio * 20.0 / 50.0;
37const double kHighGearRatio = kLowGearRatio;
Brian Silverman1a6590d2013-11-04 14:46:46 -080038
Austin Schuh88af0852016-12-04 20:31:32 -080039const ::frc971::constants::ShifterHallEffect kCompRightDriveShifter{
40 555, 657, 660, 560, 0.2, 0.7};
41const ::frc971::constants::ShifterHallEffect kCompLeftDriveShifter{
42 555, 660, 644, 552, 0.2, 0.7};
Brian Silverman6eb51f12013-11-02 14:39:01 -070043
Austin Schuh88af0852016-12-04 20:31:32 -080044const ::frc971::constants::ShifterHallEffect kPracticeRightDriveShifter{
45 2.95, 3.95, 3.95, 2.95, 0.2, 0.7};
46const ::frc971::constants::ShifterHallEffect kPracticeLeftDriveShifter{
47 2.95, 4.2, 3.95, 3.0, 0.2, 0.7};
Austin Schuhd8b2a242015-02-22 21:46:53 -080048const double kToteHeight = 0.3;
Brian Silvermane5db0c62014-03-13 15:53:18 -070049
Daniel Pettia7827412015-02-13 20:55:57 -080050// Set by Daniel on 2/13/15.
51// Distance from the center of the left wheel to the center of the right wheel.
52const double kRobotWidth = 37.806 /*inches*/ * 0.0254;
Brian Silverman6eb51f12013-11-02 14:39:01 -070053
Comran Morshed79bd3db2015-02-07 14:51:13 +000054// ///// Superstructure Constants
55
Comran Morshed79bd3db2015-02-07 14:51:13 +000056// Elevator gearbox pulley output constants.
57const int kElevatorGearboxOutputPulleyTeeth = 32; // 32 teeth
58const double kElevatorGearboxOutputPitch = 0.005; // 5 mm/tooth
Daniel Pettia7827412015-02-13 20:55:57 -080059const double kElevatorGearboxOutputRadianDistance =
60 kElevatorGearboxOutputPulleyTeeth * kElevatorGearboxOutputPitch /
61 (2.0 * M_PI);
Comran Morshed79bd3db2015-02-07 14:51:13 +000062
Daniel Pettie1bb13e2015-02-17 13:59:15 -080063const double kArmZeroingHeight = 0.2;
64
Brian Silverman10b8f4c2015-03-21 23:44:46 -070065const double kMaxAllowedLeftRightArmDifference = 0.12; // radians
66const double kMaxAllowedLeftRightElevatorDifference = 0.04; // meters
Austin Schuh703b8d42015-02-01 14:56:34 -080067
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -080068const 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 Pettia7827412015-02-13 20:55:57 -0800105// 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.
108const double kArmEncoderRatio = 18.0 / 48.0 * 16.0 / 72.0;
109const double kArmPotRatio = 48.0 / 48.0 * 16.0 / 72.0;
110const double kElevatorEncoderRatio = 14.0 / 84.0;
111const double kElevatorPotRatio = 1.0;
112const double kClawEncoderRatio = 18.0 / 72.0;
113const double kClawPotRatio = 18.0 / 72.0;
114
Comran Morshed79bd3db2015-02-07 14:51:13 +0000115// Number of radians between each index pulse on the arm.
Daniel Pettiee4fa802015-02-17 10:39:27 -0800116const double kArmEncoderIndexDifference = 2.0 * M_PI * kArmEncoderRatio;
Daniel Pettia7827412015-02-13 20:55:57 -0800117// Number of meters between each index pulse on the elevator.
Comran Morshed79bd3db2015-02-07 14:51:13 +0000118const double kElevatorEncoderIndexDifference =
Daniel Pettiee4fa802015-02-17 10:39:27 -0800119 kElevatorEncoderRatio * 2.0 * M_PI * // radians
Daniel Pettia7827412015-02-13 20:55:57 -0800120 kElevatorGearboxOutputRadianDistance;
121// Number of radians between index pulses on the claw.
Comran Morshed79bd3db2015-02-07 14:51:13 +0000122const double kClawEncoderIndexDifference = 2.0 * M_PI * kClawEncoderRatio;
123
Austin Schuh44cd5802015-03-01 00:06:09 -0800124const int kZeroingSampleSize = 200;
Brian Silvermanedcfd2d2014-04-03 13:04:16 -0700125
Philipp Schrader085bf012015-03-15 01:43:11 +0000126// The length of the arm.
127const double kArmLength = 0.7366;
128
Daniel Petti9cf68c82015-02-14 14:57:17 -0800129// TODO(danielp): All these values might need to change.
Austin Schuhf2a50ba2016-12-24 16:16:26 -0800130constexpr ::aos::monotonic_clock::duration kClawPistonSwitchTime =
131 ::std::chrono::milliseconds(400);
Daniel Petti9cf68c82015-02-14 14:57:17 -0800132const double kClawZeroingRange = 0.3;
133
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000134const Values *DoGetValuesForTeam(uint16_t team) {
Brian Silverman431500a2013-10-28 19:50:15 -0700135 switch (team) {
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800136 case 1: // for tests
137 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800138 kDrivetrainEncoderRatio,
139 kArmEncoderRatio,
140 kArmPotRatio,
141 kElevatorEncoderRatio,
142 kElevatorPotRatio,
143 kElevatorGearboxOutputRadianDistance,
144 kClawEncoderRatio,
145 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800146 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800147 kLowGearRatio,
148 kHighGearRatio,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800149 kCompLeftDriveShifter,
150 kCompRightDriveShifter,
Austin Schuh11726212014-03-02 14:01:02 -0800151 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700152 0.5,
Austin Schuh70810b92016-11-26 14:55:34 -0800153 ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop,
154 ::y2015::control_loops::drivetrain::MakeDrivetrainLoop,
Comran Morshed79bd3db2015-02-07 14:51:13 +0000155 5.0, // drivetrain max speed
156
Comran Morshed79bd3db2015-02-07 14:51:13 +0000157 // Motion ranges: hard_lower_limit, hard_upper_limit,
158 // soft_lower_limit, soft_upper_limit
Daniel Pettiee4fa802015-02-17 10:39:27 -0800159 {// Claw values, in radians.
160 // 0 is level with the ground.
161 // Positive moves in the direction of positive encoder values.
Brian Silverman24e37ad2015-02-18 01:58:08 -0500162 {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0},
Daniel Pettia7827412015-02-13 20:55:57 -0800163
Daniel Pettiee4fa802015-02-17 10:39:27 -0800164 // Zeroing constants for wrist.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000165 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9, 0.3},
Daniel Petti9cf68c82015-02-14 14:57:17 -0800166
Brian Silverman24e37ad2015-02-18 01:58:08 -0500167 6.308141,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800168 kClawPistonSwitchTime,
169 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000170
Daniel Pettiee4fa802015-02-17 10:39:27 -0800171 {// Elevator values, in meters.
Brian Silverman24e37ad2015-02-18 01:58:08 -0500172 // 0 is the portion of the elevator carriage that Spencer removed
173 // lining up with the bolt.
174 // Positive is up.
Austin Schuh813b9af2015-03-08 18:46:58 -0700175 {-0.005, 0.689000, 0.010000, 0.680000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000176
Daniel Pettiee4fa802015-02-17 10:39:27 -0800177 // 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 Silverman24e37ad2015-02-18 01:58:08 -0500180 {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2},
Daniel Pettia7827412015-02-13 20:55:57 -0800181
Daniel Pettiee4fa802015-02-17 10:39:27 -0800182 // Elevator zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000183 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3},
184 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3},
Daniel Pettiee4fa802015-02-17 10:39:27 -0800185 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000186 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3},
187 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3},
Brian Silverman24e37ad2015-02-18 01:58:08 -0500188 0.7,
189 -0.08,
190 -3.5 - 0.01 - -0.02,
191 3.5 - 0.17 - -0.15,
Daniel Pettie1bb13e2015-02-17 13:59:15 -0800192
Daniel Pettiee4fa802015-02-17 10:39:27 -0800193 kArmZeroingHeight,
Philipp Schrader085bf012015-03-15 01:43:11 +0000194 kArmLength,
Austin Schuh703b8d42015-02-01 14:56:34 -0800195 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000196 // End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800197
198 kMaxAllowedLeftRightArmDifference,
199 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800200 kClawGeometry,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800201 };
202 break;
Austin Schuh58baa352015-02-20 22:08:26 -0800203 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -0800204 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800205 kDrivetrainEncoderRatio,
206 kArmEncoderRatio,
207 kArmPotRatio,
208 kElevatorEncoderRatio,
209 kElevatorPotRatio,
210 kElevatorGearboxOutputRadianDistance,
211 kClawEncoderRatio,
212 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800213 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800214 kLowGearRatio,
215 kHighGearRatio,
Austin Schuh288c8c32014-02-16 17:20:17 -0800216 kCompLeftDriveShifter,
217 kCompRightDriveShifter,
Brian Silvermanedcfd2d2014-04-03 13:04:16 -0700218 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700219 kRobotWidth,
Austin Schuh70810b92016-11-26 14:55:34 -0800220 ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop,
221 ::y2015::control_loops::drivetrain::MakeDrivetrainLoop,
Comran Morshed79bd3db2015-02-07 14:51:13 +0000222 5.0, // drivetrain max speed
223
Comran Morshed79bd3db2015-02-07 14:51:13 +0000224 // 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 Schuh0b406bb2015-02-17 02:28:48 -0800227 {// 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 Pettia7827412015-02-13 20:55:57 -0800231
Austin Schuh0b406bb2015-02-17 02:28:48 -0800232 // Zeroing constants for wrist.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000233 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9104180000000001,
234 0.3},
Daniel Petti9cf68c82015-02-14 14:57:17 -0800235
Austin Schuh0b406bb2015-02-17 02:28:48 -0800236 6.308141,
237 kClawPistonSwitchTime,
238 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000239
Austin Schuh0b406bb2015-02-17 02:28:48 -0800240 {// 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 Schuh813b9af2015-03-08 18:46:58 -0700244 {-0.00500, 0.689000, 0.010000, 0.680000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000245
Austin Schuh0b406bb2015-02-17 02:28:48 -0800246 // 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 Pettia7827412015-02-13 20:55:57 -0800250
Austin Schuh0b406bb2015-02-17 02:28:48 -0800251 // Elevator zeroing constants: left, right.
Michael Schuh2fe80a82015-03-28 14:22:34 -0700252 {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 Schuh0b406bb2015-02-17 02:28:48 -0800254 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000255 {kZeroingSampleSize, kArmEncoderIndexDifference, -0.324437, 0.3},
256 {kZeroingSampleSize, kArmEncoderIndexDifference, -0.064683, 0.3},
Michael Schuh2fe80a82015-03-28 14:22:34 -0700257 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 Schuh0b406bb2015-02-17 02:28:48 -0800259 -3.509611 - 0.007415 - -0.019081,
260 3.506927 - 0.170017 - -0.147970,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800261
262 kArmZeroingHeight,
Philipp Schrader085bf012015-03-15 01:43:11 +0000263 kArmLength,
Austin Schuh703b8d42015-02-01 14:56:34 -0800264 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000265 // End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800266
267 kMaxAllowedLeftRightArmDifference,
268 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800269 kClawGeometry,
Brian Silverman756f9ff2014-01-17 23:40:23 -0800270 };
Brian Silverman431500a2013-10-28 19:50:15 -0700271 break;
Austin Schuh58baa352015-02-20 22:08:26 -0800272 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -0800273 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800274 kDrivetrainEncoderRatio,
275 kArmEncoderRatio,
276 kArmPotRatio,
277 kElevatorEncoderRatio,
278 kElevatorPotRatio,
279 kElevatorGearboxOutputRadianDistance,
280 kClawEncoderRatio,
281 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800282 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800283 kLowGearRatio,
284 kHighGearRatio,
Austin Schuh288c8c32014-02-16 17:20:17 -0800285 kPracticeLeftDriveShifter,
286 kPracticeRightDriveShifter,
287 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700288 kRobotWidth,
Austin Schuh70810b92016-11-26 14:55:34 -0800289 ::y2015::control_loops::drivetrain::MakeVelocityDrivetrainLoop,
290 ::y2015::control_loops::drivetrain::MakeDrivetrainLoop,
291 5.0, // drivetrain max speed
Comran Morshed79bd3db2015-02-07 14:51:13 +0000292
Comran Morshed79bd3db2015-02-07 14:51:13 +0000293 // 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 Schuhbfb8b242015-02-16 15:45:22 -0800296 {// 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 Pettia7827412015-02-13 20:55:57 -0800300
Austin Schuhbfb8b242015-02-16 15:45:22 -0800301 // Zeroing constants for wrist.
302 // TODO(sensors): Get actual offsets for these.
Brian Silverman50fa41c2015-03-19 23:37:50 -0700303 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.952602, 0.3},
304 6.1663463999999992 + 0.015241,
Daniel Petti9cf68c82015-02-14 14:57:17 -0800305
306 kClawPistonSwitchTime,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800307 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000308
Austin Schuh70810b92016-11-26 14:55:34 -0800309 {
310 // Elevator values, in meters.
Austin Schuhbfb8b242015-02-16 15:45:22 -0800311 // 0 is at the top of the elevator frame.
312 // Positive is down towards the drivebase.
Austin Schuh813b9af2015-03-08 18:46:58 -0700313 {-0.00500, 0.689000, 0.010000, 0.680000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000314
Austin Schuhbfb8b242015-02-16 15:45:22 -0800315 // 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 Pettia7827412015-02-13 20:55:57 -0800319
Austin Schuhbfb8b242015-02-16 15:45:22 -0800320 // Elevator zeroing constants: left, right.
Brian Silverman50fa41c2015-03-19 23:37:50 -0700321 // These are the encoder offsets.
Austin Schuhbfb8b242015-02-16 15:45:22 -0800322 // TODO(sensors): Get actual offsets for these.
Daniel Pettiee4fa802015-02-17 10:39:27 -0800323 {kZeroingSampleSize, kElevatorEncoderIndexDifference,
Brian Silverman50fa41c2015-03-19 23:37:50 -0700324 0.240286 - 0.007969 - 0.025, 0.3},
Daniel Pettiee4fa802015-02-17 10:39:27 -0800325 {kZeroingSampleSize, kElevatorEncoderIndexDifference,
Brian Silverman50fa41c2015-03-19 23:37:50 -0700326 0.234583 - 0.000143, 0.3},
Austin Schuhbfb8b242015-02-16 15:45:22 -0800327 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000328 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.060592, 0.3},
329 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.210155, 0.3},
Brian Silverman50fa41c2015-03-19 23:37:50 -0700330 // These are the potentiometer offsets.
331 0.72069366666666679 - 0.026008 - 0.024948 + 0.025,
Austin Schuh70810b92016-11-26 14:55:34 -0800332 -0.078959636363636357 - 0.024646 - 0.020260,
Austin Schuh58baa352015-02-20 22:08:26 -0800333 -3.509611 - 0.007415 - -0.019081 - 0.029393 - -0.013585,
334 3.506927 - 0.170017 - -0.147970 - 0.005045 - -0.026504,
Daniel Pettie1bb13e2015-02-17 13:59:15 -0800335
336 kArmZeroingHeight,
Philipp Schrader085bf012015-03-15 01:43:11 +0000337 kArmLength,
Austin Schuh703b8d42015-02-01 14:56:34 -0800338 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000339 // TODO(sensors): End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800340
341 kMaxAllowedLeftRightArmDifference,
342 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800343 kClawGeometry,
Brian Silverman756f9ff2014-01-17 23:40:23 -0800344 };
Brian Silverman431500a2013-10-28 19:50:15 -0700345 break;
346 default:
347 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
348 }
349}
350
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000351const 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 Silverman431500a2013-10-28 19:50:15 -0700357} // namespace
358
359const Values &GetValues() {
360 static ::aos::Once<const Values> once(DoGetValues);
361 return *once.Get();
362}
363
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000364const Values &GetValuesForTeam(uint16_t team_number) {
Brian Silverman0a151c92014-05-02 15:28:44 -0700365 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 Fredricksona9dcfa42014-02-23 02:05:59 +0000379}
380
Brian Silverman431500a2013-10-28 19:50:15 -0700381} // namespace constants
Austin Schuh88af0852016-12-04 20:31:32 -0800382} // namespace y2015