-
Notifications
You must be signed in to change notification settings - Fork 3
The EncoderDrive Class
The EncoderDrive class controls all general autonomous operation on the robot. This file also contains the robot data, such as the wheel circumference and wheel radius. It sets the motor names, such as the two motors being "motorLeft" and "motorRight" More niche code is shunted to the helper classes, while straight movement, rotation, and motor power control are implemented in here. This class includes all conversion ratios for using encoder ticks, as well as gear ratios.
The EncoderDrive class requires a LinearOpMode to function properly, and gets the two drive motors on initialization. It includes certain methods that write through to the LinearOpMode, such as waitForNextHardwareCycle() and 'stopDriverMotors'.
There are three variants of the rotateDegrees method. The first, which is currently the most accurate, uses the gyro sensor to turn. The second uses the radius of the wheelbase to calculate the distance each tread needs to travel in opposite directions for a given degree turn. The third is a work-in-progress one that uses PID control to achieve higher accuracy than both other methods. It is currently not complete. We use the gyro version because it is more robust when dealing with obstacles than the encoder method.
The 'moveInches' method commands the robot to move. It has built in commands to not move if the power is too high or low; or, to not move a negative distance. This instills security so that the robot doesn't exceed what it is capable of. A robot cannot go a negative distance.