Skip to content

Commit

Permalink
Added claw & bucket code
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLillquist committed Nov 9, 2024
1 parent 66644c1 commit 74ceb68
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class RobotHardware {
public DcMotor rightBackDrive = null;

public Servo clawServo = null;
public Servo bucketServo = null;

public DcMotorEx liftMotor = null; //5203 series, 384.5 ppr - encoder resolution
//5204-08139 series, 3895.9 resolution, for other arm thing motor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.firstinspires.ftc.teamcode.enums;

public enum BucketPosition {
Up, Down
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

package org.firstinspires.ftc.teamcode.subsystems;

import org.firstinspires.ftc.teamcode.RobotHardware;
import org.firstinspires.ftc.teamcode.enums.ArmPosition;
import org.firstinspires.ftc.teamcode.enums.BucketPosition;
import org.firstinspires.ftc.teamcode.enums.ClawPosition;

public class Bucket extends SubSystem {

public BucketPosition bucketState;
private RobotHardware robot;
public boolean rightBumperPressed = false;
public boolean leftBumperPressed = false;
private final int BUCKET_DOWN = 0;
private final int BUCKET_UP = 90;

private final double BUCKET_MAX_POWER = .7;

public Bucket(RobotHardware robot) {
this.robot = robot;
}


@Override
public void init() {
bucketState = BucketPosition.Down;
robot.bucketServo.setPosition(0);


}

@Override
public void start() {

}

@Override
public void update() {
switch (bucketState) {
case Up:
if (leftBumperPressed) {
robot.bucketServo.setPosition(BUCKET_DOWN);
bucketState = BucketPosition.Down;
}
case Down:
if (rightBumperPressed) {
robot.bucketServo.setPosition(BUCKET_UP);
bucketState = BucketPosition.Up;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public void start() {

@Override
public void update() {

switch (clawState) {
case Close:
if (leftBumperPressed) {
robot.clawServo.setPosition(CLAW_CLOSED);
clawState = ClawPosition.Open;
}
case Open:
if (rightBumperPressed) {
robot.clawServo.setPosition(CLAW_OPEN);
clawState = ClawPosition.Close;
}
}
}
}
}

0 comments on commit 74ceb68

Please sign in to comment.