Skip to content

Commit 3355f90

Browse files
committed
2 parents 7ebdf2a + fa8494f commit 3355f90

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/main/java/frc/trigon/robot/commands/commandfactories/CoralPlacingCommands.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
import frc.trigon.robot.constants.FieldConstants;
1111
import frc.trigon.robot.constants.OperatorConstants;
1212
import frc.trigon.robot.misc.ReefChooser;
13+
import frc.trigon.robot.subsystems.armelevator.ArmElevatorCommands;
1314
import frc.trigon.robot.subsystems.armelevator.ArmElevatorConstants;
1415
import frc.trigon.robot.subsystems.endeffector.EndEffectorCommands;
1516
import frc.trigon.robot.subsystems.endeffector.EndEffectorConstants;
1617
import frc.trigon.robot.subsystems.swerve.SwerveCommands;
1718
import lib.utilities.flippable.FlippablePose2d;
1819
import lib.utilities.flippable.FlippableTranslation2d;
19-
import org.littletonrobotics.junction.AutoLogOutput;
2020

2121
public class CoralPlacingCommands {
2222
public static boolean SHOULD_SCORE_AUTONOMOUSLY = true;
@@ -79,8 +79,9 @@ private static Command getAutonomousDriveToNoHitReefPose(boolean shouldScoreRigh
7979
}
8080

8181
private static Command getPrepareArmElevatorIfWontHitReef(boolean shouldScoreRight) {
82-
return GeneralCommands.runWhen(
82+
return GeneralCommands.getContinuousConditionalCommand(
8383
GeneralCommands.getFlippableOverridableArmCommand(REEF_CHOOSER::getArmElevatorState, true, CoralPlacingCommands::shouldReverseScore),
84+
ArmElevatorCommands.getStayInPlaceCommand(),
8485
() -> CoralPlacingCommands.isPrepareArmAngleAboveCurrentArmAngle() || calculateDistanceToTargetScoringPose(shouldScoreRight) > FieldConstants.SAFE_DISTANCE_FROM_SCORING_POSE_METERS
8586
);
8687
}

src/main/java/frc/trigon/robot/constants/FieldConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class FieldConstants {
3232
REEF_CENTER_TO_TARGET_SCORING_POSITION_Y_TRANSFORM_METERS = 0.17,
3333
REEF_CENTER_TO_TARGET_ALGAE_COLLECTION_POSITION_X_TRANSFORM_METERS = 1.6,
3434
REEF_CENTER_TO_TARGET_NO_HIT_REEF_POSITION_X_TRANSFORM_METERS = REEF_CENTER_TO_TARGET_SCORING_POSITION_X_TRANSFORM_METERS + 0.2;
35-
public static final double SAFE_DISTANCE_FROM_SCORING_POSE_METERS = 0.17;
35+
public static final double SAFE_DISTANCE_FROM_SCORING_POSE_METERS = 0.15;
3636

3737
private static final boolean SHOULD_USE_HOME_TAG_LAYOUT = false;
3838
public static final AprilTagFieldLayout APRIL_TAG_FIELD_LAYOUT = createAprilTagFieldLayout();

src/main/java/frc/trigon/robot/subsystems/armelevator/ArmElevatorCommands.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,21 @@ public static Command resetElevatorPositionCommand() {
4444
return new ParallelCommandGroup(
4545
new ExecuteEndCommand(
4646
() -> RobotContainer.ARM_ELEVATOR.setTargetArmState(ArmElevatorConstants.ArmElevatorState.ZERO_ELEVATOR, false),
47-
() -> {}
47+
() -> {
48+
}
4849
).until(() -> RobotContainer.ARM_ELEVATOR.atState(ArmElevatorConstants.ArmElevatorState.ZERO_ELEVATOR)),
4950
new ExecuteEndCommand(
5051
() -> RobotContainer.ARM_ELEVATOR.setElevatorVoltage(OperatorConstants.DRIVER_CONTROLLER.getRightY() * 2),
51-
() -> {},
52+
() -> {
53+
},
5254
RobotContainer.ARM_ELEVATOR
5355
),
5456
SwerveCommands.getOpenLoopFieldRelativeDriveCommand(() -> 0, () -> 0, () -> 0),
5557
EndEffectorCommands.getSetTargetStateCommand(EndEffectorConstants.EndEffectorState.EJECT)
56-
).finallyDo(() -> {RobotContainer.ARM_ELEVATOR.resetElevatorPosition(); RobotContainer.END_EFFECTOR.setTargetState(EndEffectorConstants.EndEffectorState.REST);});
58+
).finallyDo(() -> {
59+
RobotContainer.ARM_ELEVATOR.resetElevatorPosition();
60+
RobotContainer.END_EFFECTOR.setTargetState(EndEffectorConstants.EndEffectorState.REST);
61+
});
5762
}
5863

5964
public static Command getSetTargetStateCommand(ArmElevatorConstants.ArmElevatorState targetState) {
@@ -77,6 +82,17 @@ public static Command getSetTargetStateCommand(Supplier<ArmElevatorConstants.Arm
7782
);
7883
}
7984

85+
public static Command getStayInPlaceCommand() {
86+
return new ExecuteEndCommand(
87+
() -> {
88+
RobotContainer.ARM_ELEVATOR.setTargetArmAngle(RobotContainer.ARM_ELEVATOR.getCurrentArmAngle(), true);
89+
RobotContainer.ARM_ELEVATOR.setTargetElevatorPositionMeters(RobotContainer.ARM_ELEVATOR.getCurrentElevatorPositionMeters(), true);
90+
},
91+
RobotContainer.ARM_ELEVATOR::stop,
92+
RobotContainer.ARM_ELEVATOR
93+
);
94+
}
95+
8096
public static Command getPrepareForStateCommand(Supplier<ArmElevatorConstants.ArmElevatorState> targetState) {
8197
return getPrepareForStateCommand(targetState, () -> false);
8298
}

0 commit comments

Comments
 (0)