jules_TeamTulip
31-03-2016, 03:25
I want to set the power of the motor's to zero when they reaches their target. But now they are stopping but they are still busy. And the encoders aren't resetting.
This is my code, it's in opMode
if (gamepad1.b) { int targetPosition = 0; motorLeft.setMode(DcMotorController.RunMode.RUN_US ING_ENCODERS); motorRight.setMode(DcMotorController.RunMode.RUN_U SING_ENCODERS);
motorLeft.setMode(DcMotorController.RunMode.RESET_ ENCODERS);
motorRight.setMode(DcMotorController.RunMode.RESET _ENCODERS);
//while (motorLeft.getCurrentPosition() != 0){
//}
motorLeft.setTargetPosition(targetPosition);
motorRight.setTargetPosition(targetPosition);
motorRight.setMode(DcMotorController.RunMode.RUN_T O_POSITION);
motorLeft.setMode(DcMotorController.RunMode.RUN_TO _POSITION);
//if (motorLeft.getCurrentPosition() != targetPosition) {
motorLeft.setPower(-0.5);
motorRight.setPower(-0.5);
//}
//motorLeft.setPower(0);
//motorRight.setPower(0);
}
This is my code, it's in opMode
if (gamepad1.b) { int targetPosition = 0; motorLeft.setMode(DcMotorController.RunMode.RUN_US ING_ENCODERS); motorRight.setMode(DcMotorController.RunMode.RUN_U SING_ENCODERS);
motorLeft.setMode(DcMotorController.RunMode.RESET_ ENCODERS);
motorRight.setMode(DcMotorController.RunMode.RESET _ENCODERS);
//while (motorLeft.getCurrentPosition() != 0){
//}
motorLeft.setTargetPosition(targetPosition);
motorRight.setTargetPosition(targetPosition);
motorRight.setMode(DcMotorController.RunMode.RUN_T O_POSITION);
motorLeft.setMode(DcMotorController.RunMode.RUN_TO _POSITION);
//if (motorLeft.getCurrentPosition() != targetPosition) {
motorLeft.setPower(-0.5);
motorRight.setPower(-0.5);
//}
//motorLeft.setPower(0);
//motorRight.setPower(0);
}