Skip to content

Commit

Permalink
Elevator+trap testing to main (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
GalexY727 authored Feb 2, 2024
2 parents 612e9fa + 170dd1b commit cb45de7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
6 changes: 5 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ private void configureOperatorBindings() {
operator.povUp().toggleOnTrue(climb.povUpCommand(swerve::getPose));

operator.povDown().onTrue(climb.toBottomCommand());


operator.povLeft().onTrue(elevator.toBottomCommand());

operator.povRight().onTrue(pieceControl.placeTrapCommand());

operator.leftBumper()
.and(operator.rightBumper())
.onTrue(pieceControl.noteToShoot());
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/frc/robot/commands/PieceControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ public Command noteToTarget(BooleanSupplier toAmp) {
return shoot;
}

public Command goHomeElevator() {
return this.elevator.setPositionCommand(TrapConstants.RESET_POS);
public Command placeTrapCommand() {
return Commands.sequence(
elevator.toTopCommand(),
claw.placeCommand(),
Commands.waitSeconds(2));
}

}
22 changes: 17 additions & 5 deletions src/main/java/frc/robot/subsystems/elevator/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ public void configMotors() {
elevator.setPeriodicFramePeriod(PeriodicFrame.kStatus3, 65535);
elevator.setPeriodicFramePeriod(PeriodicFrame.kStatus5, 65535);
elevator.getEncoder().setPositionConversionFactor(TrapConstants.ELEVATOR_POSITION_CONVERSION_FACTOR);
elevator.setPID(
TrapConstants.TRAP_P,
TrapConstants.TRAP_I,
TrapConstants.TRAP_D,
TrapConstants.TRAP_ELEVATOR_MIN_OUTPUT, TrapConstants.TRAP_ELEVATOR_MAX_OUTPUT);
elevator.setPID(TrapConstants.TRAP_PID);
}

@Override
Expand Down Expand Up @@ -77,6 +73,22 @@ public Command setPositionCommand(double pos) {
.andThen(Commands.waitUntil(this.isAtTargetPosition()));
}

private void toTop() {
this.setPosition(TrapConstants.TRAP_PLACE_POS);
}

private void toBottom() {
this.setPosition(TrapConstants.RESET_POS);
}

public Command toBottomCommand() {
return runOnce(this::toBottom);
}

public Command toTopCommand() {
return runOnce(this::toTop);
}

public Command stop() {
return runOnce(() -> elevator.stopMotor());
}
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/frc/robot/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static final class TrapConstants {
public static final int CLAW_CAN_ID = 16;
public static final double ELEVATOR_DEADBAND = .3;
public static final double OUTTAKE_TIME = .2;
public static final double CLAW_POSITION_MULTIPLIER = 2;
public static final double CLAW_POSITION_MULTIPLIER = 1.83;


public static final int CLAW_CURRENT_LIMIT = 7;
Expand All @@ -176,17 +176,15 @@ public static final class TrapConstants {

public static final int ELEVATOR_MOTOR_CURRENT_LIMIT = 20; // amps

public static final double TRAP_P = 0.01;
public static final double TRAP_I = 0;
public static final double TRAP_D = 0;
public static final PIDConstants TRAP_PID = new PIDConstants(0.5, 0, 0);

// TODO: set these values
public static final double TRAP_POS = 0;
public static final double RESET_POS = 0;
public static final double INTAKE_TIME = 0;
public static final double CLAW_OUTTAKE = 0;
public static final double CLAW_INTAKE = 0;
public static final double TRAP_PLACE_POS = 0;
public static final double CLAW_OUTTAKE = -1;
public static final double CLAW_INTAKE = 1;
public static final double TRAP_PLACE_POS = 0.48;
public static final double AMP_PLACE_POS = 0.48;

public static final double CLAW_HAS_PIECE_UPPER_LIMIT = 0;
public static final double CLAW_HAS_PIECE_LOWER_LIMIT = -0.25;
Expand Down

0 comments on commit cb45de7

Please sign in to comment.