Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Try not to fry linear slides
Browse files Browse the repository at this point in the history
  • Loading branch information
Akachukwuegbosimba committed Jan 5, 2024
1 parent 832ea28 commit 82748c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 8 additions & 6 deletions TeleOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.util.ElapsedTime;

import org.firstinspires.ftc.teamcode.modules.DriveTrain;
import org.firstinspires.ftc.teamcode.modules.output.LinearSlide;
import org.firstinspires.ftc.teamcode.modules.output.MotorOutputPivot;
Expand All @@ -16,7 +17,7 @@
public class TeleOp extends LinearOpMode {
// Define attributes
private final String programVer = "2.0";
private final double speedMultiplier = 0.95;
private final double speedMultiplier = 0.99;

// Declare modules
private ButtonHelper gp1, gp2;
Expand Down Expand Up @@ -73,8 +74,9 @@ public void runOpMode() {
waitForStart();

while (opModeIsActive()) {
TelemetryWrapper.setLine(2, "LeftSlidePos" + outputSlide.getCurrentPosition()[0]);
TelemetryWrapper.setLine(3, "RightSlidePos" + outputSlide.getCurrentPosition()[1]);
TelemetryWrapper.setLine(2, "Output Box Lock State " + currentLockState);
TelemetryWrapper.setLine(3, "LeftSlidePos" + outputSlide.getCurrentPosition()[0]);
TelemetryWrapper.setLine(4, "RightSlidePos" + outputSlide.getCurrentPosition()[1]);
// Update ButtonHelper
gp1.update();
gp2.update();
Expand All @@ -85,7 +87,7 @@ public void runOpMode() {
intakeWheel.setPower((gamepad2.right_trigger - gamepad2.left_trigger) * 0.8);

if (Math.abs(gamepad2.left_stick_y) > 0.001) {
outputSlide.startMoveToRelativePos((int) (-gamepad2.left_stick_y * 100));
outputSlide.startMoveToRelativePos((int) -gamepad2.left_stick_y * 100);
}
if (gp2.pressing(ButtonHelper.b)) {
outputSlide.startMoveToPos(1430);
Expand All @@ -105,7 +107,7 @@ public void runOpMode() {
} else if (servoOutputPivot.isFinished()) {
servoOutputPivot.setPower(0);
}
if (gp2.pressed(ButtonHelper.dpad_up)){
if (gp2.pressed(ButtonHelper.dpad_up)) {
servoOutputPivot.togglePivot();
}
servoOutputPivot.tick();
Expand All @@ -126,7 +128,7 @@ public void runOpMode() {
secondPixel.setAction(lockStates[currentLockState][1]);
}

if (gp2.pressing(ButtonHelper.x)){
if (gp2.pressing(ButtonHelper.x)) {
planeLaunch.toggleAction();
}
}
Expand Down
6 changes: 2 additions & 4 deletions modules/output/LinearSlide.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.TouchSensor;
import com.qualcomm.robotcore.util.Statistics;

import org.firstinspires.ftc.robotcore.external.navigation.CurrentUnit;
import org.firstinspires.ftc.teamcode.modules.Modulable;
Expand Down Expand Up @@ -56,7 +54,7 @@ public void moveUsingEncoder(double power) {
}

public void startMoveToRelativePos(int relativePosition) {
startMoveToPos((elevatorLeft.getCurrentPosition() + elevatorRight.getCurrentPosition()) / 2 + relativePosition);
startMoveToPos(Math.max((elevatorLeft.getCurrentPosition() + elevatorRight.getCurrentPosition()) / 2 + relativePosition, 10));
}

public void startMoveToPos(int position) {
Expand All @@ -75,7 +73,7 @@ public void startMoveToPos(int position) {
* YOU MUST call {@link #tick()} in a loop to stop the intakeSlide when it reaches the ground.
*/
public void startRetraction() {
startMoveToPos(0);
startMoveToPos(10);
}

/**
Expand Down

0 comments on commit 82748c2

Please sign in to comment.