Created
April 21, 2016 01:16
-
-
Save mdttrump97/672987ee962022514709ce7d229a02db to your computer and use it in GitHub Desktop.
ColorAutoDriver code with encoder count delay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.FTC3486.FTCRC_Extensions; | |
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode; | |
import com.qualcomm.robotcore.hardware.ColorSensor; | |
import com.qualcomm.robotcore.hardware.HardwareMap; | |
/** | |
* Created by Jacob on 2/24/16. | |
*/ | |
public class ColorAutoDriver extends AutoDriver { | |
ColorSensor colorSensor; | |
public ColorAutoDriver(LinearOpMode linearOpMode, DriveTrain driveTrain, | |
String colorSensor, HardwareMap hardwareMap) { | |
super(linearOpMode, driveTrain); | |
this.colorSensor = hardwareMap.colorSensor.get(colorSensor); | |
} | |
@Override | |
public AutoDriver drive_forward_implementation(int lightValue) { | |
driveTrain.setPowers(power, power); | |
while (driveTrain.getLeftEncoderCount() < 200 && | |
!eStop && opMode.opModeIsActive()) { | |
try { | |
opMode.waitOneFullHardwareCycle(); | |
} catch (InterruptedException e){ } | |
} | |
while (colorSensor.argb() <= lightValue && | |
!eStop && opMode.opModeIsActive()) { | |
try { | |
opMode.waitOneFullHardwareCycle(); | |
} catch (InterruptedException e){ } | |
} | |
driveTrain.haltDrive(); | |
return this; | |
} | |
@Override | |
public AutoDriver drive_backward_implementation(int lightValue) { | |
driveTrain.setPowers(-power, -power); | |
try { | |
opMode.waitOneFullHardwareCycle(); | |
} catch (InterruptedException e) { } | |
while (colorSensor.argb() <= lightValue && | |
!eStop && opMode.opModeIsActive()) { | |
try { | |
opMode.waitOneFullHardwareCycle(); | |
} catch (InterruptedException e){ } | |
} | |
driveTrain.haltDrive(); | |
return this; | |
} | |
@Override | |
public AutoDriver turn_clockwise_implementation(int encoderCount) { | |
return this; | |
} | |
@Override | |
public AutoDriver turn_counterclockwise_implementation(int encoderCount) { | |
return this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment