Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
feat(auto): add shoot in place option
Browse files Browse the repository at this point in the history
  • Loading branch information
Craftzman7 committed Sep 13, 2023
1 parent bc421a6 commit ea242dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public AutoBalance (Drivetrain drivetrain, PoseEstimation poseEstimation) {
new GenerateCommand(
() -> {
try {
Pose2d targetXPosition = new Pose2d(AllianceUtils.allianceToField(Constants.AutoConstants.BALANCE_X_POSITION), poseEstimation.getEstimatedPose().getY(), poseEstimation.getEstimatedPose().getRotation());
Pose2d targetXPosition = new Pose2d(AllianceUtils.allianceToField(Constants.AutoConstants.BALANCE_X_POSITION), poseEstimation.getEstimatedPose().getY(), Rotation2d.fromDegrees(0));
PathPoint targetPoint = Constants.AutoConstants.BALANCING_OUTER_PARTITION.queryWaypoint(poseEstimation.getEstimatedPose(), targetXPosition).orElseGet(
() -> Constants.AutoConstants.BALANCING_INNER_PARTITION.queryWaypoint(poseEstimation.getEstimatedPose(), targetXPosition).orElseThrow()
);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/frc/robot/commands/autonomous/AutoShoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
import com.pathplanner.lib.PathPoint;

public class AutoShoot extends SequentialCommandGroup {
public AutoShoot(Drivetrain drivetrain, Arm arm, PoseEstimation poseEstimation) {
public AutoShoot(Drivetrain drivetrain, Arm arm, PoseEstimation poseEstimation, boolean shouldShootInPlace) {
Pose2d shootPose = AllianceUtils.allianceToField(Constants.AutoConstants.CUBE_SHOOT_POSITION);
// I'm probably doing this wrong. Someone please tell me how to do this right.
if (!shouldShootInPlace) {
this.addCommands(
new FollowTrajectoryToState(drivetrain, poseEstimation, new PathPoint(shootPose.getTranslation(), shootPose.getRotation(), shootPose.getRotation(), 2), true)
);
}
this.addCommands(
// AllianceUtils.allianceToField(new Pose2d(new Translation2d(3.76, 4.86), new Rotation2d(180)))
new FollowTrajectoryToState(drivetrain, poseEstimation, new PathPoint(shootPose.getTranslation(), shootPose.getRotation(), shootPose.getRotation(), 2), true),
// AllianceUtils.allianceToField(new Pose2d(new Translation2d(3.76, 4.86), new Rotation2d(180)))
new InstantCommand(() -> arm.setTarget(Arm.State.High)),
new WaitCommand(0.25),
new InstantCommand(() -> arm.setRollerState(Rollers.State.Outtake)),
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/utils/AutoLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ private static Command compileStatement(String source) {
return new InstantCommand(() -> RobotContainer.arm.setGamePiece(scorePiece)).
andThen(new AutoScore(RobotContainer.drivetrain, RobotContainer.arm, RobotContainer.poseEstimation, () -> node));
case "shoot":
Boolean shouldShootInPlace = tokens.length > 1 ? Boolean.parseBoolean(tokens[1]) : false;
return new GenerateCommand(
() -> new AutoShoot(RobotContainer.drivetrain, RobotContainer.arm, RobotContainer.poseEstimation),
() -> new AutoShoot(RobotContainer.drivetrain, RobotContainer.arm, RobotContainer.poseEstimation, shouldShootInPlace),
Set.of(RobotContainer.drivetrain)
);
case "balance":
Expand Down

0 comments on commit ea242dd

Please sign in to comment.