L060ShapingOpMode

What each lesson’s patch does to this file, in the order the lessons come, from applying solutions/ on solutions-auto-schedules.1. A line marked + is new, and a line marked - is gone; each number is the line’s place in the file after the lesson.

L060

--- mytry/L060ShapingOpMode.java  (before L060)
+++ mytry/L060ShapingOpMode.java  (after L060)
@@ lines 75 to 93 @@
   75         // When on L060S040, see
   76         // https://msb-stitt.github.io/ftc31459-26-27-biobuzz/guide/tasks/l060.html#l060s040
   77         // for what to do here.
+  78         double band = 0.05;
+  79         double leftPower = deadband(leftSpeed, band);
+  80         leftPower = signedSquared(leftPower);
+  81         Tracker.publish("power/left", leftPower);
+  82         double rightPower = deadband(rightSpeed, band);
+  83         rightPower = signedSquared(rightPower);
+  84         Tracker.publish("power/right", rightPower);
   85
-             hardware.frontLeft.setPower(leftSpeed);
-             hardware.backLeft.setPower(leftSpeed);
+  86         hardware.frontLeft.setPower(leftPower);
+  87         hardware.backLeft.setPower(leftPower);
   88
-             hardware.frontRight.setPower(rightSpeed);
-             hardware.backRight.setPower(rightSpeed);
+  89         hardware.frontRight.setPower(rightPower);
+  90         hardware.backRight.setPower(rightPower);
   91     }
   92
   93     // 'public' to match the parent class. 'public' allows access from any code.
@@ lines 99 to 117 @@
   99     // When on L060S030, see
  100     // https://msb-stitt.github.io/ftc31459-26-27-biobuzz/guide/tasks/l060.html#l060s030
  101     // for what to do here.
+ 102     double deadband(double value, double band) {
+ 103         double alwaysPositiveMagnitude = Math.abs(value);
+ 104         boolean isCloseToZero = alwaysPositiveMagnitude < band;
+ 105         if (isCloseToZero) {
+ 106             return 0.0;
+ 107         }
+ 108         return value;
+ 109     }
  110
  111     // When on L060S050, see
  112     // https://msb-stitt.github.io/ftc31459-26-27-biobuzz/guide/tasks/l060.html#l060s050
  113     // for what to do here.
+ 114     double signedSquared(double value) {
+ 115         return value * Math.abs(value);
+ 116     }
  117 }