Begin y2017 folder.

Change-Id: I527f49ae6b5e070fe138acd7dc7e5fff19d2b2e3
diff --git a/y2017/BUILD b/y2017/BUILD
new file mode 100644
index 0000000..aa423a8
--- /dev/null
+++ b/y2017/BUILD
@@ -0,0 +1,17 @@
+cc_library(
+  name = 'constants',
+  visibility = ['//visibility:public'],
+  srcs = [
+    'constants.cc',
+  ],
+  hdrs = [
+    'constants.h',
+  ],
+  deps = [
+    '//aos/common/logging',
+    '//aos/common:once',
+    '//aos/common/network:team_number',
+    '//aos/common:mutex',
+    '//frc971:constants',
+  ],
+)
diff --git a/y2017/constants.cc b/y2017/constants.cc
new file mode 100644
index 0000000..33deee3
--- /dev/null
+++ b/y2017/constants.cc
@@ -0,0 +1,92 @@
+#include "y2017/constants.h"
+
+#include <math.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#include <map>
+
+#if __has_feature(address_sanitizer)
+#include "sanitizer/lsan_interface.h"
+#endif
+
+#include "aos/common/logging/logging.h"
+#include "aos/common/once.h"
+#include "aos/common/network/team_number.h"
+#include "aos/common/mutex.h"
+
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+namespace y2017 {
+namespace constants {
+
+// ///// Mutual constants between robots. /////
+const int Values::kZeroingSampleSize;
+
+constexpr double Values::kDrivetrainEncoderRatio;
+
+namespace {
+const uint16_t kCompTeamNumber = 971;
+const uint16_t kPracticeTeamNumber = 9971;
+
+// ///// Dynamic constants. /////
+
+const Values *DoGetValuesForTeam(uint16_t team) {
+  switch (team) {
+    case 1:  // for tests
+      return new Values{
+          5.0,  // drivetrain max speed
+      };
+      break;
+
+    case kCompTeamNumber:
+      return new Values{
+          5.0,  // drivetrain max speed
+      };
+      break;
+
+    case kPracticeTeamNumber:
+      return new Values{
+          5.0,  // drivetrain max speed
+      };
+      break;
+
+    default:
+      LOG(FATAL, "unknown team #%" PRIu16 "\n", team);
+  }
+}
+
+const Values *DoGetValues() {
+  uint16_t team = ::aos::network::GetTeamNumber();
+  LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
+  return DoGetValuesForTeam(team);
+}
+
+}  // namespace
+
+const Values &GetValues() {
+  static ::aos::Once<const Values> once(DoGetValues);
+  return *once.Get();
+}
+
+const Values &GetValuesForTeam(uint16_t team_number) {
+  static ::aos::Mutex mutex;
+  ::aos::MutexLocker locker(&mutex);
+
+  // IMPORTANT: This declaration has to stay after the mutex is locked to avoid
+  // race conditions.
+  static ::std::map<uint16_t, const Values *> values;
+
+  if (values.count(team_number) == 0) {
+    values[team_number] = DoGetValuesForTeam(team_number);
+#if __has_feature(address_sanitizer)
+    __lsan_ignore_object(values[team_number]);
+#endif
+  }
+  return *values[team_number];
+}
+
+}  // namespace constants
+}  // namespace y2017
diff --git a/y2017/constants.h b/y2017/constants.h
new file mode 100644
index 0000000..be29a2a
--- /dev/null
+++ b/y2017/constants.h
@@ -0,0 +1,41 @@
+#ifndef Y2017_CONSTANTS_H_
+#define Y2017_CONSTANTS_H_
+
+#include <stdint.h>
+
+namespace y2017 {
+namespace constants {
+
+// Has all of the numbers that change for both robots and makes it easy to
+// retrieve the values for the current one.
+
+// Everything is in SI units (volts, radians, meters, seconds, etc).
+// Some of these values are related to the conversion between raw values
+// (encoder counts, voltage, etc) to scaled units (radians, meters, etc).
+
+// This structure contains current values for all of the things that change.
+struct Values {
+  // ///// Mutual constants between robots. /////
+  // TODO(constants): Update/check these with what we're using this year.
+  static const int kZeroingSampleSize = 200;
+
+  // The ratio from the encoder shaft to the drivetrain wheels.
+  static constexpr double kDrivetrainEncoderRatio =
+      (18.0 / 36.0) /*output reduction*/ * (44.0 / 30.0) /*encoder gears*/;
+
+  // ///// Dynamic constants. /////
+  double drivetrain_max_speed;
+};
+
+// Creates (once) a Values instance for ::aos::network::GetTeamNumber() and
+// returns a reference to it.
+const Values &GetValues();
+
+// Creates Values instances for each team number it is called with and returns
+// them.
+const Values &GetValuesForTeam(uint16_t team_number);
+
+}  // namespace constants
+}  // namespace y2017
+
+#endif  // Y2017_CONSTANTS_H_