Product Introduction

12. Verifying Solutions
For each planned driving action, always step through the code manually. Yes, this means
with paper and pencil; ask an older person for those.
Make a chart. The first column is gyro heading, the others are variables in order:
currentHeading (after adjustment, if any), headingError, driveSteering, leftPower and
rightPower (after high/low clipping, if any). In the final column called Action, draw a little
arrow indicating the approximate robot driving direction produced by leftPower and
rightPower.
Now plug in gyro sensor headings one at a time, starting with possible initial values. For
starting near zero, for example, try +5 and +355. Remember that basic heading values
range only from 0 to 360, never negatives. Now try values that change, say, every 10
degrees, in the intended steering direction: CW higher, CCW lower. Finally try a number
just before your target, and a number just after your target (in case of overshoot). You can
even test for an imagined obstacle or collision!
For each sensor input value, draw the arrow for output action. If every tested scenario
does what you want, your entire loop should work fine.
This exercise, more than anything, will give a true understanding of proportional steering
with the Modern Robotics gyro. Best of luck!
13. Background
This guide was written for young teams after trying to help a rookie FTC team at their first
tournament in December 2015. The rookie programmers struggled to debug a simple
autonomous program to drive straight and make a couple of turns. The code structure
was good, but the programmers lost track of the pluses and minuses, forwards and backs,
lefts and rights, and especially the logic of gyro conversions near zero degrees.
Tournament pressure added to the confusion. At one point they were dealing with triple
negatives: positive power drives backwards, rightMotor is on the left side, but
automatically reversed. Also they forgot whether the gyro headings increase CW or CCW,
and forgot that their treads could not drive backwards, separately or together. An
interesting day!
Searching online for clear guidance was not fruitful. Here are two examples:
“This is an example LinearOpMode that shows how to use the Modern Robotics Gyro.”
http://stackoverflow.com/questions/33723341/moving-methods-into-a-different-class-without-passing-variables-java
“Gyros to control robot driving direction”
http://wpilib.screenstepslive.com/s/3120/m/7912/l/85772-gyros-to-control-robot-driving-direction
So, this basic guide was created. It all seems so simple now! But really it wasn’t, and
hopefully other new teams can now use this valuable sensor. Comments and corrections
are welcome, please email WestsideRobotics@verizon.net