Converted trapezoid_profile over to monotonic_clock

This also involves updating all the callers, and updating
control_loop's frequency variable.

Change-Id: Ic88d2715db30efcc25721da2dd8c89910ede7788
diff --git a/aos/common/actions/actor.h b/aos/common/actions/actor.h
index b3a0220..e591084 100644
--- a/aos/common/actions/actor.h
+++ b/aos/common/actions/actor.h
@@ -65,11 +65,12 @@
   // succeeded.
   bool WaitOrCancel(const ::aos::time::Time& duration) {
     return !WaitUntil([]() {
-                        ::aos::time::PhasedLoopXMS(
-                            ::aos::controls::kLoopFrequency.ToMSec(), 2500);
-                        return false;
-                      },
-                      ::aos::time::Time::Now() + duration);
+      ::aos::time::PhasedLoopXMS(
+          ::std::chrono::duration_cast<::std::chrono::milliseconds>(
+              ::aos::controls::kLoopFrequency).count(),
+          2500);
+      return false;
+    }, ::aos::time::Time::Now() + duration);
   }
 
   // Returns true if the action should be canceled.
diff --git a/aos/common/controls/control_loop.h b/aos/common/controls/control_loop.h
index d56e5d8..f589ed7 100644
--- a/aos/common/controls/control_loop.h
+++ b/aos/common/controls/control_loop.h
@@ -37,7 +37,8 @@
 };
 
 // Control loops run this often, "starting" at time 0.
-constexpr time::Time kLoopFrequency = time::Time::InSeconds(0.005);
+constexpr ::std::chrono::nanoseconds kLoopFrequency =
+    ::std::chrono::milliseconds(5);
 
 // Provides helper methods to assist in writing control loops.
 // This template expects to be constructed with a queue group as an argument
diff --git a/aos/common/util/trapezoid_profile.cc b/aos/common/util/trapezoid_profile.cc
index f441fbe..4e4546e 100644
--- a/aos/common/util/trapezoid_profile.cc
+++ b/aos/common/util/trapezoid_profile.cc
@@ -7,10 +7,8 @@
 namespace aos {
 namespace util {
 
-TrapezoidProfile::TrapezoidProfile(const time::Time &delta_time)
-    : maximum_acceleration_(0),
-      maximum_velocity_(0),
-      timestep_(delta_time) {
+TrapezoidProfile::TrapezoidProfile(::std::chrono::nanoseconds delta_time)
+    : maximum_acceleration_(0), maximum_velocity_(0), timestep_(delta_time) {
   output_.setZero();
 }
 
@@ -26,7 +24,9 @@
     double goal_velocity) {
   CalculateTimes(goal_position - output_(0), goal_velocity);
 
-  double next_timestep = timestep_.ToSeconds();
+  double next_timestep =
+      ::std::chrono::duration_cast<::std::chrono::duration<double>>(timestep_)
+          .count();
 
   if (acceleration_time_ > next_timestep) {
     UpdateVals(acceleration_, next_timestep);
diff --git a/aos/common/util/trapezoid_profile.h b/aos/common/util/trapezoid_profile.h
index fe63352..cc91db1 100644
--- a/aos/common/util/trapezoid_profile.h
+++ b/aos/common/util/trapezoid_profile.h
@@ -17,7 +17,7 @@
 class TrapezoidProfile {
  public:
   // delta_time is how long between each call to Update.
-  TrapezoidProfile(const time::Time &delta_time);
+  TrapezoidProfile(::std::chrono::nanoseconds delta_time);
 
   // Updates the state.
   const Eigen::Matrix<double, 2, 1> &Update(double goal_position,
@@ -58,7 +58,7 @@
   double maximum_velocity_;
 
   // How long between calls to Update.
-  const time::Time timestep_;
+  ::std::chrono::nanoseconds timestep_;
 
   DISALLOW_COPY_AND_ASSIGN(TrapezoidProfile);
 };
diff --git a/aos/common/util/trapezoid_profile_test.cc b/aos/common/util/trapezoid_profile_test.cc
index 1dfeff3..c6e811c 100644
--- a/aos/common/util/trapezoid_profile_test.cc
+++ b/aos/common/util/trapezoid_profile_test.cc
@@ -45,11 +45,13 @@
   }
 
  private:
-  static const time::Time delta_time;
+  static constexpr ::std::chrono::nanoseconds delta_time =
+      ::std::chrono::milliseconds(10);
 
   Eigen::Matrix<double, 2, 1> position_;
 };
-const time::Time TrapezoidProfileTest::delta_time = time::Time::InSeconds(0.01);
+
+constexpr ::std::chrono::nanoseconds TrapezoidProfileTest::delta_time;
 
 TEST_F(TrapezoidProfileTest, ReachesGoal) {
   for (int i = 0; i < 450; ++i) {