Merge "Log IMU readings on the logger PI"
diff --git a/aos/events/simulated_event_loop.cc b/aos/events/simulated_event_loop.cc
index 9121a8f..11e10a6 100644
--- a/aos/events/simulated_event_loop.cc
+++ b/aos/events/simulated_event_loop.cc
@@ -1275,7 +1275,10 @@
   scheduler_.ScheduleOnStartup([this]() {
     UUID next_uuid = scheduler_.boot_uuid();
     if (boot_uuid_ != next_uuid) {
-      CHECK_EQ(boot_uuid_, UUID::Zero());
+      CHECK_EQ(boot_uuid_, UUID::Zero())
+          << ": Boot UUID changed without restarting.  Did TimeConverter "
+             "change the boot UUID without signaling a restart, or did you "
+             "change TimeConverter?";
       boot_uuid_ = next_uuid;
     }
     VLOG(1) << scheduler_.distributed_now() << " " << NodeName(this->node())
diff --git a/y2020/control_loops/drivetrain/drivetrain_base.cc b/y2020/control_loops/drivetrain/drivetrain_base.cc
index 9cd7494..952c3dc 100644
--- a/y2020/control_loops/drivetrain/drivetrain_base.cc
+++ b/y2020/control_loops/drivetrain/drivetrain_base.cc
@@ -60,7 +60,7 @@
           .finished() /*imu_transform*/,
   };
 
-  if (::aos::network::GetTeamNumber() == constants::Values::kCompTeamNumber) {
+  if (::aos::network::GetTeamNumber() != constants::Values::kCodingRobotTeamNumber) {
     // TODO(james): Check X/Y axis
     // transformations.
     kDrivetrainConfig.imu_transform = (Eigen::Matrix<double, 3, 3>() << 1.0,
diff --git a/y2020/control_loops/python/finisher.py b/y2020/control_loops/python/finisher.py
index 7ccccd6..8c33cc3 100644
--- a/y2020/control_loops/python/finisher.py
+++ b/y2020/control_loops/python/finisher.py
@@ -20,7 +20,7 @@
 G = 44.0 / 40.0
 # Overall flywheel inertia.
 J = 0.00507464
-J = 0.008
+J = 0.0035
 
 def AddResistance(motor, resistance):
     motor.resistance += resistance
@@ -40,7 +40,7 @@
     q_vel=10.0,
     q_voltage=4.0,
     r_pos=0.01,
-    controller_poles=[.89])
+    controller_poles=[.93])
 
 
 def main(argv):
@@ -58,4 +58,5 @@
 
 if __name__ == '__main__':
     argv = FLAGS(sys.argv)
+    glog.init()
     sys.exit(main(argv))
diff --git a/y2020/control_loops/python/flywheel.py b/y2020/control_loops/python/flywheel.py
index caaee96..6f41a17 100755
--- a/y2020/control_loops/python/flywheel.py
+++ b/y2020/control_loops/python/flywheel.py
@@ -70,6 +70,10 @@
 
         self.Kff = controls.TwoStateFeedForwards(self.B, self.Qff)
 
+        glog.debug('K: %s', str(self.K))
+        glog.debug('Poles: %s',
+                   str(numpy.linalg.eig(self.A - self.B * self.K)[0]))
+
 
 class Flywheel(VelocityFlywheel):
     def __init__(self, params, name="Flywheel"):
diff --git a/y2020/control_loops/superstructure/shooter/shooter.cc b/y2020/control_loops/superstructure/shooter/shooter.cc
index 99854fe..9be6273 100644
--- a/y2020/control_loops/superstructure/shooter/shooter.cc
+++ b/y2020/control_loops/superstructure/shooter/shooter.cc
@@ -116,6 +116,7 @@
       // come back up close to the last local maximum or is greater than it, the
       // ball has been shot.
       balls_shot_++;
+      VLOG(1) << "Shot ball at " << position_timestamp;
       ball_in_finisher_ = false;
     } else if (!ball_in_finisher_ &&
                (finisher_goal() > kVelocityToleranceFinisher)) {
diff --git a/y2020/control_loops/superstructure/superstructure.cc b/y2020/control_loops/superstructure/superstructure.cc
index 4fb5c1d..b3c36f0 100644
--- a/y2020/control_loops/superstructure/superstructure.cc
+++ b/y2020/control_loops/superstructure/superstructure.cc
@@ -245,7 +245,8 @@
         // the climber on.
         CHECK(unsafe_goal->has_turret());
         if (std::abs(unsafe_goal->turret()->unsafe_goal() -
-                     turret_.position()) > 0.1) {
+                     turret_.position()) > 0.1 &&
+            has_turret_) {
           output_struct.climber_voltage = 0;
         }
       }
diff --git a/y2020/control_loops/superstructure/superstructure_lib_test.cc b/y2020/control_loops/superstructure/superstructure_lib_test.cc
index c154c3d..0e51b7b 100644
--- a/y2020/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2020/control_loops/superstructure/superstructure_lib_test.cc
@@ -1087,18 +1087,21 @@
           ball_in_finisher_ = false;
           finisher_velocity_below_goal = false;
           balls_shot++;
+          LOG(INFO) << "Shot a ball at " << test_event_loop_->monotonic_now();
         }
         // Since here we are calculating the dip from the goal instead of the
         // local maximum, the shooter could have calculated that a ball was shot
         // slightly before we did if the local maximum was slightly below the
         // goal.
-        EXPECT_TRUE((superstructure_status_fetcher_->shooter()->balls_shot() ==
-                     balls_shot) ||
-                    ((superstructure_status_fetcher_->shooter()->balls_shot() ==
-                      balls_shot + 1) &&
-                     (finisher_velocity_dip -
-                          shooter::Shooter::kVelocityToleranceFinisher <
-                      0.2)));
+        if (superstructure_status_fetcher_->shooter()->balls_shot() !=
+            balls_shot) {
+          EXPECT_EQ(superstructure_status_fetcher_->shooter()->balls_shot(),
+                    balls_shot + 1)
+              << ": Failed at " << test_event_loop_->monotonic_now();
+          EXPECT_LT(finisher_velocity_dip,
+                    0.2 + shooter::Shooter::kVelocityToleranceFinisher)
+              << ": Failed at " << test_event_loop_->monotonic_now();
+        }
       },
       dt());
 
@@ -1108,8 +1111,8 @@
   // Maximum (since it is negative) flywheel voltage offsets for simulating the
   // friction of a ball at different finisher speeds.
   // Slower speeds require a higher magnitude of voltage offset.
-  static constexpr double kFastSpeedVoltageOffsetWithBall = -4.1;
-  static constexpr double kSlowSpeedVoltageOffsetWithBall = -4.5;
+  static constexpr double kFastSpeedVoltageOffsetWithBall = -3.1;
+  static constexpr double kSlowSpeedVoltageOffsetWithBall = -3.5;
 
   SetFinisherGoalAfter(kFastShootingSpeed, chrono::seconds(1));
   // Simulate shooting balls by applying friction to the finisher
@@ -1131,7 +1134,7 @@
   ApplyFrictionToFinisherAfter(kSlowSpeedVoltageOffsetWithBall, true,
                                chrono::seconds(31));
   // This smaller decrease in velocity shouldn't be counted as a ball
-  ApplyFrictionToFinisherAfter(kSlowSpeedVoltageOffsetWithBall / 2, false,
+  ApplyFrictionToFinisherAfter(kSlowSpeedVoltageOffsetWithBall / 10.0, false,
                                chrono::seconds(34));
 
   SetFinisherGoalAfter(kFastShootingSpeed, chrono::seconds(38));
@@ -1142,7 +1145,7 @@
   // This slow positive voltage offset that speeds up the flywheel instead of
   // slowing it down shouldn't be counted as a ball.
   // We wouldn't expect a positive voltage offset of more than ~2 volts.
-  ApplyFrictionToFinisherAfter(2, false, chrono::seconds(47));
+  ApplyFrictionToFinisherAfter(1, false, chrono::seconds(47));
 
   RunFor(chrono::seconds(50));
 
diff --git a/y2020/joystick_reader.cc b/y2020/joystick_reader.cc
index b101337..dd98e63 100644
--- a/y2020/joystick_reader.cc
+++ b/y2020/joystick_reader.cc
@@ -76,10 +76,6 @@
         setpoint_fetcher_(event_loop->MakeFetcher<y2020::joysticks::Setpoint>(
             "/superstructure")) {}
 
-  void AutoEnded() override {
-    AOS_LOG(INFO, "Auto ended, assuming disc and have piece\n");
-  }
-
   void BlueResetLocalizer() {
     auto builder = localizer_control_sender_.MakeBuilder();
 
@@ -187,7 +183,7 @@
         finisher_speed = setpoint_fetcher_->finisher();
       }
     } else if (data.IsPressed(kShootSlow)) {
-      accelerator_speed = 150.0;
+      accelerator_speed = 400.0;
       finisher_speed = 200.0;
     }
 
diff --git a/y2020/wpilib_interface.cc b/y2020/wpilib_interface.cc
index 67afb1d..1b732bc 100644
--- a/y2020/wpilib_interface.cc
+++ b/y2020/wpilib_interface.cc
@@ -625,7 +625,7 @@
     std::unique_ptr<frc971::wpilib::ADIS16448> old_imu;
     std::unique_ptr<frc971::wpilib::ADIS16470> new_imu;
     std::unique_ptr<frc::SPI> imu_spi;
-    if (::aos::network::GetTeamNumber() == constants::Values::kCompTeamNumber) {
+    if (::aos::network::GetTeamNumber() != constants::Values::kCodingRobotTeamNumber) {
       old_imu = make_unique<frc971::wpilib::ADIS16448>(
           &imu_event_loop, spi_port, imu_trigger.get());
       old_imu->SetDummySPI(frc::SPI::Port::kOnboardCS2);
diff --git a/y2020/www/field.html b/y2020/www/field.html
index e37d810..d3f5810 100644
--- a/y2020/www/field.html
+++ b/y2020/www/field.html
@@ -68,6 +68,10 @@
           <td>Right Accelerator</td>
           <td id="right_accelerator"> NA </td>
         </tr>
+        <tr>
+          <td>Balls shot </td>
+          <td id="balls_shot"> NA </td>
+        </tr>
       </table>
 
       <table>
diff --git a/y2020/www/field_handler.ts b/y2020/www/field_handler.ts
index eb5ece5..c1170c4 100644
--- a/y2020/www/field_handler.ts
+++ b/y2020/www/field_handler.ts
@@ -77,9 +77,9 @@
   // Image information indexed by timestamp (seconds since the epoch), so that
   // we can stop displaying images after a certain amount of time.
   private localizerImageMatches = new Map<number, LocalizerDebug>();
-  private outer_target: HTMLElement =
+  private outerTarget: HTMLElement =
       (document.getElementById('outer_target') as HTMLElement);
-  private inner_target: HTMLElement =
+  private innerTarget: HTMLElement =
       (document.getElementById('inner_target') as HTMLElement);
   private x: HTMLElement = (document.getElementById('x') as HTMLElement);
   private y: HTMLElement = (document.getElementById('y') as HTMLElement);
@@ -98,6 +98,8 @@
   private hood: HTMLElement = (document.getElementById('hood') as HTMLElement);
   private turret: HTMLElement =
       (document.getElementById('turret') as HTMLElement);
+  private ballsShot: HTMLElement =
+      (document.getElementById('balls_shot') as HTMLElement);
   private intake: HTMLElement =
       (document.getElementById('intake') as HTMLElement);
   private imagesAcceptedCounter: HTMLElement =
@@ -499,12 +501,12 @@
 
         if (this.superstructureStatus.aimer().aimingForInnerPort()) {
           this.innerPort.innerHTML = 'true';
-          this.outer_target.classList.remove('targetted');
-          this.inner_target.classList.add('targetted');
+          this.outerTarget.classList.remove('targetted');
+          this.innerTarget.classList.add('targetted');
         } else {
           this.innerPort.innerHTML = 'false';
-          this.outer_target.classList.add('targetted');
-          this.inner_target.classList.remove('targetted');
+          this.outerTarget.classList.add('targetted');
+          this.innerTarget.classList.remove('targetted');
         }
 
         if (!this.superstructureStatus.hood().zeroed()) {
@@ -519,6 +521,9 @@
               1e-3);
         }
 
+        this.ballsShot.innerHTML =
+            this.superstructureStatus.shooter().ballsShot().toString();
+
         if (!this.superstructureStatus.turret().zeroed()) {
           this.setZeroing(this.turret);
         } else if (this.superstructureStatus.turret().estopped()) {
diff --git a/y2020/y2020_roborio.json b/y2020/y2020_roborio.json
index 5417302..9a4842e 100644
--- a/y2020/y2020_roborio.json
+++ b/y2020/y2020_roborio.json
@@ -239,7 +239,8 @@
       "type": "frc971.control_loops.drivetrain.fb.Trajectory",
       "source_node": "roborio",
       "max_size": 600000,
-      "frequency": 4,
+      "frequency": 10,
+      "logger": "NOT_LOGGED",
       "num_senders": 2,
       "read_method": "PIN",
       "num_readers": 10