Merge "Get some basic Teensy code working"
diff --git a/aos/common/controls/control_loop_test.h b/aos/common/controls/control_loop_test.h
index 88ccfa5..6fae706 100644
--- a/aos/common/controls/control_loop_test.h
+++ b/aos/common/controls/control_loop_test.h
@@ -25,7 +25,9 @@
   // Sends out all of the required queue messages.
   void SendMessages(bool enabled);
   // Ticks time for a single control loop cycle.
-  void TickTime() { ::aos::time::SetMockTime(current_time_ += kTimeTick); }
+  void TickTime(::std::chrono::nanoseconds dt = kTimeTick) {
+    ::aos::time::SetMockTime(current_time_ += dt);
+  }
 
   // Simulates everything that happens during 1 loop time step.
   void SimulateTimestep(bool enabled) {
diff --git a/frc971/wpilib/buffered_pcm.cc b/frc971/wpilib/buffered_pcm.cc
index 54174c5..5f1dc67 100644
--- a/frc971/wpilib/buffered_pcm.cc
+++ b/frc971/wpilib/buffered_pcm.cc
@@ -12,7 +12,7 @@
       new BufferedSolenoid(number, this));
 }
 
-void BufferedPcm::Set(int number, bool value) {
+void BufferedPcm::DoSet(int number, bool value) {
   if (value) {
     values_ |= 1 << number;
   } else {
diff --git a/frc971/wpilib/buffered_pcm.h b/frc971/wpilib/buffered_pcm.h
index 09bf95f..4ff625b 100644
--- a/frc971/wpilib/buffered_pcm.h
+++ b/frc971/wpilib/buffered_pcm.h
@@ -33,7 +33,7 @@
   virtual void InitSolenoid() override {}
 #endif
 
-  void Set(int number, bool value);
+  void DoSet(int number, bool value);
 
   uint8_t values_ = 0;
 
diff --git a/frc971/wpilib/buffered_solenoid.cc b/frc971/wpilib/buffered_solenoid.cc
index cd68da8..c07a7cd 100644
--- a/frc971/wpilib/buffered_solenoid.cc
+++ b/frc971/wpilib/buffered_solenoid.cc
@@ -6,7 +6,7 @@
 namespace wpilib {
 
 void BufferedSolenoid::Set(bool value) {
-  pcm_->Set(number_, value);
+  pcm_->DoSet(number_, value);
 }
 
 }  // namespace wpilib
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index 4fa332f..7676131 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -208,6 +208,7 @@
   ],
   copts = common_copts + [
     '-fno-builtin',
+    '-Wno-mismatched-new-delete',
   ],
   size = 'small',
 )
diff --git a/third_party/gperftools/src/base/basictypes.h b/third_party/gperftools/src/base/basictypes.h
index 4779611..2a0fec1 100644
--- a/third_party/gperftools/src/base/basictypes.h
+++ b/third_party/gperftools/src/base/basictypes.h
@@ -78,12 +78,12 @@
 const  int8  kint8max   = (   (  int8) 0x7F);
 const  int16 kint16max  = (   ( int16) 0x7FFF);
 const  int32 kint32max  = (   ( int32) 0x7FFFFFFF);
-const  int64 kint64max =  ( ((( int64) kint32max) << 32) | kuint32max );
+const  int64 kint64max =  ( ((( uint64) kint32max) << 32) | kuint32max );
 
 const  int8  kint8min   = (   (  int8) 0x80);
 const  int16 kint16min  = (   ( int16) 0x8000);
 const  int32 kint32min  = (   ( int32) 0x80000000);
-const  int64 kint64min =  ( ((( int64) kint32min) << 32) | 0 );
+const  int64 kint64min =  ( ((( uint64) kint32min) << 32) | 0 );
 
 // Define the "portable" printf and scanf macros, if they're not
 // already there (via the inttypes.h we #included above, hopefully).
diff --git a/y2014/autonomous/auto.cc b/y2014/autonomous/auto.cc
index e7f7697..e443f6b 100644
--- a/y2014/autonomous/auto.cc
+++ b/y2014/autonomous/auto.cc
@@ -212,7 +212,7 @@
       distance - theta * control_loops::drivetrain::kRobotRadius;
   right_initial_position +=
       distance + theta * control_loops::drivetrain::kRobotRadius;
-  return ::std::move(drivetrain_action);
+  return drivetrain_action;
 }
 
 void Shoot() {
diff --git a/y2015/autonomous/auto.cc b/y2015/autonomous/auto.cc
index 4df613d..2a1a7c2 100644
--- a/y2015/autonomous/auto.cc
+++ b/y2015/autonomous/auto.cc
@@ -166,7 +166,7 @@
       distance - theta * constants::GetValues().turn_width / 2.0;
   right_initial_position +=
       distance + theta * constants::GetValues().turn_width / 2.0;
-  return ::std::move(drivetrain_action);
+  return drivetrain_action;
 }
 
 const ProfileParams kFridgeYProfile{1.0, 4.0};
diff --git a/y2015_bot3/autonomous/auto.cc b/y2015_bot3/autonomous/auto.cc
index 35ad8d2..f7491f4 100644
--- a/y2015_bot3/autonomous/auto.cc
+++ b/y2015_bot3/autonomous/auto.cc
@@ -91,7 +91,7 @@
       distance - theta * control_loops::drivetrain::kDrivetrainTurnWidth / 2.0;
   right_initial_position +=
       distance + theta * control_loops::drivetrain::kDrivetrainTurnWidth / 2.0;
-  return ::std::move(drivetrain_action);
+  return drivetrain_action;
 }
 void WaitUntilDoneOrCanceled(
     ::std::unique_ptr<aos::common::actions::Action> action) {
diff --git a/y2016/actors/autonomous_actor.cc b/y2016/actors/autonomous_actor.cc
index 4646cde..727f5de 100644
--- a/y2016/actors/autonomous_actor.cc
+++ b/y2016/actors/autonomous_actor.cc
@@ -197,7 +197,7 @@
 
 void AutonomousActor::AlignWithVisionGoal() {
   actors::VisionAlignActionParams params;
-  vision_action_ = ::std::move(actors::MakeVisionAlignAction(params));
+  vision_action_ = actors::MakeVisionAlignAction(params);
   vision_action_->Start();
 }
 
diff --git a/y2017/control_loops/superstructure/shooter/shooter.cc b/y2017/control_loops/superstructure/shooter/shooter.cc
index 795a7d4..03abd99 100644
--- a/y2017/control_loops/superstructure/shooter/shooter.cc
+++ b/y2017/control_loops/superstructure/shooter/shooter.cc
@@ -67,10 +67,7 @@
   // Compute the distance moved over that time period.
   average_angular_velocity_ =
       (history_[oldest_history_position] - history_[history_position_]) /
-      (chrono::duration_cast<chrono::duration<double>>(
-           ::aos::controls::kLoopFrequency)
-           .count() *
-       static_cast<double>(kHistoryLength - 1));
+      (0.00505 * static_cast<double>(kHistoryLength - 1));
 
   // Ready if average angular velocity is close to the goal.
   error_ = average_angular_velocity_ - loop_->next_R(2, 0);
diff --git a/y2017/control_loops/superstructure/superstructure_lib_test.cc b/y2017/control_loops/superstructure/superstructure_lib_test.cc
index 7906af4..513e2f2 100644
--- a/y2017/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2017/control_loops/superstructure/superstructure_lib_test.cc
@@ -492,7 +492,7 @@
     superstructure_.Iterate();
     superstructure_plant_.Simulate();
 
-    TickTime();
+    TickTime(::std::chrono::microseconds(5050));
   }
 
   // Runs iterations until the specified amount of simulated time has elapsed.
@@ -948,7 +948,7 @@
 
   superstructure_plant_.set_hood_voltage_offset(2.0);
 
-  superstructure_plant_.set_turret_voltage_offset(-1.5);
+  superstructure_plant_.set_turret_voltage_offset(-1.0);
   superstructure_plant_.set_indexer_voltage_offset(2.0);
 
   RunForTime(chrono::seconds(1), false);
@@ -1082,12 +1082,13 @@
     }
   }
 
-  // Make sure it took some time, but not too much to detect us not being stuck anymore.
+  // Make sure it took some time, but not too much to detect us not being stuck
+  // anymore.
   const auto unstuck_detection_time = monotonic_clock::now();
   EXPECT_TRUE(unstuck_detection_time - unstuck_start_time <
-              chrono::milliseconds(200));
+              chrono::milliseconds(600));
   EXPECT_TRUE(unstuck_detection_time - unstuck_start_time >
-              chrono::milliseconds(40));
+              chrono::milliseconds(100));
 
   // Verify that it actually moved.
   superstructure_queue_.position.FetchLatest();
@@ -1155,7 +1156,7 @@
   // anymore.
   const auto unstuck_detection_time = monotonic_clock::now();
   EXPECT_TRUE(unstuck_detection_time - unstuck_start_time <
-              chrono::milliseconds(600));
+              chrono::milliseconds(1050));
   EXPECT_TRUE(unstuck_detection_time - unstuck_start_time >
               chrono::milliseconds(400));
   LOG(INFO, "Unstuck time is %ldms",