Merge "Log the pulse widths from the drivetrain encoders"
diff --git a/debian/usr.BUILD b/debian/usr.BUILD
index ac354cc..c66b30d 100644
--- a/debian/usr.BUILD
+++ b/debian/usr.BUILD
@@ -44,6 +44,7 @@
   ],
   copts = [
     '-Wno-error',
+    '-Wno-parentheses-equality',
   ],
   includes = [
     'lib/python3/dist-packages/numpy/f2py/src/',
diff --git a/frc971/wpilib/loop_output_handler.cc b/frc971/wpilib/loop_output_handler.cc
index 658b064..310b3e3 100644
--- a/frc971/wpilib/loop_output_handler.cc
+++ b/frc971/wpilib/loop_output_handler.cc
@@ -15,8 +15,8 @@
     : watchdog_(this, timeout) {}
 
 void LoopOutputHandler::operator()() {
-  ::aos::SetCurrentThreadName("OutputHandler");
   ::std::thread watchdog_thread(::std::ref(watchdog_));
+  ::aos::SetCurrentThreadName("OutputHandler");
 
   ::aos::SetCurrentThreadRealtimePriority(30);
   while (run_) {
@@ -51,11 +51,11 @@
   if (timerfd_.get() == -1) {
     PLOG(FATAL, "timerfd_create(Time::kDefaultClock, 0)");
   }
-  ::aos::SetCurrentThreadRealtimePriority(35);
-  ::aos::SetCurrentThreadName("OutputWatchdog");
 }
 
 void LoopOutputHandler::Watchdog::operator()() {
+  ::aos::SetCurrentThreadRealtimePriority(35);
+  ::aos::SetCurrentThreadName("OutputWatchdog");
   uint8_t buf[8];
   while (run_) {
     PCHECK(read(timerfd_.get(), buf, sizeof(buf)));
diff --git a/tools/build_rules/fortran.bzl b/tools/build_rules/fortran.bzl
index c67884a..ff940af 100644
--- a/tools/build_rules/fortran.bzl
+++ b/tools/build_rules/fortran.bzl
@@ -18,6 +18,7 @@
                    '-Werror',
                    '-Wextra',
                    '-Wno-builtin-macro-redefined',
+                   '-Wunused-local-typedefs',
                    '-D__has_feature(x)=0',
                    '-fmacro-backtrace-limit=0']
 
diff --git a/y2014/control_loops/drivetrain/replay_drivetrain.cc b/y2014/control_loops/drivetrain/replay_drivetrain.cc
index 346ca69..b0ac33f 100644
--- a/y2014/control_loops/drivetrain/replay_drivetrain.cc
+++ b/y2014/control_loops/drivetrain/replay_drivetrain.cc
@@ -15,14 +15,22 @@
 
   ::aos::InitNRT();
 
-  ::aos::controls::ControlLoopReplayer<::y2014::control_loops::DrivetrainQueue>
-      replayer(&::y2014::control_loops::drivetrain_queue, "drivetrain");
+  {
+    ::aos::controls::ControlLoopReplayer<
+        ::y2014::control_loops::DrivetrainQueue>
+        replayer(&::y2014::control_loops::drivetrain_queue, "drivetrain");
 
-  replayer.AddDirectQueueSender("wpilib_interface.Gyro", "sending",
-                                ::frc971::sensors::gyro_reading);
-  for (int i = 1; i < argc; ++i) {
-    replayer.ProcessFile(argv[i]);
+    replayer.AddDirectQueueSender("wpilib_interface.Gyro", "sending",
+                                  ::frc971::sensors::gyro_reading);
+    for (int i = 1; i < argc; ++i) {
+      replayer.ProcessFile(argv[i]);
+    }
   }
+  ::frc971::sensors::gyro_reading.Clear();
+  ::y2014::control_loops::drivetrain_queue.goal.Clear();
+  ::y2014::control_loops::drivetrain_queue.status.Clear();
+  ::y2014::control_loops::drivetrain_queue.position.Clear();
+  ::y2014::control_loops::drivetrain_queue.output.Clear();
 
   ::aos::Cleanup();
 }
diff --git a/y2014/wpilib/wpilib_interface.cc b/y2014/wpilib/wpilib_interface.cc
index 8c37854..0278ebc 100644
--- a/y2014/wpilib/wpilib_interface.cc
+++ b/y2014/wpilib/wpilib_interface.cc
@@ -247,7 +247,6 @@
 
   void operator()() {
     ::aos::SetCurrentThreadName("SensorReader");
-    LOG(INFO, "In sensor reader thread\n");
 
     my_pid_ = getpid();
     ds_ =
@@ -261,7 +260,6 @@
     top_reader_.Start();
     bottom_reader_.Start();
     dma_synchronizer_->Start();
-    LOG(INFO, "Things are now started\n");
 
     ::aos::SetCurrentThreadRealtimePriority(kPriority);
     while (run_) {
@@ -694,7 +692,6 @@
     ::std::thread joystick_thread(::std::ref(joystick_sender));
 
     SensorReader reader;
-    LOG(INFO, "Creating the reader\n");
 
     // Create this first to make sure it ends up in one of the lower-numbered
     // FPGA slots so we can use it with DMA.
diff --git a/y2014_bot3/wpilib/wpilib_interface.cc b/y2014_bot3/wpilib/wpilib_interface.cc
index 56a5aa1..4fde0f5 100644
--- a/y2014_bot3/wpilib/wpilib_interface.cc
+++ b/y2014_bot3/wpilib/wpilib_interface.cc
@@ -88,7 +88,6 @@
 
   void operator()() {
     ::aos::SetCurrentThreadName("SensorReader");
-    LOG(INFO, "In sensor reader thread\n");
 
     my_pid_ = getpid();
     ds_ =
@@ -99,8 +98,6 @@
 #endif
     pdp_.reset(new PowerDistributionPanel());
 
-    LOG(INFO, "Things are now started\n");
-
     ::aos::SetCurrentThreadRealtimePriority(kPriority);
     while (run_) {
       ::aos::time::PhasedLoopXMS(5, 4000);
@@ -351,7 +348,6 @@
 
     // Sensors
     SensorReader reader;
-    LOG(INFO, "Creating the reader\n");
     reader.set_drivetrain_left_encoder(make_encoder(4));
     reader.set_drivetrain_right_encoder(make_encoder(5));
 
diff --git a/y2015/wpilib/wpilib_interface.cc b/y2015/wpilib/wpilib_interface.cc
index 84b921a..0ea4b8d 100644
--- a/y2015/wpilib/wpilib_interface.cc
+++ b/y2015/wpilib/wpilib_interface.cc
@@ -228,7 +228,6 @@
   }
 
   void operator()() {
-    LOG(INFO, "In sensor reader thread\n");
     ::aos::SetCurrentThreadName("SensorReader");
 
     my_pid_ = getpid();
@@ -242,7 +241,6 @@
 
     wrist_encoder_.Start();
     dma_synchronizer_->Start();
-    LOG(INFO, "Things are now started\n");
 
     ::aos::SetCurrentThreadRealtimePriority(kPriority);
     while (run_) {
@@ -650,7 +648,6 @@
     // TODO(austin): Compressor needs to use a spike.
 
     SensorReader reader;
-    LOG(INFO, "Creating the reader\n");
     reader.set_arm_left_encoder(encoder(1));
     reader.set_arm_left_index(make_unique<DigitalInput>(1));
     reader.set_arm_left_potentiometer(make_unique<AnalogInput>(1));
diff --git a/y2015_bot3/wpilib/wpilib_interface.cc b/y2015_bot3/wpilib/wpilib_interface.cc
index 682cff5..6b5c3db 100644
--- a/y2015_bot3/wpilib/wpilib_interface.cc
+++ b/y2015_bot3/wpilib/wpilib_interface.cc
@@ -127,7 +127,6 @@
   }
 
   void operator()() {
-    LOG(INFO, "In sensor reader thread\n");
     ::aos::SetCurrentThreadName("SensorReader");
 
     my_pid_ = getpid();
@@ -139,8 +138,6 @@
 #endif
     pdp_.reset(new PowerDistributionPanel());
 
-    LOG(INFO, "Things are now started\n");
-
     ::aos::SetCurrentThreadRealtimePriority(kPriority);
     while (run_) {
       ::aos::time::PhasedLoopXMS(5, 4000);
@@ -467,7 +464,6 @@
     ::std::thread joystick_thread(::std::ref(joystick_sender));
 
     SensorReader reader;
-    LOG(INFO, "Creating the reader\n");
 
     reader.set_elevator_encoder(encoder(6));
     reader.set_elevator_zeroing_hall_effect(make_unique<DigitalInput>(6));