-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autonomous #22
Merged
Merged
Autonomous #22
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
554b5dd
Initial test with chained paths
ky28059 b9f1d92
Start on auton sequences
ky28059 23e8228
Changed shoot command to not use a callback
e3l ac36293
Add ball coordinates to constants
ky28059 a35842c
Finish red sequences, `GRTAutonSequence` abstraction
ky28059 7692a83
Blue auton sequences
ky28059 ebec55e
Auton sequence abstraction
ky28059 6482208
Merge branch 'shooter-testing' into auton
ky28059 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions
33
src/main/java/frc/robot/commands/internals/ShootCommand.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,33 @@ | ||
package frc.robot.commands.internals; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.internals.InternalSubsystem; | ||
|
||
/** | ||
* Requests a shot to be fired, and waits until it is. This is used in autonomous command groups to | ||
* make sure shots are fired when they are supposed to. | ||
*/ | ||
public class ShootCommand extends CommandBase { | ||
private final InternalSubsystem internals; | ||
|
||
private boolean shotRequested = false; | ||
private boolean finished = false; | ||
|
||
public ShootCommand(InternalSubsystem internals) { | ||
this.internals = internals; | ||
addRequirements(internals); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
internals.requestShot(); | ||
shotRequested = true; | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
boolean doneShooting = shotRequested && !internals.shotRequested(); | ||
this.finished = finished || doneShooting; // in case someone ever queues a new shot before successive isFinished calls (???) | ||
return finished; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/frc/robot/commands/tank/AutonMiddleSequence.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,39 @@ | ||
package frc.robot.commands.tank; | ||
|
||
import java.util.List; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
|
||
import frc.robot.commands.internals.ShootCommand; | ||
import frc.robot.subsystems.internals.InternalSubsystem; | ||
import frc.robot.subsystems.tank.TankSubsystem; | ||
|
||
/** | ||
* The middle autonomous sequence. This assumes we start in the middle position, facing away from the hub. | ||
* For all autonomous sequences, we drive forward and intake a ball, then shoot both cargo into the hub. | ||
* For the middle sequence specifically, after shooting both balls off the tarmac, drive to and shoot | ||
* the ball from the human player terminal. | ||
*/ | ||
public class AutonMiddleSequence extends SequentialCommandGroup { | ||
// TODO: measure these | ||
private static Pose2d initialPose = new Pose2d(0, 0, Rotation2d.fromDegrees(-66)); | ||
private static Pose2d ballOnePose = new Pose2d( | ||
Units.inchesToMeters(88.3000339775), | ||
Units.inchesToMeters(124.94840535), | ||
Rotation2d.fromDegrees(-54.7514582647)); | ||
private static Pose2d ballTwoPose = new Pose2d(0, 0, Rotation2d.fromDegrees(-45)); | ||
|
||
public AutonMiddleSequence(TankSubsystem tankSubsystem, InternalSubsystem internalSubsystem) { | ||
addRequirements(tankSubsystem, internalSubsystem); | ||
addCommands( | ||
new FollowPathCommand(tankSubsystem, initialPose, List.of(), ballOnePose), | ||
new ShootCommand(internalSubsystem), | ||
new ShootCommand(internalSubsystem), | ||
new FollowPathCommand(tankSubsystem, ballOnePose, List.of(), ballTwoPose), | ||
new ShootCommand(internalSubsystem) | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/frc/robot/commands/tank/AutonTopSequence.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,30 @@ | ||
package frc.robot.commands.tank; | ||
|
||
import java.util.List; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
|
||
import frc.robot.commands.internals.ShootCommand; | ||
import frc.robot.subsystems.internals.InternalSubsystem; | ||
import frc.robot.subsystems.tank.TankSubsystem; | ||
|
||
/** | ||
* The top autonomous sequence. This assumes we start in the top position, facing away from the hub. | ||
* For all autonomous sequences, we drive forward and intake a ball, then shoot both cargo into the hub. | ||
*/ | ||
public class AutonTopSequence extends SequentialCommandGroup { | ||
// TODO: measure these | ||
public static final Pose2d initialPose = new Pose2d(0, 0, new Rotation2d()); | ||
public static final Pose2d ballOnePose = new Pose2d(0, 0, new Rotation2d()); | ||
|
||
public AutonTopSequence(TankSubsystem tankSubsystem, InternalSubsystem internalSubsystem) { | ||
addRequirements(tankSubsystem, internalSubsystem); | ||
addCommands( | ||
new FollowPathCommand(tankSubsystem, initialPose, List.of(), ballOnePose), | ||
new ShootCommand(internalSubsystem), | ||
new ShootCommand(internalSubsystem) | ||
); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's realistic for a driver to request a new shot in the 20ms periodic window between the first tick after the old shot is fired and the tick immediately following it. Also, drivers won't be able to request shots in autonomous (which is when this command would be used) and there's no way for two calls to this command in a SequentialCommandGroup to trigger this because the first command's
isFinished()
needs to return true before the second command'sinitialize()
runs.For
isFinished()
, we may not have to storeshotRequested
either; ifinitialize()
always runs before the first call toisFinished()
,isFinished()
can be implemented likeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, does it hurt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not? But it's an impossible scenario anyways and it adds another field variable