|
|
|
@ -34,9 +34,12 @@ import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
|
|
|
|
import com.qualcomm.robotcore.hardware.ColorSensor;
|
|
|
|
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
|
|
|
|
import com.qualcomm.robotcore.hardware.DcMotorSimple;
|
|
|
|
|
import com.qualcomm.robotcore.hardware.DistanceSensor;
|
|
|
|
|
import com.qualcomm.robotcore.hardware.Servo;
|
|
|
|
|
import com.qualcomm.robotcore.util.ElapsedTime;
|
|
|
|
|
|
|
|
|
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This file illustrates the concept of driving a path based on encoder counts.
|
|
|
|
|
* The code is structured as a LinearOpMode
|
|
|
|
@ -70,13 +73,14 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
/* Declare OpMode members. */
|
|
|
|
|
private DcMotor leftDrive = null;
|
|
|
|
|
private DcMotor rightDrive = null;
|
|
|
|
|
private DcMotor backRightDrive = null;
|
|
|
|
|
private DcMotor backLeftDrive = null;
|
|
|
|
|
private ColorSensor colorRight = null;
|
|
|
|
|
private ColorSensor colorLeft = null;
|
|
|
|
|
private DcMotor backrightDrive = null;
|
|
|
|
|
private DcMotor backleftDrive = null;
|
|
|
|
|
private DistanceSensor distanceRight = null;
|
|
|
|
|
private DistanceSensor distanceLeft = null;
|
|
|
|
|
private Servo wrist = null;
|
|
|
|
|
private Servo gripper = null;
|
|
|
|
|
private DcMotor arm = null;
|
|
|
|
|
private DistanceSensor distance = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ElapsedTime runtime = new ElapsedTime();
|
|
|
|
@ -112,8 +116,8 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
/* telemetry.addData("Starting at", "%7d :%7d",
|
|
|
|
|
leftDrive.getCurrentPosition(),
|
|
|
|
|
rightDrive.getCurrentPosition(),
|
|
|
|
|
backLeftDrive.getCurrentPosition(),
|
|
|
|
|
backRightDrive.getCurrentPosition());*/
|
|
|
|
|
backleftDrive.getCurrentPosition(),
|
|
|
|
|
backrightDrive.getCurrentPosition());*/
|
|
|
|
|
|
|
|
|
|
telemetry.update();
|
|
|
|
|
|
|
|
|
@ -137,8 +141,8 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
{
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
encoderDrive(DRIVE_SPEED, distance, distance, LONG_TIMEOUT); // S1: Forward 47 Inches with 5 Sec timeout
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -146,8 +150,8 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
{
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
encoderDrive(DRIVE_SPEED, distance, distance, LONG_TIMEOUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -155,8 +159,8 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
{
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
encoderDrive(DRIVE_SPEED, distance, distance, LONG_TIMEOUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -164,8 +168,8 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
{
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
double turning_distance = degrees * DEGREE_TOO_DISTANCE;
|
|
|
|
|
encoderDrive(DRIVE_SPEED, turning_distance, turning_distance, LONG_TIMEOUT);
|
|
|
|
|
}
|
|
|
|
@ -173,49 +177,29 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
public void turnRight(double degrees) {
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
double turning_distance = degrees * DEGREE_TOO_DISTANCE;
|
|
|
|
|
encoderDrive(DRIVE_SPEED, turning_distance, turning_distance, LONG_TIMEOUT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int readColorRight() {
|
|
|
|
|
telemetry.addData("Clear", colorRight.alpha());
|
|
|
|
|
telemetry.addData("Red ", colorRight.red());
|
|
|
|
|
telemetry.addData("Green", colorRight.green());
|
|
|
|
|
telemetry.addData("Blue ", colorRight.blue());
|
|
|
|
|
//telemetry.update();
|
|
|
|
|
int bluenumber = colorRight.red();
|
|
|
|
|
return bluenumber;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int readColorLeft() {
|
|
|
|
|
telemetry.addData("Clear Left", colorLeft.alpha());
|
|
|
|
|
telemetry.addData("Red left ", colorLeft.red());
|
|
|
|
|
telemetry.addData("Green left", colorLeft.green());
|
|
|
|
|
telemetry.addData("Blue left", colorLeft.blue());
|
|
|
|
|
//telemetry.update();
|
|
|
|
|
int bluenumber = colorLeft.red();
|
|
|
|
|
return bluenumber;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void raisearm(int degrees) {
|
|
|
|
|
armEncoder(ARM_SPEED, degrees*TICKS_TO_DEGREES, LONG_TIMEOUT);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void hardwareinit()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
leftDrive = hardwareMap.get(DcMotor.class, "Drive front lt");
|
|
|
|
|
rightDrive = hardwareMap.get(DcMotor.class, "Drive front rt");
|
|
|
|
|
backLeftDrive = hardwareMap.get(DcMotor.class, "Drive back lt");
|
|
|
|
|
backRightDrive = hardwareMap.get(DcMotor.class, "Drive back rt");
|
|
|
|
|
colorRight = hardwareMap.get(ColorSensor.class, "color right");
|
|
|
|
|
colorLeft = hardwareMap.get(ColorSensor.class, "color left");
|
|
|
|
|
backleftDrive = hardwareMap.get(DcMotor.class, "Drive back lt");
|
|
|
|
|
backrightDrive = hardwareMap.get(DcMotor.class, "Drive back rt");
|
|
|
|
|
distanceRight = hardwareMap.get(DistanceSensor.class, "color right");
|
|
|
|
|
distanceLeft = hardwareMap.get(DistanceSensor.class, "color left");
|
|
|
|
|
gripper = hardwareMap.get(Servo.class, "gripper");
|
|
|
|
|
arm = hardwareMap.get(DcMotor.class, "arm raise");
|
|
|
|
|
wrist = hardwareMap.get(Servo.class, "wrist");
|
|
|
|
|
distance = hardwareMap.get(DistanceSensor.class, "distance");
|
|
|
|
|
wrist.setPosition(1);
|
|
|
|
|
sleep(1000);
|
|
|
|
|
// To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
|
|
|
|
@ -223,21 +207,21 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
// Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
|
|
|
|
|
leftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
rightDrive.setDirection(DcMotor.Direction.FORWARD);
|
|
|
|
|
backRightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backLeftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backrightDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
backleftDrive.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
arm.setDirection(DcMotor.Direction.REVERSE);
|
|
|
|
|
|
|
|
|
|
leftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
rightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
backLeftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
backRightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
backleftDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
backrightDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backRightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backLeftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backrightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backleftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
}
|
|
|
|
|
public void testWrist()
|
|
|
|
@ -253,51 +237,54 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public void executeAuto()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
|
|
|
|
driveForward(26);
|
|
|
|
|
|
|
|
|
|
int distanceleft = (int)distanceLeft.getDistance(DistanceUnit.CM);
|
|
|
|
|
int distanceright = (int)distanceRight.getDistance(DistanceUnit.CM);
|
|
|
|
|
telemetry.addData("color left sensor",distanceleft);
|
|
|
|
|
telemetry.addData("color right sensor",distanceright);
|
|
|
|
|
telemetry.update();
|
|
|
|
|
sleep(500);
|
|
|
|
|
|
|
|
|
|
if (distanceleft < 30)
|
|
|
|
|
{
|
|
|
|
|
arm.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
|
|
|
|
driveForward(26);
|
|
|
|
|
int blueleft = readColorLeft();
|
|
|
|
|
int blueright = readColorRight();
|
|
|
|
|
// double backboard = 29; -- not used
|
|
|
|
|
if (blueleft > 50 )
|
|
|
|
|
{
|
|
|
|
|
//telemetry.addData("color sensor","left");
|
|
|
|
|
if(blueleft > blueright)
|
|
|
|
|
telemetry.addData("color sensor","left");
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(2);
|
|
|
|
|
driveForward(6.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-23);
|
|
|
|
|
straightLeft(32);
|
|
|
|
|
turnLeft(10);
|
|
|
|
|
driveForward(18);
|
|
|
|
|
driveForward(-40);
|
|
|
|
|
//telemetry.addData("color sensor","left");
|
|
|
|
|
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(2);
|
|
|
|
|
driveForward(6.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-23);
|
|
|
|
|
straightLeft(32);
|
|
|
|
|
turnLeft(10);
|
|
|
|
|
driveForward(18);
|
|
|
|
|
driveForward(-40);
|
|
|
|
|
// straightRight(31.5);
|
|
|
|
|
// raisearm(80);
|
|
|
|
|
// wrist.setPosition(0);
|
|
|
|
|
// raisearm(100);
|
|
|
|
|
// driveForward(-1);
|
|
|
|
|
// gripper.setPosition(0.25);
|
|
|
|
|
terminateOpModeNow();
|
|
|
|
|
terminateOpModeNow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (blueright > 50)
|
|
|
|
|
{
|
|
|
|
|
if(blueleft < blueright)
|
|
|
|
|
telemetry.addData("color sensor","right");
|
|
|
|
|
straightRight(11);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-15.5);
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(15);
|
|
|
|
|
driveForward(8);
|
|
|
|
|
driveForward(-38);
|
|
|
|
|
}
|
|
|
|
|
if (distanceright < 30)
|
|
|
|
|
{
|
|
|
|
|
straightRight(13.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-15.5);
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(15);
|
|
|
|
|
driveForward(8);
|
|
|
|
|
driveForward(-38);
|
|
|
|
|
// straightRight(14.5);
|
|
|
|
|
// raisearm(80);
|
|
|
|
|
// wrist.setPosition(0);
|
|
|
|
@ -305,41 +292,41 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
// gripper.setPosition(.25);
|
|
|
|
|
// driveForward(5);
|
|
|
|
|
// raisearm(-200);
|
|
|
|
|
terminateOpModeNow();
|
|
|
|
|
terminateOpModeNow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
telemetry.addData("position","center");
|
|
|
|
|
driveForward(2.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-8);
|
|
|
|
|
straightRight(11.5);
|
|
|
|
|
driveForward(-15);
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(15);
|
|
|
|
|
driveForward(8);
|
|
|
|
|
driveForward(-26);
|
|
|
|
|
straightRight(29);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
wrist.setPosition(0);
|
|
|
|
|
raisearm(100);
|
|
|
|
|
gripper.setPosition(.25);
|
|
|
|
|
sleep(500);
|
|
|
|
|
driveForward(5);
|
|
|
|
|
raisearm(-270);
|
|
|
|
|
telemetry.update();
|
|
|
|
|
sleep(250);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
driveForward(6.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
arm.setPower(0);
|
|
|
|
|
driveForward(-8);
|
|
|
|
|
straightRight(11.5);
|
|
|
|
|
driveForward(-15);
|
|
|
|
|
turnLeft(90);
|
|
|
|
|
straightLeft(15);
|
|
|
|
|
driveForward(8);
|
|
|
|
|
driveForward(-26);
|
|
|
|
|
straightRight(29);
|
|
|
|
|
driveForward(-1.5);
|
|
|
|
|
raisearm(80);
|
|
|
|
|
wrist.setPosition(0);
|
|
|
|
|
raisearm(100);
|
|
|
|
|
gripper.setPosition(.25);
|
|
|
|
|
sleep(500);
|
|
|
|
|
driveForward(5);
|
|
|
|
|
raisearm(-270);
|
|
|
|
|
telemetry.update();
|
|
|
|
|
sleep(250);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Values were created from robot with wheel issues 9/28/23
|
|
|
|
|
//Values were created from robot with wheel issues 9/28/23
|
|
|
|
|
|
|
|
|
|
telemetry.addData("Path", "Complete");
|
|
|
|
|
telemetry.update();
|
|
|
|
|
sleep(1000); // pause to display final telemetry message.
|
|
|
|
|
telemetry.addData("Path", "Complete");
|
|
|
|
|
telemetry.update();
|
|
|
|
|
sleep(1000); // pause to display final telemetry message.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -362,7 +349,7 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
int newLeftTarget;
|
|
|
|
|
int newRightTarget;
|
|
|
|
|
int newBackLeftTarget;
|
|
|
|
|
int newBackRightTarget;
|
|
|
|
|
int newbackRightTarget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opModeIsActive()) {
|
|
|
|
@ -370,25 +357,25 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
// Determine new target position, and pass to motor controller
|
|
|
|
|
newLeftTarget = leftDrive.getCurrentPosition() + (int) (leftInches * COUNTS_PER_INCH);
|
|
|
|
|
newRightTarget = rightDrive.getCurrentPosition() + (int) (rightInches * COUNTS_PER_INCH);
|
|
|
|
|
newBackLeftTarget = backLeftDrive.getCurrentPosition() + (int) (leftInches * COUNTS_PER_INCH);
|
|
|
|
|
newBackRightTarget = backRightDrive.getCurrentPosition() + (int) (rightInches * COUNTS_PER_INCH);
|
|
|
|
|
newBackLeftTarget = backleftDrive.getCurrentPosition() + (int) (leftInches * COUNTS_PER_INCH);
|
|
|
|
|
newbackRightTarget = backrightDrive.getCurrentPosition() + (int) (rightInches * COUNTS_PER_INCH);
|
|
|
|
|
leftDrive.setTargetPosition(newLeftTarget);
|
|
|
|
|
rightDrive.setTargetPosition(newRightTarget);
|
|
|
|
|
backRightDrive.setTargetPosition(newBackRightTarget);
|
|
|
|
|
backLeftDrive.setTargetPosition(newBackLeftTarget);
|
|
|
|
|
backrightDrive.setTargetPosition(newbackRightTarget);
|
|
|
|
|
backleftDrive.setTargetPosition(newBackLeftTarget);
|
|
|
|
|
|
|
|
|
|
// Turn On RUN_TO_POSITION
|
|
|
|
|
leftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
rightDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
backRightDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
backLeftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
backrightDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
backleftDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
|
|
|
|
|
|
// reset the timeout time and start motion.
|
|
|
|
|
runtime.reset();
|
|
|
|
|
leftDrive.setPower(Math.abs(speed));
|
|
|
|
|
rightDrive.setPower(Math.abs(speed));
|
|
|
|
|
backRightDrive.setPower(Math.abs(speed));
|
|
|
|
|
backLeftDrive.setPower(Math.abs(speed));
|
|
|
|
|
backrightDrive.setPower(Math.abs(speed));
|
|
|
|
|
backleftDrive.setPower(Math.abs(speed));
|
|
|
|
|
|
|
|
|
|
// keep looping while we are still active, and there is time left, and both motors are running.
|
|
|
|
|
// Note: We use (isBusy() && isBusy()) in the loop test, which means that when EITHER motor hits
|
|
|
|
@ -398,27 +385,27 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
// onto the next step, use (isBusy() || isBusy()) in the loop test.
|
|
|
|
|
while (opModeIsActive() &&
|
|
|
|
|
(runtime.seconds() < timeoutS) &&
|
|
|
|
|
(leftDrive.isBusy() && rightDrive.isBusy() && backLeftDrive.isBusy() && backRightDrive.isBusy())) {
|
|
|
|
|
(leftDrive.isBusy() && rightDrive.isBusy() && backleftDrive.isBusy() && backrightDrive.isBusy() && backrightDrive.isBusy())) {
|
|
|
|
|
|
|
|
|
|
// Display it for the driver.
|
|
|
|
|
telemetry.addData("Running to", " %7d :%7d", newLeftTarget, newRightTarget);
|
|
|
|
|
telemetry.addData("Currently at", " at %7d :%7d",
|
|
|
|
|
leftDrive.getCurrentPosition(), rightDrive.getCurrentPosition(), backRightDrive.getCurrentPosition(), backLeftDrive.getCurrentPosition());
|
|
|
|
|
leftDrive.getCurrentPosition(), rightDrive.getCurrentPosition(), backrightDrive.getCurrentPosition(), backleftDrive.getCurrentPosition());
|
|
|
|
|
telemetry.update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leftDrive.setPower(0);
|
|
|
|
|
rightDrive.setPower(0);
|
|
|
|
|
backRightDrive.setPower(0);
|
|
|
|
|
backLeftDrive.setPower(0);
|
|
|
|
|
backrightDrive.setPower(0);
|
|
|
|
|
backleftDrive.setPower(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Turn off RUN_TO_POSITION
|
|
|
|
|
leftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
rightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backLeftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backRightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backleftDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
backrightDrive.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
|
|
|
|
|
|
|
|
|
|
sleep(250); // optional pause after each move.
|
|
|
|
|
}
|
|
|
|
@ -426,14 +413,14 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
|
|
|
|
|
public void armEncoder(double speed,
|
|
|
|
|
double Inches, double timeoutS) {
|
|
|
|
|
int newArmTarget;
|
|
|
|
|
int newarmTarget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opModeIsActive()) {
|
|
|
|
|
|
|
|
|
|
// Determine new target position, and pass to motor controller
|
|
|
|
|
newArmTarget = arm.getCurrentPosition() + (int) (Inches * COUNTS_PER_ARM_INCH);
|
|
|
|
|
arm.setTargetPosition(newArmTarget);
|
|
|
|
|
newarmTarget = arm.getCurrentPosition() + (int) (Inches * COUNTS_PER_ARM_INCH);
|
|
|
|
|
arm.setTargetPosition(newarmTarget);
|
|
|
|
|
|
|
|
|
|
// Turn On RUN_TO_POSITION
|
|
|
|
|
arm.setMode(DcMotor.RunMode.RUN_TO_POSITION);
|
|
|
|
@ -453,7 +440,7 @@ public class Autonomoustest extends LinearOpMode {
|
|
|
|
|
(arm.isBusy())) {
|
|
|
|
|
|
|
|
|
|
// Display it for the driver.
|
|
|
|
|
telemetry.addData("Running to", " %7d", newArmTarget);
|
|
|
|
|
telemetry.addData("Running to", " %7d", newarmTarget);
|
|
|
|
|
telemetry.addData("Currently at", " at %7d",
|
|
|
|
|
arm.getCurrentPosition());
|
|
|
|
|
telemetry.update();
|
|
|
|
|