OpMode Classes (Step 3)
Integrating OpModes
Going along with the robot established in the previous module, we will now create an OpMode for our robot with a single motor connected to an encoder. Creating the opMode is very simple.
Implementation
The only difference between a standard opMode and this opMode is that this will be an extension of the base class.
OpMode
@TeleOp(name = "SampleTeleop", group = "samples")
public class SampleTeleop extends Base { // extends base instead of linearopmode
@Override
public void runOpMode() throws InterruptedException {
initHardware(); // inits hardware
telemetry.addData("Status", "Initialized");
telemetry.update();
waitForStart();
matchTime.reset();
while (opModeIsActive()) {
// Updates
//only call reset cache if you are using manual mode in your lynxmodule
//resetCache();
// move arm up when 'a' is pressed
if(gamepad1.a){
armModule.moveArmMotorTicks(500);
}
// move arm back down when 'b' is pressed
if(gamepad1.b){
armModule.moveArmMotorTicks(0);
}
// Display Values
telemetry.addLine("Program is running");
telemetry.update();
}
}
}Module Class
Base Class
Last updated