Remove usage of CHECK_NOTNULL

We want to switch to absl logging instead of glog.  gtest and ceres are
going there, and we already have absl as a dependency.  ABSL doesn't
have CHECK_NOTNULL, and we can move things over in an easier to review
fashion.

Change-Id: Ifd9a11ec34a2357cec43f88dba015db9c28ed2cf
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/control_loops/drivetrain/splinedrivetrain.cc b/frc971/control_loops/drivetrain/splinedrivetrain.cc
index f052a9e..ebe0f64 100644
--- a/frc971/control_loops/drivetrain/splinedrivetrain.cc
+++ b/frc971/control_loops/drivetrain/splinedrivetrain.cc
@@ -79,7 +79,9 @@
 }
 
 void SplineDrivetrain::DeleteCurrentSpline() {
-  DeleteTrajectory(&CHECK_NOTNULL(current_trajectory())->trajectory());
+  const FinishedTrajectory *const trajectory = current_trajectory();
+  CHECK(trajectory != nullptr);
+  DeleteTrajectory(&trajectory->trajectory());
   executing_spline_ = false;
   commanded_spline_.reset();
   current_xva_.setZero();
@@ -95,12 +97,15 @@
       DeleteCurrentSpline();
       return;
     } else {
-      if (executing_spline_ &&
-          CHECK_NOTNULL(current_trajectory())->spline_handle() !=
-              *commanded_spline) {
-        // If we are executing a spline, and the handle has changed, garbage
-        // collect the old spline.
-        DeleteCurrentSpline();
+      if (executing_spline_) {
+        const FinishedTrajectory *const trajectory = current_trajectory();
+        CHECK(trajectory != nullptr);
+
+        if (trajectory->spline_handle() != *commanded_spline) {
+          // If we are executing a spline, and the handle has changed, garbage
+          // collect the old spline.
+          DeleteCurrentSpline();
+        }
       }
     }
   }
@@ -144,8 +149,8 @@
   enable_ = enable;
   if (enable && executing_spline_) {
     ::Eigen::Matrix<double, 2, 1> U_ff = ::Eigen::Matrix<double, 2, 1>::Zero();
-    const FinishedTrajectory *const trajectory =
-        CHECK_NOTNULL(current_trajectory());
+    const FinishedTrajectory *const trajectory = current_trajectory();
+    CHECK(trajectory != nullptr);
     if (!IsAtEnd() && executing_spline_) {
       // TODO(alex): It takes about a cycle for the outputs to propagate to the
       // motors. Consider delaying the output by a cycle.
@@ -258,7 +263,9 @@
     ::Eigen::Matrix<double, 5, 1> goal_state = CurrentGoalState();
     trajectory_logging_builder.add_x(goal_state(0));
     trajectory_logging_builder.add_y(goal_state(1));
-    if (CHECK_NOTNULL(current_trajectory())->drive_spline_backwards()) {
+    const FinishedTrajectory *const trajectory = current_trajectory();
+    CHECK(trajectory != nullptr);
+    if (trajectory->drive_spline_backwards()) {
       trajectory_logging_builder.add_left_velocity(-goal_state(4));
       trajectory_logging_builder.add_right_velocity(-goal_state(3));
       trajectory_logging_builder.add_theta(
@@ -285,10 +292,14 @@
       trajectory_logging_builder.add_current_spline_idx(*commanded_spline_);
     }
   }
-  trajectory_logging_builder.add_distance_remaining(
-      executing_spline_
-          ? CHECK_NOTNULL(current_trajectory())->length() - current_xva_.x()
-          : 0.0);
+  if (executing_spline_) {
+    const FinishedTrajectory *const trajectory = current_trajectory();
+    CHECK(trajectory != nullptr);
+    trajectory_logging_builder.add_distance_remaining(trajectory->length() -
+                                                      current_xva_.x());
+  } else {
+    trajectory_logging_builder.add_distance_remaining(0.0);
+  }
   trajectory_logging_builder.add_available_splines(handles_vector);
   trajectory_logging_builder.add_distance_traveled(
       executing_spline_ ? current_xva_.x() : 0.0);