copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff


git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/frc971/constants.cpp b/frc971/constants.cpp
new file mode 100644
index 0000000..6c16097
--- /dev/null
+++ b/frc971/constants.cpp
@@ -0,0 +1,75 @@
+#include "frc971/constants.h"
+
+#include <stddef.h>
+#include <inttypes.h>
+
+#include "aos/common/messages/RobotState.q.h"
+#include "aos/atom_code/output/MotorOutput.h"
+
+namespace frc971 {
+namespace constants {
+
+namespace {
+
+const double kCompHorizontal = -1.77635 + 0.180;
+const double kPracticeHorizontal = -1.77635 + -0.073631;
+const int kCompCameraCenter = -2;
+const int kPracticeCameraCenter = -5;
+
+struct Values {
+  // what horizontal_offset returns
+  double horizontal;
+  // what camera_center returns
+  int camera_center;
+  // what drivetrain_motor_controllers returns
+  char drivetrain_controllers;
+};
+Values *values = NULL;
+// Attempts to retrieve a new Values instance and stores it in values if
+// necessary.
+// Returns a valid Values instance or NULL.
+const Values *GetValues() {
+  if (values == NULL) {
+    LOG(INFO, "creating a Constants for team %"PRIu16"\n",
+        aos::robot_state->team_id);
+    switch (aos::robot_state->team_id) {
+      case kCompTeamNumber:
+        values = new Values{kCompHorizontal, kCompCameraCenter,
+          aos::MotorOutput::TALON};
+        break;
+      case kPracticeTeamNumber:
+        values = new Values{kPracticeHorizontal, kPracticeCameraCenter,
+          aos::MotorOutput::VICTOR};
+        break;
+      default:
+        LOG(ERROR, "unknown team #%"PRIu16"\n",
+            aos::robot_state->team_id);
+        return NULL;
+    }
+  }
+  return values;
+}
+
+}  // namespace
+
+bool horizontal_offset(double *horizontal) {
+  const Values *const values = GetValues();
+  if (values == NULL) return false;
+  *horizontal = values->horizontal;
+  return true;
+}
+bool camera_center(int *center) {
+  const Values *const values = GetValues();
+  if (values == NULL) return false;
+  *center = values->camera_center;
+  return true;
+}
+bool drivetrain_motor_controllers(char *controllers) {
+  const Values *const values = GetValues();
+  if (values == NULL) return false;
+  *controllers = values->drivetrain_controllers;
+  return true;
+}
+
+}  // namespace constants
+}  // namespace frc971