Competition day things
This commit is contained in:
parent
b74d5a38dd
commit
3076e0b8b7
|
@ -3,21 +3,30 @@ package org.firstinspires.ftc.teamcode.createdcode.enhancedautos;
|
|||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.hardware.ColorSensor;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
|
||||
@Autonomous
|
||||
public class AutoBlueColorSensor extends LinearOpMode {
|
||||
@Override
|
||||
public void runOpMode() throws InterruptedException {
|
||||
ColorSensor sensor = hardwareMap.get(ColorSensor.class, "color2");
|
||||
ColorSensor sensor = hardwareMap.get(ColorSensor.class, "color");
|
||||
API api = new API(this);
|
||||
MovementAPI movementAPI = new MovementAPI(api);
|
||||
DcMotor motorLiftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
|
||||
DcMotor motorLiftRight = hardwareMap.get(DcMotor.class, "liftRight");
|
||||
|
||||
waitForStart();
|
||||
|
||||
// motorLiftLeft.setPower(1);
|
||||
// motorLiftRight.setPower(1);
|
||||
// api.pause(0.1);
|
||||
// motorLiftLeft.setPower(0);
|
||||
// motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.4);
|
||||
movementAPI.move(90, 0.7);
|
||||
api.pause(0.05);
|
||||
// movementAPI.move(90, 0.7);
|
||||
// api.pause(0.15);
|
||||
movementAPI.stop();
|
||||
|
||||
api.pause(5);
|
||||
|
@ -26,14 +35,14 @@ public class AutoBlueColorSensor extends LinearOpMode {
|
|||
int b = sensor.blue();
|
||||
|
||||
// move back to start position
|
||||
movementAPI.move(-90, 0.7);
|
||||
api.pause(0.05);
|
||||
// movementAPI.move(-90, 0.7);
|
||||
// api.pause(0.05);
|
||||
movementAPI.move(-180, 0.7);
|
||||
api.pause(0.75);
|
||||
|
||||
if (r < 100 && g < 100 && b < 100) {
|
||||
movementAPI.move(90, 0.7);
|
||||
api.pause(0.7);
|
||||
api.pause(1);
|
||||
movementAPI.stop();
|
||||
|
||||
terminateOpModeNow();
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.firstinspires.ftc.teamcode.createdcode.enhancedautos;
|
|||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.hardware.ColorSensor;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
|
||||
@Autonomous
|
||||
public class AutoRedColorSensor extends LinearOpMode {
|
||||
|
@ -11,13 +12,21 @@ public class AutoRedColorSensor extends LinearOpMode {
|
|||
ColorSensor sensor = hardwareMap.get(ColorSensor.class, "color");
|
||||
API api = new API(this);
|
||||
MovementAPI movementAPI = new MovementAPI(api);
|
||||
DcMotor motorLiftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
|
||||
DcMotor motorLiftRight = hardwareMap.get(DcMotor.class, "liftRight");
|
||||
|
||||
waitForStart();
|
||||
|
||||
// motorLiftLeft.setPower(1);
|
||||
// motorLiftRight.setPower(1);
|
||||
// api.pause(0.1);
|
||||
// motorLiftLeft.setPower(0);
|
||||
// motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.4);
|
||||
movementAPI.move(-90, 0.7);
|
||||
api.pause(0.05);
|
||||
// movementAPI.move(-90, 0.7);
|
||||
// api.pause(0.05);
|
||||
movementAPI.stop();
|
||||
|
||||
api.pause(5);
|
||||
|
@ -26,8 +35,8 @@ public class AutoRedColorSensor extends LinearOpMode {
|
|||
int b = sensor.blue();
|
||||
|
||||
// move back to start position
|
||||
movementAPI.move(90, 0.7);
|
||||
api.pause(0.05);
|
||||
// movementAPI.move(90, 0.7);
|
||||
// api.pause(0.05);
|
||||
movementAPI.move(-180, 0.7);
|
||||
api.pause(0.75);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ public class ColorSensorTest extends LinearOpMode {
|
|||
api.print("r:", String.valueOf(sensor.red()));
|
||||
api.print("g:", String.valueOf(sensor.green()));
|
||||
api.print("b:", String.valueOf(sensor.blue()));
|
||||
telemetry.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
package org.firstinspires.ftc.teamcode.createdcode.enhancedautos;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.hardware.ColorSensor;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
import com.qualcomm.robotcore.hardware.Servo;
|
||||
|
||||
@Autonomous
|
||||
public class PlaceConeColorSensorBlue extends LinearOpMode {
|
||||
@Override
|
||||
public void runOpMode() {
|
||||
ColorSensor sensor = hardwareMap.get(ColorSensor.class, "color");
|
||||
API api = new API(this);
|
||||
MovementAPI movementAPI = new MovementAPI(api);
|
||||
DcMotor motorLiftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
|
||||
DcMotor motorLiftRight = hardwareMap.get(DcMotor.class, "liftRight");
|
||||
Servo claw = hardwareMap.get(Servo.class, "claw");
|
||||
claw.setPosition(0);
|
||||
|
||||
waitForStart();
|
||||
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(0, 0.5);
|
||||
api.pause(0.1);
|
||||
movementAPI.stop();
|
||||
|
||||
motorLiftLeft.setPower(-1);
|
||||
motorLiftRight.setPower(-1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
api.pause(2);
|
||||
|
||||
claw.setPosition(1);
|
||||
api.pause(5);
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(180, 0.5);
|
||||
api.pause(0.5);
|
||||
movementAPI.move(-90, 0.5);
|
||||
api.pause(0.5);
|
||||
movementAPI.stop();
|
||||
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.4);
|
||||
// movementAPI.move(90, 0.7);
|
||||
// api.pause(0.15);
|
||||
movementAPI.stop();
|
||||
|
||||
api.pause(5);
|
||||
int r = sensor.red();
|
||||
int g = sensor.green();
|
||||
int b = sensor.blue();
|
||||
|
||||
// move back to start position
|
||||
// movementAPI.move(-90, 0.7);
|
||||
// api.pause(0.05);
|
||||
movementAPI.move(-180, 0.7);
|
||||
api.pause(0.75);
|
||||
|
||||
if (r < 100 && g < 100 && b < 100) {
|
||||
movementAPI.move(90, 0.7);
|
||||
api.pause(1);
|
||||
movementAPI.stop();
|
||||
|
||||
terminateOpModeNow();
|
||||
}
|
||||
|
||||
int largest = api.getLargest(r, g, b);
|
||||
|
||||
api.print("r", String.valueOf(r));
|
||||
api.print("g", String.valueOf(g));
|
||||
api.print("b", String.valueOf(b));
|
||||
|
||||
if (largest == g) {
|
||||
// move to position 1
|
||||
movementAPI.move(90, 0.7);
|
||||
api.pause(0.75);
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.75);
|
||||
} else if (largest == r) {
|
||||
// move to position 2
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.75);
|
||||
} else if (largest == b) {
|
||||
// move to position 3
|
||||
movementAPI.move(-90, 0.7);
|
||||
api.pause(0.75);
|
||||
movementAPI.move(0, 0.7);
|
||||
api.pause(0.75);
|
||||
}
|
||||
|
||||
movementAPI.stop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.firstinspires.ftc.teamcode.createdcode.enhancedautos;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
import com.qualcomm.robotcore.hardware.Servo;
|
||||
|
||||
@Autonomous
|
||||
public class PlaceConeLeft extends LinearOpMode {
|
||||
@Override
|
||||
public void runOpMode() {
|
||||
API api = new API(this);
|
||||
MovementAPI movementAPI = new MovementAPI(api);
|
||||
DcMotor motorLiftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
|
||||
DcMotor motorLiftRight = hardwareMap.get(DcMotor.class, "liftRight");
|
||||
Servo claw = hardwareMap.get(Servo.class, "claw");
|
||||
claw.setPosition(0);
|
||||
|
||||
waitForStart();
|
||||
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
api.pause(1);
|
||||
|
||||
movementAPI.move(-90, 0.25);
|
||||
api.pause(1);
|
||||
movementAPI.stop();
|
||||
|
||||
movementAPI.move(0, 0.5);
|
||||
api.pause(0.1);
|
||||
movementAPI.stop();
|
||||
api.pause(1);
|
||||
|
||||
motorLiftLeft.setPower(-1);
|
||||
motorLiftRight.setPower(-1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
api.pause(2);
|
||||
|
||||
claw.setPosition(1);
|
||||
api.pause(5);
|
||||
movementAPI.move(180, 0.5);
|
||||
api.pause(0.5);
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(-90, 0.5);
|
||||
api.pause(0.75);
|
||||
movementAPI.stop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package org.firstinspires.ftc.teamcode.createdcode.enhancedautos;
|
||||
|
||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||
import com.qualcomm.robotcore.hardware.Servo;
|
||||
|
||||
@Autonomous
|
||||
public class PlaceConeRight extends LinearOpMode {
|
||||
@Override
|
||||
public void runOpMode() {
|
||||
API api = new API(this);
|
||||
MovementAPI movementAPI = new MovementAPI(api);
|
||||
DcMotor motorLiftLeft = hardwareMap.get(DcMotor.class, "liftLeft");
|
||||
DcMotor motorLiftRight = hardwareMap.get(DcMotor.class, "liftRight");
|
||||
Servo claw = hardwareMap.get(Servo.class, "claw");
|
||||
claw.setPosition(0);
|
||||
|
||||
waitForStart();
|
||||
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
api.pause(1);
|
||||
|
||||
movementAPI.move(90, 0.25);
|
||||
api.pause(1);
|
||||
movementAPI.stop();
|
||||
|
||||
movementAPI.move(0, 0.5);
|
||||
api.pause(0.1);
|
||||
movementAPI.stop();
|
||||
api.pause(1);
|
||||
|
||||
motorLiftLeft.setPower(-1);
|
||||
motorLiftRight.setPower(-1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
api.pause(2);
|
||||
|
||||
claw.setPosition(1);
|
||||
api.pause(5);
|
||||
movementAPI.move(180, 0.5);
|
||||
api.pause(0.5);
|
||||
motorLiftLeft.setPower(1);
|
||||
motorLiftRight.setPower(1);
|
||||
api.pause(0.25);
|
||||
motorLiftLeft.setPower(0);
|
||||
motorLiftRight.setPower(0);
|
||||
|
||||
movementAPI.move(90, 0.5);
|
||||
api.pause(0.75);
|
||||
movementAPI.stop();
|
||||
}
|
||||
}
|
|
@ -17,8 +17,7 @@ public class DriveTeleOp extends OpMode {
|
|||
private DcMotor motorLiftRight;
|
||||
private double powerLift;
|
||||
private Servo claw;
|
||||
private double clawPos = 0;
|
||||
private double lastClawPos = 0;
|
||||
private double clawPos = 1;
|
||||
private double drive = 0, strafe = 0, turn = 0;
|
||||
private double speed = 1;
|
||||
private boolean last_left_bumper = false;
|
||||
|
@ -37,13 +36,14 @@ public class DriveTeleOp extends OpMode {
|
|||
drive = -1 * gamepad1.left_stick_y;
|
||||
strafe = gamepad1.left_stick_x;
|
||||
turn = gamepad1.right_stick_x;
|
||||
powerLift = -1 * gamepad2.left_stick_y;
|
||||
powerLift = -0.75 * gamepad2.left_stick_y;
|
||||
if (gamepad1.left_bumper && last_left_bumper != gamepad1.left_bumper) speed = Math.max(0.15, speed - 0.15);
|
||||
if (gamepad1.right_bumper && last_right_bumper != gamepad1.right_bumper) speed = Math.min(1, speed + 0.15);
|
||||
if (gamepad2.a && last_claw_control != gamepad2.a) clawPos = (clawPos == 0 ? 1 : 0);
|
||||
|
||||
last_left_bumper = gamepad1.left_bumper;
|
||||
last_right_bumper = gamepad1.right_bumper;
|
||||
last_claw_control = gamepad2.a;
|
||||
}
|
||||
|
||||
private void drive() {
|
||||
|
@ -70,12 +70,11 @@ public class DriveTeleOp extends OpMode {
|
|||
motorLiftRight.setPower(powerLift);
|
||||
|
||||
// TODO: keep / remove these lines based on empirical testing
|
||||
if (lastClawPos != clawPos) claw.setPosition(clawPos);
|
||||
|
||||
lastClawPos = clawPos;
|
||||
claw.setPosition(clawPos);
|
||||
|
||||
DecimalFormat df = new DecimalFormat("#%");
|
||||
telemetry.addData("speed", df.format(speed));
|
||||
telemetry.addData("clawPos", df.format(clawPos));
|
||||
telemetry.update();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue