Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Added toggle to intake
Browse files Browse the repository at this point in the history
  • Loading branch information
Picklze1 committed Jan 18, 2024
1 parent 63d8354 commit 67ff9bf
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.CRServo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Gamepad;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.util.Range;

Expand All @@ -20,6 +21,7 @@ public class TeleOp extends OpMode {
double turn;
double strafe;
double intakePower = 0.5;
boolean intakeToggle = false;
private final double armStartPos = 0.0;
private final double armTargetPos = 0.0;
private final double armTolerance = 2.5;
Expand All @@ -29,6 +31,12 @@ public class TeleOp extends OpMode {
private final double jointTargetPos = 0.0;
boolean scoringATM;

Gamepad currentGamepad1 = new Gamepad();
Gamepad currentGamepad2 = new Gamepad();

Gamepad previousGamepad1 = new Gamepad();
Gamepad previousGamepad2 = new Gamepad();

@Override
public void init() {
telemetry.addData("Status", "Initializing");
Expand All @@ -42,10 +50,10 @@ public void init() {
// Init CR Servos.
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "intakeGeckoWheels"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "intakeTube"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeJoint"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeTube1"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeTube2"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeJoint1"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeJoint2"));
robot.introduce(new HardwareElement<>(CRServo.class, hardwareMap, "outerIntakeTube"));

// Init DcMotors.
robot.introduce(new HardwareElement<>(DcMotor.class, hardwareMap, "leftFront", "setDirection:FORWARD"));
robot.introduce(new HardwareElement<>(DcMotor.class, hardwareMap, "leftRear", "setDirection:FORWARD"));
Expand Down Expand Up @@ -81,6 +89,8 @@ public void init() {
@Override
public void loop() {

gamepadUpdate();

// Values for drive.
drive = gamepad1.left_stick_y * 0.8;
turn = -gamepad1.right_stick_x * 0.6;
Expand Down Expand Up @@ -133,8 +143,12 @@ public void loop() {
robot.<CRServo>get("clawJoint").setPower(0);
}

if (currentGamepad1.a && !previousGamepad1.a) {
intakeToggle = !intakeToggle;
}

// Activating Intake via gamepad a.
if (gamepad1.a) {
if (intakeToggle) {
robot.<CRServo>get("intakeTube").setPower(0.5);
robot.<CRServo>get("intakeGeckoWheels").setPower(0.5);
robot.<CRServo>get("outerIntakeTube").setPower(0.5);
Expand All @@ -147,11 +161,14 @@ public void loop() {
}

if (gamepad1.right_bumper) {
robot.<CRServo>get("outerIntakeJoint").setPower(-0.25);
robot.<CRServo>get("outerIntakeJoint1").setPower(-0.25);
robot.<CRServo>get("outerIntakeJoint2").setPower(-0.25);
} else if (gamepad1.right_trigger > 0.5) {
robot.<CRServo>get("outerIntakeJoint").setPower(0.25);
robot.<CRServo>get("outerIntakeJoint1").setPower(0.25);
robot.<CRServo>get("outerIntakeJoint2").setPower(0.25);
} else {
robot.<CRServo>get("outerIntakeJoint").setPower(0);
robot.<CRServo>get("outerIntakeJoint1").setPower(0);
robot.<CRServo>get("outerIntakeJoint2").setPower(0);
}
}

Expand Down Expand Up @@ -252,6 +269,14 @@ public void runViperSlidesToPosition(double position, double power) {
}
}

public void gamepadUpdate() {
previousGamepad1.copy(currentGamepad1);
previousGamepad2.copy(currentGamepad2);

currentGamepad1.copy(gamepad1);
currentGamepad2.copy(gamepad2);
}

// Strafe Drive using sticks on Gamepad 1
public void driving() {
// Calculate drive power.
Expand Down
Binary file modified gradle/wrapper/caches/8.0/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/8.0/fileContent/fileContent.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/8.0/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/8.0/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified gradle/wrapper/caches/8.0/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified gradle/wrapper/caches/8.0/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/jars-9/jars-9.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/journal-1/file-access.bin
Binary file not shown.
Binary file modified gradle/wrapper/caches/journal-1/journal-1.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/modules-2/modules-2.lock
Binary file not shown.
Binary file modified gradle/wrapper/caches/transforms-3/transforms-3.lock
Binary file not shown.
Binary file modified gradle/wrapper/daemon/8.0/registry.bin
Binary file not shown.
Binary file modified gradle/wrapper/daemon/8.0/registry.bin.lock
Binary file not shown.

0 comments on commit 67ff9bf

Please sign in to comment.