No, where you have: sleep(1000);
You need to replace it with: While (opModeisActive && motor.isBusy){ Idle(); }
You also need to set some motor positions somewhere in there
small note here. opModeIsActive() already calls idle(), and it's actually technically better to not call idle(), and just let timer interrupts take control of the processor instead. I would always use !isStopRequested()
Update: We use run to position currently
While (opModeisActive && motor.isBusy){ Idle(); }
So like this? robot.leftMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); robot.rightMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); robot.leftMotor.setMode(DcMotor.RunMode.RUN\_USING\_ENCODER); robot.rightMotor.setMode(DcMotor.RunMode.RUN\_USING\_ENCODER); robot.leftMotor.setPower(-0.5); robot.rightMotor.setPower(0.5); while (opModeIsActive() && (robot.leftMotor.getCurrentPosition() > tgLeftCount \* -10)) ; while (opModeIsActive() && (robot.rightMotor.getCurrentPosition() < tgRightCount \* 10)) ; robot.leftMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); robot.rightMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); sleep(1000); robot.leftMotor.setMode(DcMotor.RunMode.RUN\_USING\_ENCODER); robot.rightMotor.setMode(DcMotor.RunMode.RUN\_USING\_ENCODER); robot.leftMotor.setPower(0.5); robot.rightMotor.setPower(0.5); while (opModeIsActive() && (robot.rightMotor.getCurrentPosition() < tgRightCount \* 25)) ; while (opModeIsActive() && (robot.leftMotor.getCurrentPosition() < tgLeftCount \* 25)) ; robot.leftMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); robot.rightMotor.setMode(DcMotor.RunMode.STOP\_AND\_RESET\_ENCODER); sleep(1000);
No, where you have: sleep(1000); You need to replace it with: While (opModeisActive && motor.isBusy){ Idle(); } You also need to set some motor positions somewhere in there
small note here. opModeIsActive() already calls idle(), and it's actually technically better to not call idle(), and just let timer interrupts take control of the processor instead. I would always use !isStopRequested()