Added arm positioning override and new state, BUCKET

This commit is contained in:
2024-10-30 21:31:17 -07:00
parent e8d316baee
commit 8e99d1672e
2 changed files with 30 additions and 2 deletions

View File

@ -126,9 +126,18 @@ public class ArmTest extends LinearOpMode {
arm.switchState(); arm.switchState();
} }
if (currentGamepad1.left_bumper && !previousGamepad1.left_bumper) {
arm.setPosition(arm.getPosition() - .05);
}
if (currentGamepad1.right_bumper && !previousGamepad1.right_bumper) {
arm.setPosition(arm.getPosition() + .05);
}
// Show the elapsed game time and wheel power. // Show the elapsed game time and wheel power.
telemetry.addData("Status", "Run Time: " + runtime.toString()); telemetry.addData("Status", "Run Time: " + runtime.toString());
telemetry.addData("Arm State", arm.getState()); telemetry.addData("Arm State", arm.getState());
telemetry.addData("Arm Position", arm.getPosition());
telemetry.update(); telemetry.update();
} }
}} }}

View File

@ -2,6 +2,7 @@ package org.firstinspires.ftc.teamcode.subsystem;
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armEngage; import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armEngage;
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armPark; import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armPark;
import static org.firstinspires.ftc.teamcode.configs.RobotConstants.armBucket;
import com.qualcomm.robotcore.hardware.HardwareMap; import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.ServoImplEx; import com.qualcomm.robotcore.hardware.ServoImplEx;
@ -12,12 +13,12 @@ import org.firstinspires.ftc.teamcode.util.action.RunAction;
public class ArmSubsystem { public class ArmSubsystem {
public enum ArmState { public enum ArmState {
PARK, ENGAGE PARK, ENGAGE, BUCKET
} }
public ServoImplEx arm; public ServoImplEx arm;
public ArmState state; public ArmState state;
public RunAction engageArm, parkArm; public RunAction engageArm, parkArm, bucketArm;
public ArmSubsystem(HardwareMap hardwareMap, ArmState armState) { public ArmSubsystem(HardwareMap hardwareMap, ArmState armState) {
arm = hardwareMap.get(ServoImplEx.class, "arm-servo"); arm = hardwareMap.get(ServoImplEx.class, "arm-servo");
@ -27,6 +28,7 @@ public class ArmSubsystem {
parkArm = new RunAction(this::parkArm); parkArm = new RunAction(this::parkArm);
engageArm = new RunAction(this::engageArm); engageArm = new RunAction(this::engageArm);
bucketArm = new RunAction(this::bucketArm);
} }
public void setState(ArmState armState) { public void setState(ArmState armState) {
@ -36,6 +38,9 @@ public class ArmSubsystem {
} else if (armState == ArmState.PARK) { } else if (armState == ArmState.PARK) {
arm.setPosition(armPark); arm.setPosition(armPark);
this.state = ArmState.PARK; this.state = ArmState.PARK;
} else if (armState == ArmState.BUCKET) {
arm.setPosition(armBucket);
this.state = ArmState.BUCKET;
} }
} }
@ -47,10 +52,16 @@ public class ArmSubsystem {
setState(ArmState.PARK); setState(ArmState.PARK);
} }
public void bucketArm() {
setState(ArmState.BUCKET);
}
public void switchState() { public void switchState() {
if (state == ArmState.ENGAGE) { if (state == ArmState.ENGAGE) {
setState(ArmState.PARK); setState(ArmState.PARK);
} else if (state == ArmState.PARK) { } else if (state == ArmState.PARK) {
setState(ArmState.BUCKET);
} else if (state == ArmState.BUCKET) {
setState(ArmState.ENGAGE); setState(ArmState.ENGAGE);
} }
} }
@ -67,4 +78,12 @@ public class ArmSubsystem {
Actions.runBlocking(parkArm); Actions.runBlocking(parkArm);
} }
public double getPosition() {
return this.arm.getPosition();
}
public void setPosition(double position) {
this.arm.setPosition(position);
}
} }