Upgraded y2016 shooter to std::chrono

Change-Id: I095ddfb76e9ee076854b6c70d754d210935e5457
diff --git a/y2016/control_loops/shooter/shooter.cc b/y2016/control_loops/shooter/shooter.cc
index c9ee712..7b64f99 100644
--- a/y2016/control_loops/shooter/shooter.cc
+++ b/y2016/control_loops/shooter/shooter.cc
@@ -13,8 +13,8 @@
 namespace control_loops {
 namespace shooter {
 
-using ::aos::time::Time;
 namespace chrono = ::std::chrono;
+using ::aos::monotonic_clock;
 
 // TODO(austin): Pseudo current limit?
 
@@ -75,7 +75,7 @@
 Shooter::Shooter(ShooterQueue *my_shooter)
     : aos::controls::ControlLoop<ShooterQueue>(my_shooter),
       shots_(0),
-      last_pre_shot_timeout_(0, 0) {}
+      last_pre_shot_timeout_(::aos::monotonic_clock::min_time) {}
 
 void Shooter::RunIteration(const ShooterQueue::Goal *goal,
                            const ShooterQueue::Position *position,
@@ -132,7 +132,7 @@
               shoot = true;
             }
           }
-          last_pre_shot_timeout_ = Time::Now() + Time::InSeconds(1.0);
+          last_pre_shot_timeout_ = monotonic_clock::now() + chrono::seconds(1);
           break;
         case ShooterLatchState::WAITING_FOR_SPINDOWN:
           shoot = true;
@@ -141,7 +141,7 @@
             state_ = ShooterLatchState::WAITING_FOR_SPINUP;
           }
           if (::std::abs(goal->angular_velocity) < 10 ||
-              last_pre_shot_timeout_ < Time::Now()) {
+              last_pre_shot_timeout_ < monotonic_clock::now()) {
             state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
           }
           break;
@@ -152,7 +152,7 @@
             state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
           }
           if (::std::abs(goal->angular_velocity) < 10 ||
-              last_pre_shot_timeout_ < Time::Now()) {
+              last_pre_shot_timeout_ < monotonic_clock::now()) {
             state_ = ShooterLatchState::INCREMENT_SHOT_COUNT;
           }
           break;
diff --git a/y2016/control_loops/shooter/shooter.h b/y2016/control_loops/shooter/shooter.h
index 0b515f1..aafc472 100644
--- a/y2016/control_loops/shooter/shooter.h
+++ b/y2016/control_loops/shooter/shooter.h
@@ -85,7 +85,7 @@
 
   // Current state.
   ShooterLatchState state_ = ShooterLatchState::PASS_THROUGH;
-  ::aos::time::Time last_pre_shot_timeout_;
+  ::aos::monotonic_clock::time_point last_pre_shot_timeout_;
 
   DISALLOW_COPY_AND_ASSIGN(Shooter);
 };
diff --git a/y2016/control_loops/shooter/shooter_lib_test.cc b/y2016/control_loops/shooter/shooter_lib_test.cc
index 8d0ae39..93b3b17 100644
--- a/y2016/control_loops/shooter/shooter_lib_test.cc
+++ b/y2016/control_loops/shooter/shooter_lib_test.cc
@@ -2,6 +2,7 @@
 
 #include <unistd.h>
 
+#include <chrono>
 #include <memory>
 
 #include "gtest/gtest.h"
@@ -12,7 +13,6 @@
 #include "y2016/control_loops/shooter/shooter.h"
 #include "y2016/control_loops/shooter/shooter_plant.h"
 
-using ::aos::time::Time;
 using ::frc971::control_loops::testing::kTeamNumber;
 
 namespace y2016 {
@@ -20,6 +20,9 @@
 namespace shooter {
 namespace testing {
 
+namespace chrono = ::std::chrono;
+using ::aos::monotonic_clock;
+
 class ShooterPlant : public StateFeedbackPlant<2, 1, 1> {
  public:
   explicit ShooterPlant(StateFeedbackPlant<2, 1, 1> &&other)
@@ -138,9 +141,9 @@
   }
 
   // Runs iterations until the specified amount of simulated time has elapsed.
-  void RunForTime(const Time &run_for, bool enabled = true) {
-    const auto start_time = Time::Now();
-    while (Time::Now() < start_time + run_for) {
+  void RunForTime(const monotonic_clock::duration run_for, bool enabled = true) {
+    const auto start_time = monotonic_clock::now();
+    while (monotonic_clock::now() < start_time + run_for) {
       RunIteration(enabled);
     }
   }
@@ -175,7 +178,7 @@
   // Spin up.
   EXPECT_TRUE(
       shooter_queue_.goal.MakeWithBuilder().angular_velocity(450.0).Send());
-  RunForTime(Time::InSeconds(1));
+  RunForTime(chrono::seconds(1));
   VerifyNearGoal();
   EXPECT_TRUE(shooter_queue_.status->ready);
   EXPECT_TRUE(
@@ -188,7 +191,7 @@
   EXPECT_EQ(0.0, shooter_queue_.output->voltage_right);
 
   // Continue to stop.
-  RunForTime(Time::InSeconds(5));
+  RunForTime(chrono::seconds(5));
   EXPECT_TRUE(shooter_queue_.output.FetchLatest());
   EXPECT_EQ(0.0, shooter_queue_.output->voltage_left);
   EXPECT_EQ(0.0, shooter_queue_.output->voltage_right);
@@ -203,7 +206,7 @@
       shooter_queue_.goal.MakeWithBuilder().angular_velocity(20.0).Send());
   // Cause problems by adding a voltage error on one side.
   shooter_plant_.set_right_voltage_offset(-4.0);
-  RunForTime(Time::InSeconds(0.1));
+  RunForTime(chrono::milliseconds(100));
 
   shooter_queue_.goal.FetchLatest();
   shooter_queue_.status.FetchLatest();
@@ -216,7 +219,7 @@
   EXPECT_FALSE(shooter_queue_.status->right.ready);
   EXPECT_FALSE(shooter_queue_.status->ready);
 
-  RunForTime(Time::InSeconds(5));
+  RunForTime(chrono::seconds(5));
 
   shooter_queue_.goal.FetchLatest();
   shooter_queue_.status.FetchLatest();
@@ -235,10 +238,10 @@
   ASSERT_TRUE(shooter_queue_.goal.MakeWithBuilder()
                   .angular_velocity(200.0)
                   .Send());
-  RunForTime(Time::InSeconds(5), false);
+  RunForTime(chrono::seconds(5), false);
   EXPECT_EQ(nullptr, shooter_queue_.output.get());
 
-  RunForTime(Time::InSeconds(5));
+  RunForTime(chrono::seconds(5));
 
   VerifyNearGoal();
 }