Skip to content

Commit a577ccc

Browse files
authored
Lift after floor intaking (#124)
* double voltage setpoint for holding algae * restore missing event binding * raise to processor height after acquiring algae from floor * rotate algae wrist instead of lifting elevator; apply to all elevator states * restore hold-algae function to event binding * separate bindings * formatting
1 parent fa82027 commit a577ccc

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

src/main/java/frc/robot/Robot.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@
4343
import frc.robot.drivetrain.commands.DriveToPoseCommand;
4444
import frc.robot.drivetrain.commands.ZorroDriveCommand;
4545
import frc.robot.elevator.AlgaeRoller;
46+
import frc.robot.elevator.AlgaeWrist;
4647
import frc.robot.elevator.CoralRoller;
4748
import frc.robot.elevator.Elevator;
49+
import frc.robot.elevator.ElevatorConstants.AlgaeWristConstants.AlgaeWristState;
4850
import frc.robot.elevator.Lifter;
4951
import frc.robot.vision.Vision;
5052
import frc.util.Gamepiece;
@@ -65,6 +67,7 @@ public class Robot extends TimedRobot {
6567
private final Lifter lifter = elevator.getLifter();
6668
private final CoralRoller coralRoller = elevator.getCoralRoller();
6769
private final AlgaeRoller algaeRoller = elevator.getAlgaeRoller();
70+
private final AlgaeWrist algaeWrist = elevator.getAlgaeWrist();
6871

6972
private final Drivetrain swerve =
7073
new Drivetrain(allianceSelector::fieldRotated, lifter::getProportionOfMaxHeight);
@@ -298,8 +301,7 @@ public boolean getAsBoolean() {
298301
// Intake coral and algae
299302
operator.rightBumper()
300303
.whileTrue(algaeRoller.createIntakeCommand()
301-
.alongWith(coralRoller.createIntakeCommand())
302-
.andThen(new ConditionalCommand(algaeRoller.createHoldAlgaeCommand(), algaeRoller.createStopCommand(), algaeRoller.hasAlgae)));
304+
.alongWith(coralRoller.createIntakeCommand()));
303305

304306
// Force joystick operation of the elevator
305307
Trigger elevatorTriggerHigh = operator.axisGreaterThan(Axis.kLeftY.value, 0.9, loop).debounce(0.1);
@@ -313,7 +315,7 @@ public boolean getAsBoolean() {
313315

314316
operator.leftTrigger().onTrue(climber.createDeployCommand());
315317

316-
// Auto climbe to position
318+
// Auto climb to position
317319
operator.povUp().onTrue(climber.createRetractCommand());
318320

319321
// just for testing roller animation.
@@ -331,7 +333,10 @@ private void configureEventBindings() {
331333
.andThen(climber.lockRatchet())
332334
.andThen(climber.resetEncoder()));
333335

334-
algaeRoller.hasAlgae.whileTrue(algaeRoller.createHoldAlgaeCommand());
336+
algaeRoller.hasAlgae
337+
.whileTrue(algaeRoller.createHoldAlgaeCommand());
338+
algaeRoller.hasAlgae
339+
.onTrue(algaeWrist.createSetAngleCommand(AlgaeWristState.Barge));
335340
coralRoller.isRolling.whileTrue(createRollerAnimationCommand());
336341
}
337342

src/main/java/frc/robot/elevator/AlgaeWrist.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import frc.robot.Constants.RobotConstants;
2727
import frc.robot.elevator.ElevatorConstants.AlgaeWristConstants;
2828
import frc.robot.elevator.ElevatorConstants.AlgaeWristConstants.AlgaeWristState;
29+
import java.util.function.BooleanSupplier;
2930

3031
public class AlgaeWrist extends SubsystemBase {
3132

@@ -35,16 +36,19 @@ public class AlgaeWrist extends SubsystemBase {
3536

3637
private final ProfiledPIDController feedback =
3738
new ProfiledPIDController(
38-
AlgaeWristConstants.kP,
39+
AlgaeWristConstants.kPWithoutAlgae,
3940
AlgaeWristConstants.kI,
4041
AlgaeWristConstants.kD,
4142
AlgaeWristConstants.kConstraints);
4243
private final ArmFeedforward feedforward =
4344
new ArmFeedforward(AlgaeWristConstants.kS, AlgaeWristConstants.kG, AlgaeWristConstants.kV);
4445

4546
private AlgaeWristState targetState = AlgaeWristState.Initial;
47+
private BooleanSupplier hasAlgae;
48+
49+
public AlgaeWrist(BooleanSupplier hasAlgaeSupplier) {
50+
hasAlgae = hasAlgaeSupplier;
4651

47-
public AlgaeWrist() {
4852
// spotless:off
4953
config
5054
.inverted(false)
@@ -112,6 +116,12 @@ public void resetController() {
112116
}
113117

114118
private void control() {
119+
if (hasAlgae.getAsBoolean()) {
120+
feedback.setP(AlgaeWristConstants.kPWithAlgae);
121+
} else {
122+
feedback.setP(AlgaeWristConstants.kPWithoutAlgae);
123+
}
124+
115125
double currentPosition = encoder.getPosition();
116126
double offsetPosition =
117127
currentPosition + AlgaeWristConstants.kCenterOfGravityOffset.in(Radians);

src/main/java/frc/robot/elevator/Elevator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class Elevator {
1212
Lifter lifter = new Lifter();
1313
CoralWrist coralWrist = new CoralWrist();
1414
CoralRoller coralRoller = new CoralRoller();
15-
AlgaeWrist algaeWrist = new AlgaeWrist();
1615
AlgaeRoller algaeRoller = new AlgaeRoller();
16+
AlgaeWrist algaeWrist = new AlgaeWrist(algaeRoller.hasAlgae);
1717

1818
public Elevator() {}
1919

@@ -83,7 +83,7 @@ public Command coralIntakeCG() {
8383

8484
public Command algaeBargePositionCG() {
8585
return Commands.parallel(
86-
lifter.createSetHeightCommand(LifterState.Max),
86+
lifter.createSetHeightCommand(LifterState.AlgaeBarge),
8787
coralWrist.createSetAngleCommand(CoralWristState.AlgaeMode),
8888
algaeWrist.createSetAngleCommand(AlgaeWristState.Barge));
8989
}

src/main/java/frc/robot/elevator/ElevatorConstants.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ public static enum LifterState {
7373
CoralIntake(11.7),
7474
AlgaeProcessor(12.0),
7575
AlgaeL2(28),
76-
AlgaeL3(44.5),
77-
Max(67.8);
76+
AlgaeL3(43.5),
77+
AlgaeBarge(67.8),
78+
Max(68.3);
7879

7980
public Distance height;
8081

@@ -226,9 +227,10 @@ public static final class AlgaeWristConstants {
226227
public static final double kS = 0.15; // Found empirically 2/22/2025
227228
public static final double kV = (12.0 - kS) / maxArmVelocityTheoretical.in(RadiansPerSecond);
228229

229-
public static final double kP = 1.5;
230-
public static final double kI = 1.0;
231-
public static final double kD = 0.1;
230+
public static final double kPWithAlgae = 3.0;
231+
public static final double kPWithoutAlgae = 1.0;
232+
public static final double kI = 0;
233+
public static final double kD = 0;
232234
public static final Angle kIZone = Degrees.of(30.0);
233235

234236
public static enum AlgaeWristState {

src/main/java/frc/robot/elevator/Lifter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public Boolean inState(LifterState state) {
154154
}
155155

156156
public Trigger atIntakingHeight = new Trigger(() -> inState(LifterState.CoralIntake));
157+
public Trigger atFloorIntakingHeight = new Trigger(() -> inState(LifterState.AlgaeIntakeFloor));
157158
public Trigger tooHighForCoralWrist =
158159
new Trigger(() -> getCurrentHeight().gt(LifterState.CoralL3.height.plus(Inches.of(2.0))));
159160

0 commit comments

Comments
 (0)