Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void leftRight(double power, double leftDist, double rightDist, int seconds) {
- int leftFrontDist, rightFrontDist, leftBackDist, rightBackDist;
- double correction;
- // if (opmode.opModeIsActive()) {
- int moveLeftTicks = (int) (leftDist * forwardTicks);
- int moveRightTicks = (int) (rightDist * forwardTicks);
- // DOES THIS DO ANYTHING
- /* robot.leftFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
- robot.rightFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
- robot.leftBack.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
- robot.rightBack.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); */
- leftFrontDist = robot.leftFront.getCurrentPosition() + moveLeftTicks;
- rightFrontDist = robot.rightFront.getCurrentPosition() + moveRightTicks;
- leftBackDist = robot.leftBack.getCurrentPosition() + moveLeftTicks;
- rightBackDist = robot.rightBack.getCurrentPosition() + moveRightTicks;
- setTarget(power, leftFrontDist, rightFrontDist, leftBackDist, rightBackDist);
- motionTimer.reset();
- // how long the motors should run
- while (opmode.opModeIsActive()&&(motionTimer.seconds() < seconds)
- && (robot.leftFront.isBusy()
- && robot.rightFront.isBusy()
- && robot.leftBack.isBusy()
- && robot.rightBack.isBusy())) {
- encoderData(leftFrontDist, rightFrontDist);
- opmode.telemetry.update();
- // find how much we should correct by
- // corrections
- robot.leftFront.setPower(power);
- robot.rightFront.setPower(power);
- robot.leftBack.setPower(power);
- robot.rightBack.setPower(power);
- }
- robot.stop();
- robot.setEncoders(true);
- opmode.sleep(stopTime);
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement