Skip to content

Commit

Permalink
more consistent auto stow, faster wrist
Browse files Browse the repository at this point in the history
  • Loading branch information
JayK445 committed Nov 12, 2023
1 parent f10a25e commit 8a5e9f5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ public static final class Intake {
public static final double HOLD_CUBE_PERCENT = -0.2;

public static final double CONE_STATOR_LIMIT = 75;
public static final double CUBE_STATOR_LIMIT = 65;
public static final double CUBE_STATOR_LIMIT = 69;
public static final double GROUND_CUBE_STATOR_LIMIT = 60;

public static final class Ports {
public static final int INTAKE_MOTOR_PORT = CAN.at(18, "intake motor");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/GroundPickupCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GroundPickupCommand(
// Add your commands in the addCommands() call, e.g.

addCommands(
new IntakeModeCommand(intakeSubsystem, Modes.INTAKE, isCone)
new IntakeModeCommand(intakeSubsystem, Modes.INTAKE, isCone, true)
.deadlineWith(new GroundIntakeElevatorCommand(elevatorSubsystem, isCone))
.andThen(
new ElevatorPositionCommand(elevatorSubsystem, () -> Elevator.Setpoints.STOWED)));
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/frc/robot/commands/IntakeModeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants.Intake;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.IntakeSubsystem.Modes;
import java.util.function.BooleanSupplier;
Expand All @@ -13,16 +14,22 @@ public class IntakeModeCommand extends CommandBase {
private IntakeSubsystem intakeSubsystem;
private Modes mode;
private BooleanSupplier isCone;
private boolean isGroundIntake;

/** Creates a new IntakeCommand. */
public IntakeModeCommand(IntakeSubsystem intakeSubsystem, Modes mode, BooleanSupplier isCone) {
public IntakeModeCommand(IntakeSubsystem intakeSubsystem, Modes mode, BooleanSupplier isCone, boolean isGroundIntake) {
// Use addRequirements() here to declare subsystem dependencies.
this.intakeSubsystem = intakeSubsystem;
this.mode = mode;
this.isCone = isCone;
this.isGroundIntake = isGroundIntake;
addRequirements(intakeSubsystem);
}

public IntakeModeCommand(IntakeSubsystem intakeSubsystem, Modes mode, BooleanSupplier isCone) {
this(intakeSubsystem, mode, isCone, false);
}

public IntakeModeCommand(IntakeSubsystem intakeSubsystem, Modes mode) {
// Use addRequirements() here to declare subsystem dependencies.
this.intakeSubsystem = intakeSubsystem;
Expand Down Expand Up @@ -53,8 +60,14 @@ public void end(boolean interrupted) {}
// Returns true when the command should end.
@Override
public boolean isFinished() {
if (intakeSubsystem.getMode() == Modes.HOLD || intakeSubsystem.getMode() == Modes.OFF) {
return true;
if(!isGroundIntake) {
if (intakeSubsystem.getMode() == Modes.HOLD || intakeSubsystem.getMode() == Modes.OFF) {
return true;
}
} else {
if(intakeSubsystem.getFilterOutput() > Intake.GROUND_CUBE_STATOR_LIMIT) {
return true;
}
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void positionDrivePeriodic() {
} else {
wristMotor.set(
TalonFXControlMode.PercentOutput,
MathUtil.clamp(wristController.calculate(currentWristAngle, targetAngle), -0.5, 0.5));
MathUtil.clamp(wristController.calculate(currentWristAngle, targetAngle), -1, 1));
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ public void setIsCone(boolean isCone) {
this.isCone = isCone;
}

public double getFilterOutput() {
return filterOutput;
}

private double getFilterCalculatedValue() {
return filter.calculate(intakeMotor.getStatorCurrent());
}
Expand Down

0 comments on commit 8a5e9f5

Please sign in to comment.