Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ public static class RobotStateConstants {

public static final double C4_ELEVATOR_POS = 0.7043; // from 3/1
public static final double C4_ARM_POS = -3.211; // from 3/1

public static final double C4_FORWARD_ARM_POS = 2*Math.PI + C4_ARM_POS; // swing arm forward

public static final double C4_ELEVATOR_POS_WITH_CORAL = 0.7026; // from 3/1
public static final double C4_ARM_POS_WITH_CORAL = -3.2239; // from 3/1
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ public RobotContainer() {
NamedCommands.registerCommand("scoreL1Coral", createScoreCommand(m_lifter.moveToCommand(RobotState.L1_CORAL)));
NamedCommands.registerCommand("scoreL2Coral", createScoreCommand(m_lifter.moveToCommand(RobotState.L2_CORAL)));
NamedCommands.registerCommand("scoreL3Coral", createScoreCommand(m_lifter.moveToCommand(RobotState.L3_CORAL)));
NamedCommands.registerCommand("scoreL4Coral", createScoreCommand(m_lifter.moveToCommand(RobotState.L4_CORAL)));
NamedCommands.registerCommand("scoreL4Coral", createScoreCommand(m_lifter.moveToCommand(RobotState.L4_CORAL_FORWARD)));
NamedCommands.registerCommand("shootCoral", new ParallelRaceGroup(
new PIDToTargetCommand(drivetrain, () -> m_ppTargetPose),
Commands.sequence(
(new WaitCommand(1).until(m_lifter.isLifterAtGoal(RobotState.L4_CORAL.getArmPos(), RobotState.L4_CORAL.getElevatorPos()))),
(new WaitCommand(1).until(m_lifter.isLifterAtGoal(RobotState.L4_CORAL_FORWARD.getArmPos(), RobotState.L4_CORAL_FORWARD.getElevatorPos()))),
m_collarCommandFactory.runCollarOut().withTimeout(0.5).asProxy(),
m_collar.runCollarOffInstant().asProxy())));
NamedCommands.registerCommand("waitUntilCoralIntaken", new WaitCommand(2).until(m_rampSensor.coralSeenAfterRampTrigger()));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/frc/robot/RobotState.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum RobotState {
L3_CORAL(RobotStateConstants.C3_ELEVATOR_POS, RobotStateConstants.C3_ARM_POS),
L3_CORAL_WITH_CORAL(RobotStateConstants.C3_ELEVATOR_POS_WITH_CORAL, RobotStateConstants.C3_ARM_POS_WITH_CORAL),
L4_CORAL(RobotStateConstants.C4_ELEVATOR_POS, RobotStateConstants.C4_ARM_POS),
L4_CORAL_FORWARD(RobotStateConstants.C4_ELEVATOR_POS, RobotStateConstants.C4_FORWARD_ARM_POS), // arm swinging forward :>
L4_CORAL_WITH_CORAL(RobotStateConstants.C4_ELEVATOR_POS_WITH_CORAL, RobotStateConstants.C4_ARM_POS_WITH_CORAL),
L2_ALGAE(RobotStateConstants.A2_ELEVATOR_POS, RobotStateConstants.A2_ARM_POS),
L3_ALGAE(RobotStateConstants.A3_ELEVATOR_POS, RobotStateConstants.A3_ARM_POS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ public Command moveToCommand(RobotState targetRobotState) {
m_elevator.moveToCommand(targetRobotState.getElevatorPos())
)
).until(isLifterAtGoal(targetRobotState.getArmPos(), targetRobotState.getElevatorPos())).withName("moveToL4Command");
} else if (targetRobotState == RobotState.L4_CORAL_FORWARD) {
// moves arm and elevator in parallel for maximum speed

// keep elevator at intermediate pos to let arm clear ramp
double elevatorIntermediatePosition = Math.max(targetRobotState.getElevatorPos(),
ElevatorConstants.MIN_POS_ARM_CLEAR);

return Commands.parallel(
Commands.sequence(
m_arm.moveToCommand(targetRobotState.getArmPos())
),
Commands.sequence(
Commands.waitSeconds(3).until(m_arm.isArmInsideRobotTrigger()),
m_elevator.moveToCommand(elevatorIntermediatePosition)
.until(m_arm.okToMoveElevatorDownTrigger()),
m_elevator.moveToCommand(targetRobotState.getElevatorPos())
)
).until(isLifterAtGoal(targetRobotState.getArmPos(), targetRobotState.getElevatorPos())).withName("moveToL4ForwardCommand");

} else {
// move arm to intermediate pos inside the robot before moving elevator
double armIntermediatePosition = MathUtil.clamp(targetRobotState.getArmPos(),
Expand Down