TPSrightTargetpublic void runOpMode() {
leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
rightmotor.setDirection(DcMotor.Direction.REVERSE);
leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
int leftTarget = (int)(610 * COUNTS_PER_MM);
int rightTarget = (int)(610 * COUNTS_PER_MM);
double TPS = (175/60) * COUNTS_PER_WHEEL_REV;
waitForStart();waitForStart();
leftmotor.setTargetPosition(leftTarget);
rightmotor.setTargetPosition(rightTarget);
leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
leftmotor.setVelocity(TPS);
rightmotor.setVelocity(TPS);
while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())){
}public class HelloRobot_Encoder extends LinearOpMode {
private DcMotorEx leftmotor;
private DcMotorEx rightmotor;public void runOpMode() {
leftmotor = hardwareMap.get(DcMotorEx.class, "leftmotor");
rightmotor = hardwareMap.get(DcMotorEx.class, "rightmotor");@Autonomous
public class HelloRobot_Encoder extends LinearOpMode {
private DcMotorEx leftmotor;
private DcMotorEx rightmotor;
static final double COUNTS_PER_MOTOR_REV = 28.0;
static final double DRIVE_GEAR_REDUCTION = 30.24;
static final double WHEEL_CIRCUMFERENCE_MM = 90.0 * 3.14;
static final double COUNTS_PER_WHEEL_REV = COUNTS_PER_MOTOR_REV * DRIVE_GEAR_REDUCTION;
static final double COUNTS_PER_MM = COUNTS_PER_WHEEL_REV / WHEEL_CIRCUMFERENCE_MM;
@Override
public void runOpMode() {
leftmotor = hardwareMap.get(DcMotorEx.class, "leftmotor");
rightmotor = hardwareMap.get(DcMotorEx.class, "rightmotor");
rightmotor.setDirection(DcMotor.Direction.REVERSE);
leftmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightmotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
int leftTarget = (int)(610 * COUNTS_PER_MM);
int rightTarget = (int)(610 * COUNTS_PER_MM);
double TPS = (175/ 60) * COUNTS_PER_WHEEL_REV;
waitForStart();
leftmotor.setTargetPosition(leftTarget);
rightmotor.setTargetPosition(rightTarget);
leftmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightmotor.setMode(DcMotor.RunMode.RUN_TO_POSITION);
leftmotor.setVelocity(TPS);
rightmotor.setVelocity(TPS);
while (opModeIsActive() && (leftmotor.isBusy() && rightmotor.isBusy())) {
}
}
}