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
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,17 @@ private void addControllerBindings() {
() ->
modifyJoystick(driver.getLeftX())
* SwerveSubsystem.SWERVE_CONSTANTS.getMaxLinearSpeed()));

while(swerve.isCloseToBump()){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the right logic, although the while loop doesn't explicitly create a trigger object around this boolean value

Suggested change
while(swerve.isCloseToBump()){
new Trigger(swerve::isCloseToBump).whileTrue(swerve.bumpAlign etc...)

swerve.bumpAlign(
() ->
modifyJoystick(driver.getLeftY())
* SwerveSubsystem.SWERVE_CONSTANTS.getMaxLinearSpeed(),
() ->
modifyJoystick(driver.getLeftX())
* SwerveSubsystem.SWERVE_CONSTANTS.getMaxLinearSpeed());
}

// TODO add binding for climb

// ---zeroing stuff---
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/frc/robot/subsystems/swerve/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,31 @@ public Command faceHub(DoubleSupplier xVel, DoubleSupplier yVel) {
yVel);
}

public Command bumpAlign(DoubleSupplier xVel, DoubleSupplier yVel) {
return driveWithHeadingSnap(
() -> {
if(getPose().getRotation().getDegrees() <= 90 || getPose().getRotation().getDegrees() >= 270){
return Rotation2d.kZero;
} else {
return Rotation2d.k180deg;
}
},
xVel,
yVel);
}

public boolean isCloseToBump(){
if(
((Math.abs(getPose().getX() - 4.62) < 2) || (Math.abs(getPose().getX() - 11.91) < 2))
&&
((getPose().getY() > 5.04 && getPose().getY() < 6.07) || (getPose().getY() > 2 && getPose().getY() < 3.01)))
Comment on lines +623 to +625
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd recommend throwing these numbers for the coordinates (4.62, 11.91 etc) into FieldUtils.java as constants (so similar to the BLUE_HUB_POS that's already there) and then referencing them by name here to minimize the amount of "magic numbers" floating around in our code

{
return true;
} else {
return false;
}
}

public boolean isInAutoAimTolerance(Pose2d target) {
return isInTolerance(
target, AutoAlign.TRANSLATION_TOLERANCE_METERS, AutoAlign.ROTATION_TOLERANCE_RADIANS);
Expand Down