blob: 04b9576215f392d5259535a6d47eac6932bc8925 [file] [log] [blame]
Brian Silverman431500a2013-10-28 19:50:15 -07001#include "frc971/constants.h"
2
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 Silverman2c590c32013-11-04 18:08:54 -080018#include "frc971/control_loops/drivetrain/polydrivetrain_dog_motor_plant.h"
Brian Silverman2c590c32013-11-04 18:08:54 -080019#include "frc971/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
25namespace frc971 {
26namespace 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
Brian Silvermane5db0c62014-03-13 15:53:18 -070039const ShifterHallEffect kCompRightDriveShifter{555, 657, 660, 560, 0.2, 0.7};
40const ShifterHallEffect kCompLeftDriveShifter{555, 660, 644, 552, 0.2, 0.7};
Brian Silverman6eb51f12013-11-02 14:39:01 -070041
Daniel Pettiee4fa802015-02-17 10:39:27 -080042const ShifterHallEffect kPracticeRightDriveShifter{2.95, 3.95, 3.95,
43 2.95, 0.2, 0.7};
44const ShifterHallEffect kPracticeLeftDriveShifter{2.95, 4.2, 3.95,
45 3.0, 0.2, 0.7};
Austin Schuhd8b2a242015-02-22 21:46:53 -080046const double kToteHeight = 0.3;
Brian Silvermane5db0c62014-03-13 15:53:18 -070047
Daniel Pettia7827412015-02-13 20:55:57 -080048// Set by Daniel on 2/13/15.
49// Distance from the center of the left wheel to the center of the right wheel.
50const double kRobotWidth = 37.806 /*inches*/ * 0.0254;
Brian Silverman6eb51f12013-11-02 14:39:01 -070051
Comran Morshed79bd3db2015-02-07 14:51:13 +000052// ///// Superstructure Constants
53
Comran Morshed79bd3db2015-02-07 14:51:13 +000054// Elevator gearbox pulley output constants.
55const int kElevatorGearboxOutputPulleyTeeth = 32; // 32 teeth
56const double kElevatorGearboxOutputPitch = 0.005; // 5 mm/tooth
Daniel Pettia7827412015-02-13 20:55:57 -080057const double kElevatorGearboxOutputRadianDistance =
58 kElevatorGearboxOutputPulleyTeeth * kElevatorGearboxOutputPitch /
59 (2.0 * M_PI);
Comran Morshed79bd3db2015-02-07 14:51:13 +000060
Daniel Pettie1bb13e2015-02-17 13:59:15 -080061const double kArmZeroingHeight = 0.2;
62
Daniel Pettiee4fa802015-02-17 10:39:27 -080063const double kMaxAllowedLeftRightArmDifference = 0.04; // radians
Austin Schuh703b8d42015-02-01 14:56:34 -080064const double kMaxAllowedLeftRightElevatorDifference = 0.01; // meters
65
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -080066const Values::ClawGeometry kClawGeometry{
67 // Horizontal distance from the center of the grabber to the end.
68 0.5 * 18.0 * 0.0254,
69 // Vertical distance from the arm rotation center to the bottom of
70 // the
71 // grabber. Distance measured with arm vertical (theta = 0).
72 5.1 * 0.0254,
73 // Vertical separation of the claw and arm rotation centers with the
74 // elevator at 0.0 and the arm angle set to zero.
75 10.5 * 0.0254,
76 // Horizontal separation of the claw and arm rotation centers with
77 // the
78 // elevator at 0.0 and the arm angle set to zero.
79 6.5 * 0.0254,
80 // Distance between the center of the claw to the top of the claw.
81 // 2.75 inches would work most of the time. Using 3.5 inches because
82 // of the
83 // pnumatics fitting on the piston.
84 3.5 * 0.0254,
85 // The grabber is safe at any height if it is behind this location.
86 // The location of the grabber is used here and not the location of
87 // the end
88 // of the grabber. The grabber location is (0, 0) when the elevator
89 // is at 0
90 // and the arm angle is 0.
91 (18.0 - 0.3) * 0.0254,
92 // The grabber is safe at any x if it is above this location.
93 // The location of the grabber is used here and not the location of
94 // the end
95 // of the grabber. The grabber location is (0, 0) when the elevator
96 // is at 0
97 // and the arm angle is 0.
98 // The "-5.4" is the location of the bottom of the grabber when
99 // the elevator is at the bottom (-0.3 inches) and arm angle is 0.
100 -8.0 * 0.0254,
101};
102
Daniel Pettia7827412015-02-13 20:55:57 -0800103// Gearing ratios of the pots and encoders for the elevator and arm.
104// Ratio is output shaft rotations per encoder/pot rotation
105// Checked by Daniel on 2/13/15.
106const double kArmEncoderRatio = 18.0 / 48.0 * 16.0 / 72.0;
107const double kArmPotRatio = 48.0 / 48.0 * 16.0 / 72.0;
108const double kElevatorEncoderRatio = 14.0 / 84.0;
109const double kElevatorPotRatio = 1.0;
110const double kClawEncoderRatio = 18.0 / 72.0;
111const double kClawPotRatio = 18.0 / 72.0;
112
Comran Morshed79bd3db2015-02-07 14:51:13 +0000113// Number of radians between each index pulse on the arm.
Daniel Pettiee4fa802015-02-17 10:39:27 -0800114const double kArmEncoderIndexDifference = 2.0 * M_PI * kArmEncoderRatio;
Daniel Pettia7827412015-02-13 20:55:57 -0800115// Number of meters between each index pulse on the elevator.
Comran Morshed79bd3db2015-02-07 14:51:13 +0000116const double kElevatorEncoderIndexDifference =
Daniel Pettiee4fa802015-02-17 10:39:27 -0800117 kElevatorEncoderRatio * 2.0 * M_PI * // radians
Daniel Pettia7827412015-02-13 20:55:57 -0800118 kElevatorGearboxOutputRadianDistance;
119// Number of radians between index pulses on the claw.
Comran Morshed79bd3db2015-02-07 14:51:13 +0000120const double kClawEncoderIndexDifference = 2.0 * M_PI * kClawEncoderRatio;
121
Austin Schuh44cd5802015-03-01 00:06:09 -0800122const int kZeroingSampleSize = 200;
Brian Silvermanedcfd2d2014-04-03 13:04:16 -0700123
Daniel Petti9cf68c82015-02-14 14:57:17 -0800124// TODO(danielp): All these values might need to change.
125const double kClawPistonSwitchTime = 0.4;
126const double kClawZeroingRange = 0.3;
127
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000128const Values *DoGetValuesForTeam(uint16_t team) {
Brian Silverman431500a2013-10-28 19:50:15 -0700129 switch (team) {
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800130 case 1: // for tests
131 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800132 kDrivetrainEncoderRatio,
133 kArmEncoderRatio,
134 kArmPotRatio,
135 kElevatorEncoderRatio,
136 kElevatorPotRatio,
137 kElevatorGearboxOutputRadianDistance,
138 kClawEncoderRatio,
139 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800140 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800141 kLowGearRatio,
142 kHighGearRatio,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800143 kCompLeftDriveShifter,
144 kCompRightDriveShifter,
Austin Schuh11726212014-03-02 14:01:02 -0800145 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700146 0.5,
Austin Schuha25a0412014-03-09 00:50:04 -0800147 control_loops::MakeVelocityDrivetrainLoop,
148 control_loops::MakeDrivetrainLoop,
Comran Morshed79bd3db2015-02-07 14:51:13 +0000149 0.02, // drivetrain done delta
150 5.0, // drivetrain max speed
151
Comran Morshed79bd3db2015-02-07 14:51:13 +0000152 // Motion ranges: hard_lower_limit, hard_upper_limit,
153 // soft_lower_limit, soft_upper_limit
Daniel Pettiee4fa802015-02-17 10:39:27 -0800154 {// Claw values, in radians.
155 // 0 is level with the ground.
156 // Positive moves in the direction of positive encoder values.
Brian Silverman24e37ad2015-02-18 01:58:08 -0500157 {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0},
Daniel Pettia7827412015-02-13 20:55:57 -0800158
Daniel Pettiee4fa802015-02-17 10:39:27 -0800159 // Zeroing constants for wrist.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000160 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9, 0.3},
Daniel Petti9cf68c82015-02-14 14:57:17 -0800161
Brian Silverman24e37ad2015-02-18 01:58:08 -0500162 6.308141,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800163 kClawPistonSwitchTime,
164 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000165
Daniel Pettiee4fa802015-02-17 10:39:27 -0800166 {// Elevator values, in meters.
Brian Silverman24e37ad2015-02-18 01:58:08 -0500167 // 0 is the portion of the elevator carriage that Spencer removed
168 // lining up with the bolt.
169 // Positive is up.
170 {-0.005, 0.679000, 0.010000, 0.650000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000171
Daniel Pettiee4fa802015-02-17 10:39:27 -0800172 // Arm values, in radians.
173 // 0 is sticking straight out horizontally over the intake/front.
174 // Positive is rotating up and into the robot (towards the back).
Brian Silverman24e37ad2015-02-18 01:58:08 -0500175 {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2},
Daniel Pettia7827412015-02-13 20:55:57 -0800176
Daniel Pettiee4fa802015-02-17 10:39:27 -0800177 // Elevator zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000178 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3},
179 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.0, 0.3},
Daniel Pettiee4fa802015-02-17 10:39:27 -0800180 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000181 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3},
182 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.0, 0.3},
Brian Silverman24e37ad2015-02-18 01:58:08 -0500183 0.7,
184 -0.08,
185 -3.5 - 0.01 - -0.02,
186 3.5 - 0.17 - -0.15,
Daniel Pettie1bb13e2015-02-17 13:59:15 -0800187
Daniel Pettiee4fa802015-02-17 10:39:27 -0800188 kArmZeroingHeight,
Austin Schuh703b8d42015-02-01 14:56:34 -0800189 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000190 // End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800191
192 kMaxAllowedLeftRightArmDifference,
193 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800194 kClawGeometry,
Brian Silverman0d2b7cb2014-02-18 20:25:57 -0800195 };
196 break;
Austin Schuh58baa352015-02-20 22:08:26 -0800197 case kPracticeTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -0800198 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800199 kDrivetrainEncoderRatio,
200 kArmEncoderRatio,
201 kArmPotRatio,
202 kElevatorEncoderRatio,
203 kElevatorPotRatio,
204 kElevatorGearboxOutputRadianDistance,
205 kClawEncoderRatio,
206 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800207 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800208 kLowGearRatio,
209 kHighGearRatio,
Austin Schuh288c8c32014-02-16 17:20:17 -0800210 kCompLeftDriveShifter,
211 kCompRightDriveShifter,
Brian Silvermanedcfd2d2014-04-03 13:04:16 -0700212 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700213 kRobotWidth,
Austin Schuha25a0412014-03-09 00:50:04 -0800214 control_loops::MakeVelocityDrivetrainLoop,
215 control_loops::MakeDrivetrainLoop,
Comran Morshed79bd3db2015-02-07 14:51:13 +0000216 0.02, // drivetrain done delta
217 5.0, // drivetrain max speed
218
Comran Morshed79bd3db2015-02-07 14:51:13 +0000219 // Motion ranges: hard_lower_limit, hard_upper_limit,
220 // soft_lower_limit, soft_upper_limit
221 // TODO(sensors): Get actual bounds before turning on robot.
Austin Schuh0b406bb2015-02-17 02:28:48 -0800222 {// Claw values, in radians.
223 // 0 is level with the ground.
224 // Positive moves in the direction of positive encoder values.
225 {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0},
Daniel Pettia7827412015-02-13 20:55:57 -0800226
Austin Schuh0b406bb2015-02-17 02:28:48 -0800227 // Zeroing constants for wrist.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000228 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.9104180000000001,
229 0.3},
Daniel Petti9cf68c82015-02-14 14:57:17 -0800230
Austin Schuh0b406bb2015-02-17 02:28:48 -0800231 6.308141,
232 kClawPistonSwitchTime,
233 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000234
Austin Schuh0b406bb2015-02-17 02:28:48 -0800235 {// Elevator values, in meters.
236 // 0 is the portion of the elevator carriage that Spencer removed
237 // lining up with the bolt.
238 // Positive is up.
239 {-0.00500, 0.679000, 0.010000, 0.650000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000240
Austin Schuh0b406bb2015-02-17 02:28:48 -0800241 // Arm values, in radians.
242 // 0 is sticking straight out horizontally over the intake/front.
243 // Positive is rotating up and into the robot (towards the back).
244 {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2},
Daniel Pettia7827412015-02-13 20:55:57 -0800245
Austin Schuh0b406bb2015-02-17 02:28:48 -0800246 // Elevator zeroing constants: left, right.
Austin Schuh44cd5802015-03-01 00:06:09 -0800247 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.094297, 0.3},
248 {kZeroingSampleSize, kElevatorEncoderIndexDifference, 0.106393, 0.3},
Austin Schuh0b406bb2015-02-17 02:28:48 -0800249 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000250 {kZeroingSampleSize, kArmEncoderIndexDifference, -0.324437, 0.3},
251 {kZeroingSampleSize, kArmEncoderIndexDifference, -0.064683, 0.3},
Austin Schuhd8b2a242015-02-22 21:46:53 -0800252 0.722230 - -0.000594,
253 -0.081354 - -0.000374,
Austin Schuh0b406bb2015-02-17 02:28:48 -0800254 -3.509611 - 0.007415 - -0.019081,
255 3.506927 - 0.170017 - -0.147970,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800256
257 kArmZeroingHeight,
Austin Schuh703b8d42015-02-01 14:56:34 -0800258 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000259 // End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800260
261 kMaxAllowedLeftRightArmDifference,
262 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800263 kClawGeometry,
Brian Silverman756f9ff2014-01-17 23:40:23 -0800264 };
Brian Silverman431500a2013-10-28 19:50:15 -0700265 break;
Austin Schuh58baa352015-02-20 22:08:26 -0800266 case kCompTeamNumber:
Brian Silverman756f9ff2014-01-17 23:40:23 -0800267 return new Values{
Daniel Pettia7827412015-02-13 20:55:57 -0800268 kDrivetrainEncoderRatio,
269 kArmEncoderRatio,
270 kArmPotRatio,
271 kElevatorEncoderRatio,
272 kElevatorPotRatio,
273 kElevatorGearboxOutputRadianDistance,
274 kClawEncoderRatio,
275 kClawPotRatio,
Daniel Pettidfc90ba2015-02-17 21:42:15 -0800276 kToteHeight,
Daniel Pettia7827412015-02-13 20:55:57 -0800277 kLowGearRatio,
278 kHighGearRatio,
Austin Schuh288c8c32014-02-16 17:20:17 -0800279 kPracticeLeftDriveShifter,
280 kPracticeRightDriveShifter,
281 false,
Brian Silvermanad9e0002014-04-13 14:55:57 -0700282 kRobotWidth,
Austin Schuha25a0412014-03-09 00:50:04 -0800283 control_loops::MakeVelocityDrivetrainLoop,
284 control_loops::MakeDrivetrainLoop,
Comran Morshed79bd3db2015-02-07 14:51:13 +0000285 0.02, // drivetrain done delta
286 5.0, // drivetrain max speed
287
Comran Morshed79bd3db2015-02-07 14:51:13 +0000288 // Motion ranges: hard_lower_limit, hard_upper_limit,
289 // soft_lower_limit, soft_upper_limit
290 // TODO(sensors): Get actual bounds before turning on robot.
Austin Schuhbfb8b242015-02-16 15:45:22 -0800291 {// Claw values, in radians.
292 // 0 is level with the ground.
293 // Positive moves in the direction of positive encoder values.
294 {-0.05, M_PI / 2.0 + 0.1, 0.0, M_PI / 2.0},
Daniel Pettia7827412015-02-13 20:55:57 -0800295
Austin Schuhbfb8b242015-02-16 15:45:22 -0800296 // Zeroing constants for wrist.
297 // TODO(sensors): Get actual offsets for these.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000298 {kZeroingSampleSize, kClawEncoderIndexDifference, 0.973311, 0.3},
Austin Schuhbfb8b242015-02-16 15:45:22 -0800299 6.1663463999999992,
Daniel Petti9cf68c82015-02-14 14:57:17 -0800300
301 kClawPistonSwitchTime,
Daniel Pettiee4fa802015-02-17 10:39:27 -0800302 kClawZeroingRange},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000303
Austin Schuhbfb8b242015-02-16 15:45:22 -0800304 {// Elevator values, in meters.
305 // 0 is at the top of the elevator frame.
306 // Positive is down towards the drivebase.
307 {-0.00500, 0.679000, 0.010000, 0.650000},
Comran Morshed79bd3db2015-02-07 14:51:13 +0000308
Austin Schuhbfb8b242015-02-16 15:45:22 -0800309 // Arm values, in radians.
310 // 0 is sticking straight out horizontally over the intake/front.
311 // Positive is rotating up and into the robot (towards the back).
312 {-M_PI / 2 - 0.05, M_PI / 2 + 0.05, -M_PI / 2, M_PI / 2},
Daniel Pettia7827412015-02-13 20:55:57 -0800313
Austin Schuhbfb8b242015-02-16 15:45:22 -0800314 // Elevator zeroing constants: left, right.
315 // TODO(sensors): Get actual offsets for these.
Daniel Pettiee4fa802015-02-17 10:39:27 -0800316 {kZeroingSampleSize, kElevatorEncoderIndexDifference,
Adam Snaider3cd11c52015-02-16 02:16:09 +0000317 0.016041 + 0.001290, 0.3},
Daniel Pettiee4fa802015-02-17 10:39:27 -0800318 {kZeroingSampleSize, kElevatorEncoderIndexDifference,
Adam Snaider3cd11c52015-02-16 02:16:09 +0000319 0.011367 + 0.003216, 0.3},
Austin Schuhbfb8b242015-02-16 15:45:22 -0800320 // Arm zeroing constants: left, right.
Adam Snaider3cd11c52015-02-16 02:16:09 +0000321 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.060592, 0.3},
322 {kZeroingSampleSize, kArmEncoderIndexDifference, 0.210155, 0.3},
Austin Schuhbfb8b242015-02-16 15:45:22 -0800323 0.72069366666666679 - 0.026008,
324 -0.078959636363636357 - 0.024646,
Austin Schuh58baa352015-02-20 22:08:26 -0800325 -3.509611 - 0.007415 - -0.019081 - 0.029393 - -0.013585,
326 3.506927 - 0.170017 - -0.147970 - 0.005045 - -0.026504,
Daniel Pettie1bb13e2015-02-17 13:59:15 -0800327
328 kArmZeroingHeight,
Austin Schuh703b8d42015-02-01 14:56:34 -0800329 },
Comran Morshed79bd3db2015-02-07 14:51:13 +0000330 // TODO(sensors): End "sensor" values.
Austin Schuh703b8d42015-02-01 14:56:34 -0800331
332 kMaxAllowedLeftRightArmDifference,
333 kMaxAllowedLeftRightElevatorDifference,
Benjamin Fredricksona74b0bd2015-03-07 00:32:52 -0800334 kClawGeometry,
Brian Silverman756f9ff2014-01-17 23:40:23 -0800335 };
Brian Silverman431500a2013-10-28 19:50:15 -0700336 break;
337 default:
338 LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
339 }
340}
341
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000342const Values *DoGetValues() {
343 uint16_t team = ::aos::network::GetTeamNumber();
344 LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
345 return DoGetValuesForTeam(team);
346}
347
Brian Silverman431500a2013-10-28 19:50:15 -0700348} // namespace
349
350const Values &GetValues() {
351 static ::aos::Once<const Values> once(DoGetValues);
352 return *once.Get();
353}
354
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000355const Values &GetValuesForTeam(uint16_t team_number) {
Brian Silverman0a151c92014-05-02 15:28:44 -0700356 static ::aos::Mutex mutex;
357 ::aos::MutexLocker locker(&mutex);
358
359 // IMPORTANT: This declaration has to stay after the mutex is locked to avoid
360 // race conditions.
361 static ::std::map<uint16_t, const Values *> values;
362
363 if (values.count(team_number) == 0) {
364 values[team_number] = DoGetValuesForTeam(team_number);
365#if __has_feature(address_sanitizer)
366 __lsan_ignore_object(values[team_number]);
367#endif
368 }
369 return *values[team_number];
Ben Fredricksona9dcfa42014-02-23 02:05:59 +0000370}
371
Brian Silverman431500a2013-10-28 19:50:15 -0700372} // namespace constants
373} // namespace frc971