generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from StuyPulse/se/amp-alignment
Se/amp alignment
- Loading branch information
Showing
4 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/stuypulse/robot/commands/swerve/SwerveDriveAutoAlignment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.stuypulse.robot.commands.swerve; | ||
|
||
import com.stuypulse.robot.commands.BuzzController; | ||
import com.stuypulse.robot.subsystems.arm.Arm; | ||
import com.stuypulse.stuylib.input.Gamepad; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandScheduler; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
/** | ||
* automatically determines how to align depending on the state of the arm | ||
* | ||
* <p> buzzes controller if arm is not in one of the scoring/ferrying positions | ||
*/ | ||
public class SwerveDriveAutoAlignment extends InstantCommand{ | ||
|
||
private final Gamepad driver; | ||
|
||
public SwerveDriveAutoAlignment(Gamepad driver) { | ||
this.driver = driver; | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
switch (Arm.getInstance().getState()) { | ||
case AMP: | ||
CommandScheduler.getInstance().schedule(new SwerveDriveDriveAmpAligned(driver)); | ||
break; | ||
case SPEAKER_HIGH: | ||
CommandScheduler.getInstance().schedule(new SwerveDriveDriveAlignedSpeakerHigh(driver)); | ||
break; | ||
case SPEAKER_LOW: | ||
CommandScheduler.getInstance().schedule(new SwerveDriveDriveAlignedSpeakerLow(driver)); | ||
break; | ||
case LOW_FERRY: | ||
CommandScheduler.getInstance().schedule(new SwerveDriveDriveAlignedLowFerry(driver)); | ||
break; | ||
case LOB_FERRY: | ||
CommandScheduler.getInstance().schedule(new SwerveDriveDriveAlignedLobFerry(driver)); | ||
break; | ||
default: | ||
CommandScheduler.getInstance().schedule(new BuzzController(driver)); | ||
break; | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/stuypulse/robot/commands/swerve/SwerveDriveDriveAmpAligned.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.stuypulse.robot.commands.swerve; | ||
|
||
import com.stuypulse.robot.Robot; | ||
import com.stuypulse.robot.constants.Settings; | ||
import com.stuypulse.stuylib.input.Gamepad; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
|
||
|
||
public class SwerveDriveDriveAmpAligned extends SwerveDriveDriveAligned { | ||
|
||
public SwerveDriveDriveAmpAligned(Gamepad driver) { | ||
super(driver); | ||
} | ||
|
||
|
||
@Override | ||
protected Rotation2d getTargetAngle() { | ||
return Rotation2d.fromDegrees(Robot.isBlue() ? 90 : 270); | ||
} | ||
|
||
@Override | ||
protected double getDistanceToTarget() { | ||
return Settings.Swerve.Assist.AMP_WALL_SCORE_DISTANCE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters