generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added auto ferry command Co-authored-by: Lapcas <[email protected]> Co-authored-by: alex <[email protected]> Co-authored-by: Rahel Arka <[email protected]> Co-authored-by: jopy-man <[email protected]> Co-authored-by: rzheng287 <[email protected]> Co-authored-by: hahafoot <[email protected]> Co-authored-by: simon <[email protected]> Co-authored-by: urnotkool <[email protected]> * add override end method * Fix command, bind to top button --------- Co-authored-by: Naowal Rahman <[email protected]> Co-authored-by: Lapcas <[email protected]> Co-authored-by: alex <[email protected]> Co-authored-by: Rahel Arka <[email protected]> Co-authored-by: jopy-man <[email protected]> Co-authored-by: rzheng287 <[email protected]> Co-authored-by: hahafoot <[email protected]> Co-authored-by: simon <[email protected]> Co-authored-by: urnotkool <[email protected]>
- Loading branch information
1 parent
26cff58
commit b301ed9
Showing
6 changed files
with
113 additions
and
14 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
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
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
73 changes: 73 additions & 0 deletions
73
src/main/java/com/stuypulse/robot/commands/swerve/SwerveDriveAutoFerry.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,73 @@ | ||
package com.stuypulse.robot.commands.swerve; | ||
|
||
import com.stuypulse.robot.Robot; | ||
import com.stuypulse.robot.constants.Field; | ||
import com.stuypulse.robot.subsystems.conveyor.Conveyor; | ||
import com.stuypulse.robot.subsystems.intake.Intake; | ||
import com.stuypulse.robot.subsystems.odometry.Odometry; | ||
import com.stuypulse.robot.subsystems.shooter.Shooter; | ||
import com.stuypulse.robot.subsystems.swerve.SwerveDrive; | ||
import com.stuypulse.stuylib.input.Gamepad; | ||
|
||
import com.stuypulse.robot.constants.Settings; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
|
||
|
||
public class SwerveDriveAutoFerry extends SwerveDriveDriveAligned { | ||
|
||
private final Odometry odometry; | ||
private final Shooter shooter; | ||
private final Conveyor conveyor; | ||
private final Intake intake; | ||
|
||
public SwerveDriveAutoFerry(Gamepad driver) { | ||
super(driver); | ||
|
||
shooter = Shooter.getInstance(); | ||
odometry = Odometry.getInstance(); | ||
conveyor = Conveyor.getInstance(); | ||
intake = Intake.getInstance(); | ||
|
||
addRequirements(shooter, odometry); | ||
} | ||
|
||
// returns pose of close amp corner | ||
private Translation2d getTargetPose() { | ||
return Robot.isBlue() | ||
? new Translation2d(0, Field.WIDTH) | ||
: new Translation2d(0, 0); | ||
} | ||
|
||
@Override | ||
public Rotation2d getTargetAngle() { | ||
return getTargetPose().minus(odometry.getPose().getTranslation()).getAngle(); | ||
} | ||
|
||
@Override | ||
public double getDistanceToTarget() { | ||
return getTargetPose().getDistance(odometry.getPose().getTranslation()); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
super.execute(); | ||
|
||
if (odometry.getPose().getX() < Field.FERRY_SHOT_THRESHOLD_X) { | ||
intake.acquire(); | ||
conveyor.toShooter(); | ||
shooter.setTargetSpeeds(Settings.Shooter.FERRY); | ||
} else { | ||
intake.stop(); | ||
conveyor.stop(); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
intake.stop(); | ||
conveyor.stop(); | ||
shooter.setTargetSpeeds(Settings.Shooter.PODIUM_SHOT); | ||
} | ||
} |
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
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