From c04bb7f198a40d8193a21d1f5b5fefc0414ea3e9 Mon Sep 17 00:00:00 2001 From: Jonathan Gassend <115192551+The-Arx@users.noreply.github.com> Date: Fri, 22 Nov 2024 22:24:49 -0800 Subject: [PATCH] everything working! --- .../java/com/team766/robot/rookie_bot/OI.java | 20 +++++++++++-------- .../robot/rookie_bot/mechanisms/Elevator.java | 13 +++++++----- .../robot/rookie_bot/mechanisms/Intake.java | 10 +++++++--- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/team766/robot/rookie_bot/OI.java b/src/main/java/com/team766/robot/rookie_bot/OI.java index 3dbd2510..7fffffce 100644 --- a/src/main/java/com/team766/robot/rookie_bot/OI.java +++ b/src/main/java/com/team766/robot/rookie_bot/OI.java @@ -36,19 +36,23 @@ public void run(final Context context) { Robot.drive.setArcadeDrivePower(joystick0.getAxis(1), joystick0.getAxis(0)); - if (joystick0.getButtonPressed(1)) { + if (joystick0.getButton(1)) { Robot.elevator.move(0.3); - } else if (joystick0.getButtonPressed(2)) { + } else if (joystick0.getButton(2)) { Robot.elevator.move(-0.3); - } else if (joystick0.getButtonReleased(1) || joystick0.getButtonReleased(1)) { + } + + if (joystick0.getButtonReleased(1) || joystick0.getButtonReleased(2)) { Robot.elevator.move(0); } - if (joystick0.getButtonPressed(3)) { - Robot.intake.setPowerBoth(0.3); - } else if (joystick0.getButtonPressed(4)) { - Robot.intake.setPowerBoth(-0.3); - } else if (joystick0.getButtonReleased(3) || joystick0.getButtonReleased(4)) { + if (joystick0.getButton(3)) { + Robot.intake.setPowerBoth(0.5); + } else if (joystick0.getButton(4)) { + Robot.intake.setPowerBoth(-0.5); + } + + if (joystick0.getButtonReleased(3) || joystick0.getButtonReleased(4)) { Robot.intake.setPowerBoth(0); } diff --git a/src/main/java/com/team766/robot/rookie_bot/mechanisms/Elevator.java b/src/main/java/com/team766/robot/rookie_bot/mechanisms/Elevator.java index dc9fa7b3..c049deeb 100644 --- a/src/main/java/com/team766/robot/rookie_bot/mechanisms/Elevator.java +++ b/src/main/java/com/team766/robot/rookie_bot/mechanisms/Elevator.java @@ -10,7 +10,7 @@ public class Elevator extends Mechanism{ private MotorController m_elevator; private EncoderReader m_elevatorEncoder; - private final double TOP_LIMIT = 400; + private final double TOP_LIMIT = -130; private final double BOTTOM_LIMIT = 0; @@ -22,8 +22,8 @@ public Elevator() { } public void move(double power) { - if (!((power > 0 && getElevatorDistance() > TOP_LIMIT) || (power < 0 && getElevatorDistance() < BOTTOM_LIMIT))) { - m_elevator.set(power); + if (!((power < 0 && (getElevatorDistance() < TOP_LIMIT)) || (power > 0 && (getElevatorDistance() > BOTTOM_LIMIT)))) { + m_elevator.set(-power); } else { m_elevator.set(0); } @@ -31,12 +31,15 @@ public void move(double power) { } public double getElevatorDistance(){ - return m_elevatorEncoder.getDistance(); + return m_elevator.getSensorPosition(); } public void resetEncoder(){ - m_elevatorEncoder.reset(); + m_elevator.setSensorPosition(0); } + public void run() { + log("elevator: " + getElevatorDistance()); + } } diff --git a/src/main/java/com/team766/robot/rookie_bot/mechanisms/Intake.java b/src/main/java/com/team766/robot/rookie_bot/mechanisms/Intake.java index d10afce8..51ec8e72 100644 --- a/src/main/java/com/team766/robot/rookie_bot/mechanisms/Intake.java +++ b/src/main/java/com/team766/robot/rookie_bot/mechanisms/Intake.java @@ -14,8 +14,8 @@ public class Intake extends Mechanism { private MotorController intakeChainLeft; private MotorController intakeChainRight; - private final double INNER_LIMIT = 20; - private final double OUTER_LIMIT = -400; + private final double INNER_LIMIT = 2; + private final double OUTER_LIMIT = -6; public Intake() { intakeChainLeft = RobotProvider.instance.getMotor("intake.ChainLeft"); @@ -45,6 +45,10 @@ public void setIntake(double leftPower, double rightPower) { public void setPowerBoth(double powerBoth) { setIntake(powerBoth, powerBoth); } - + public void run(){ + log("left: " + intakeChainLeft.getSensorPosition()); + log("right: " + intakeChainRight.getSensorPosition()); + + } }