Skip to content

Commit

Permalink
implement OOP based codriver controls
Browse files Browse the repository at this point in the history
  • Loading branch information
team6101 committed Mar 1, 2024
1 parent 8e38da2 commit 1f863d5
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 48 deletions.
62 changes: 19 additions & 43 deletions src/main/java/frc/robot/InputtedCoDriverControls.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package frc.robot;

import edu.wpi.first.wpilibj.XboxController;
import frc.robot.auton.AutonShoot;
import frc.robot.auton.ExtendArms;
import frc.robot.auton.RetractArms;
import frc.robot.RobotComponents.Climber;
import frc.robot.RobotComponents.Intake;
import frc.robot.RobotComponents.Shooter;

public class InputtedCoDriverControls {

Expand All @@ -14,51 +14,27 @@ public static void setCoDriverController(XboxController xboxController) {
}

public static void onEveryFrame() {
Robot.motors.getFeeder().stopMotor();
if (controller.getAButton()) {
Robot.motors.getFeeder().set(30);
if (controller.getAButtonPressed()) {
Shooter.startFeedMotors();
}
if (controller.getXButtonPressed()) {
shootIntoSpeaker();
if (controller.getXButton()) {
Shooter.startShooterMotors();
} else {
Shooter.stopShooterMotors();
}
Robot.motors.getIntake().stopMotor();

if (controller.getYButton()) {
doFloorIntake();
Intake.startFloorIntake();
} else {
Intake.stopFloorIntake();
}
Robot.motors.getLeftClimb().stopMotor();
Robot.motors.getRightClimb().stopMotor();

if (controller.getStartButton()) {
//extendArms();
Robot.motors.getLeftClimb().set(Constants.CLIMB_EXTENSION_SPEED);
Robot.motors.getRightClimb().set(Constants.CLIMB_EXTENSION_SPEED);
Climber.manualExtendArms();
} else if (controller.getBackButton()) {
Climber.manualRetractArms();
} else {
Climber.stopClimbMotors();
}
if (controller.getBackButton()) {
//retractArms();
Robot.motors.getLeftClimb().set(Constants.CLIMB_RETRACTION_SPEED);
Robot.motors.getRightClimb().set(Constants.CLIMB_RETRACTION_SPEED);
}
}

private static void doFloorIntake() {
Robot.motors.getIntake().set(.5);
//Robot.motors.getFeeder().set(.5);
}

private static void extendArms() {
Robot.getTeleopActionRunner().addActionToRun(new ExtendArms());
Robot.getTeleopActionRunner().removeActionsOfType(RetractArms.class);
}

private static void retractArms() {
Robot.getTeleopActionRunner().addActionToRun(new RetractArms());
Robot.getTeleopActionRunner().removeActionsOfType(ExtendArms.class);
}

private static void shootIntoSpeaker() {
Robot.getTeleopActionRunner().addActionToRun(new AutonShoot());
}

private static void dropIntoAmp() {
throw new UnsupportedOperationException("Unimplemented method 'dropIntoAmp'");
}
}
33 changes: 32 additions & 1 deletion src/main/java/frc/robot/RobotComponents/Climber.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
package frc.robot.RobotComponents;

public class Climber {}
import frc.robot.Constants;
import frc.robot.Robot;
import frc.robot.auton.ExtendArms;
import frc.robot.auton.RetractArms;

public class Climber {

private static void extendArms() {
Robot.getTeleopActionRunner().addActionToRun(new ExtendArms());
Robot.getTeleopActionRunner().removeActionsOfType(RetractArms.class);
}

private static void retractArms() {
Robot.getTeleopActionRunner().addActionToRun(new RetractArms());
Robot.getTeleopActionRunner().removeActionsOfType(ExtendArms.class);
}

public static void manualExtendArms() {
Robot.motors.getLeftClimb().set(Constants.CLIMB_EXTENSION_SPEED);
Robot.motors.getRightClimb().set(Constants.CLIMB_EXTENSION_SPEED);
}

public static void manualRetractArms() {
Robot.motors.getLeftClimb().set(Constants.CLIMB_RETRACTION_SPEED);
Robot.motors.getRightClimb().set(Constants.CLIMB_RETRACTION_SPEED);
}

public static void stopClimbMotors() {
Robot.motors.getLeftClimb().stopMotor();
Robot.motors.getRightClimb().stopMotor();
}
}
13 changes: 12 additions & 1 deletion src/main/java/frc/robot/RobotComponents/Intake.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
package frc.robot.RobotComponents;

public class Intake {}
import frc.robot.Robot;

public class Intake {

public static void startFloorIntake() {
Robot.motors.getIntake().set(.5);
}

public static void stopFloorIntake() {
Robot.motors.getIntake().stopMotor();
}
}
11 changes: 8 additions & 3 deletions src/main/java/frc/robot/RobotComponents/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@

import frc.robot.Constants;
import frc.robot.Robot;
import frc.robot.auton.AutonShoot;
import frc.robot.auton.AutonShooterFeed;

public class Shooter {

public void startShooterMotors() {
public static void startShooterMotors() {
Robot.motors.getLeftFlywheel().setVelocity(Constants.SHOOTING_VELOCITY);
Robot.motors.getRightFlywheel().setVelocity(Constants.SHOOTING_VELOCITY);
}

public void stopShooterMotors() {
public static void stopShooterMotors() {
Robot.motors.getLeftFlywheel().stopMotor();
Robot.motors.getRightFlywheel().stopMotor();
}

public void startFeedMotors() {
public static void startFeedMotors() {
Robot.getTeleopActionRunner().removeActionsOfType(AutonShooterFeed.class);
Robot.getTeleopActionRunner().addActionToRun(new AutonShooterFeed());
}

public static void autoShootIntoSpeaker() {
Robot.getTeleopActionRunner().addActionToRun(new AutonShoot());
}
}

0 comments on commit 1f863d5

Please sign in to comment.