forked from FIRST-Tech-Challenge/FtcRobotController
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/enums/Armposition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.firstinspires.ftc.teamcode.enums; | ||
|
||
public enum Armposition { | ||
Front, | ||
Back | ||
} |
62 changes: 62 additions & 0 deletions
62
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/subsystems/Arm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.firstinspires.ftc.teamcode.subsystems; | ||
|
||
import com.qualcomm.robotcore.hardware.DcMotor; | ||
|
||
import org.firstinspires.ftc.teamcode.RobotHardware; | ||
import org.firstinspires.ftc.teamcode.enums.Armposition; | ||
import org.firstinspires.ftc.teamcode.enums.LiftPosition; | ||
|
||
import java.security.PublicKey; | ||
|
||
public class Arm extends SubSystem { | ||
public Armposition armState; | ||
private RobotHardware robot; | ||
public boolean rightBumperPressed = false; | ||
public boolean leftBumperPressed = false; | ||
private final int ARM_FRONT = 0; | ||
private final int ARM_BACK = 384; | ||
|
||
private final double ARM_MAX_POWER = .7; | ||
private final int ARM_POSITION_TOLERANCE = 10; | ||
|
||
public Arm(RobotHardware robot) { | ||
this.robot = robot; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
armState = Armposition.Back; | ||
robot.armMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); | ||
robot.armMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
|
||
} | ||
|
||
@Override | ||
public void update() { | ||
switch (armState) { | ||
case Back: | ||
if (Math.abs(robot.armMotor.getCurrentPosition() - ARM_BACK) < ARM_POSITION_TOLERANCE) { | ||
if (leftBumperPressed) { | ||
robot.armMotor.setTargetPosition(ARM_BACK); | ||
robot.armMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION); | ||
robot.armMotor.setPower(ARM_MAX_POWER); | ||
armState = Armposition.Front; | ||
} | ||
} | ||
|
||
case Front: | ||
if (Math.abs(robot.armMotor.getCurrentPosition() - ARM_FRONT) < ARM_POSITION_TOLERANCE) { | ||
if (rightBumperPressed) { | ||
robot.armMotor.setTargetPosition(ARM_FRONT); | ||
robot.armMotor.setMode(DcMotor.RunMode.RUN_TO_POSITION); | ||
robot.armMotor.setPower(ARM_MAX_POWER); | ||
armState = Armposition.Back; | ||
} | ||
} | ||
} | ||
} | ||
} |