Skip to content

Commit

Permalink
add low feed shot as a superstructure command
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatankar6 committed Apr 15, 2024
1 parent 60dd55f commit 1dbf78d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
8 changes: 8 additions & 0 deletions src/main/java/frc/robot/PoseEstimation.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public AimingParameters getAimingParameters() {
return m_lastAimingParameters;
}

public Rotation2d getFeedHeading() {
return FieldConstants.stashPositionSupplier
.get()
.minus(getPose().getTranslation())
.getAngle()
.rotateBy(new Rotation2d(Math.PI));
}

private Pose2d poseInverse(Pose2d pose) {
Rotation2d rotationInverse = pose.getRotation().unaryMinus();
return new Pose2d(
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public Robot() {
m_driverController
.leftTrigger()
.and(m_drivetrain.inRangeOfGoal.negate())
.whileTrue(Superstructure.aimAtStash(m_drivetrain, m_shooter, m_arm, m_lights))
.whileTrue(Superstructure.feedShotHigh(m_drivetrain, m_shooter, m_arm, m_lights))
.onFalse(m_arm.goToSetpoint(ArmSetpoints.kStowed));

m_driverController.start().onTrue(m_drivetrain.zeroGyro());
Expand All @@ -245,7 +245,7 @@ public Robot() {
m_operatorController.leftStick().onTrue(m_arm.goToSetpoint(ArmSetpoints.kClimb));
m_operatorController
.rightStick()
.whileTrue(m_arm.goToSetpoint(ArmSetpoints.kStash))
.whileTrue(m_arm.goToSetpoint(ArmSetpoints.kFeedLow))
.onFalse(m_arm.goToSetpoint(ArmSetpoints.kStowed));
m_driverController.b().onTrue(m_arm.goToSetpoint(ArmSetpoints.kTrap));
m_driverController.b().whileTrue(Commands.parallel(m_climber.windWinch()));
Expand Down
29 changes: 17 additions & 12 deletions src/main/java/frc/robot/Superstructure.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package frc.robot;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.GenericHID.RumbleType;
import edu.wpi.first.wpilibj.util.Color;
Expand Down Expand Up @@ -65,22 +64,28 @@ public static Command aimAtGoal(Drivetrain drivetrain, Shooter shooter, Arm arm,
.withInterruptBehavior(InterruptionBehavior.kCancelIncoming);
}

public static Command aimAtStash(Drivetrain drivetrain, Shooter shooter, Arm arm, Lights lights) {
public static Command feedShotHigh(
Drivetrain drivetrain, Shooter shooter, Arm arm, Lights lights) {
return Commands.parallel(
Commands.startEnd(
() ->
drivetrain.setHeadingGoal(
() ->
FieldConstants.stashPositionSupplier
.get()
.minus(PoseEstimation.getInstance().getPose().getTranslation())
.getAngle()
.rotateBy(new Rotation2d(Math.PI))),
() -> drivetrain.setHeadingGoal(PoseEstimation.getInstance()::getFeedHeading),
drivetrain::clearHeadingGoal),
shooter.feederShot(),
arm.goToSetpoint(ArmSetpoints.kStash),
arm.goToSetpoint(ArmSetpoints.kFeedHigh),
lights.showReadyToShootStatus(
drivetrain.atHeadingGoal.and(drivetrain.atHeadingGoal).and(arm.atGoal)))
drivetrain.atHeadingGoal.and(arm.atGoal).and(shooter.readyToShoot)))
.withInterruptBehavior(InterruptionBehavior.kCancelIncoming);
}

public static Command feedShotLow(
Drivetrain drivetrain, Shooter shooter, Arm arm, Lights lights) {
return Commands.parallel(
Commands.startEnd(
() -> drivetrain.setHeadingGoal(PoseEstimation.getInstance()::getFeedHeading),
drivetrain::clearHeadingGoal),
shooter.runShooter(),
arm.goToSetpoint(ArmSetpoints.kFeedLow),
lights.showReadyToShootStatus(drivetrain.atHeadingGoal.and(arm.atGoal)))
.withInterruptBehavior(InterruptionBehavior.kCancelIncoming);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/arm/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ public enum ArmSetpoints {
kAmp(1.49 + 0.0873 + Units.degreesToRadians(3.0), Units.degreesToRadians(228), 0.0, 0.0),
kClimb(1.633, -2.371, 0.0, 0.0),
kTrap(Units.degreesToRadians(53.0), Units.degreesToRadians(80.0), 0.0, 0.0),
kStash(Units.degreesToRadians(-31), 2.083, 0.0, 0.0);
kFeedHigh(Units.degreesToRadians(-31), 2.083, 0.0, 0.0),
kFeedLow(Units.degreesToRadians(10.0), Units.degreesToRadians(170.0), 0.0, 0.0);

public final double elbowAngle;
public final double wristAngle;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/feeder/FeederIOTalonFX.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.time.Duration;

public class FeederIOTalonFX implements FeederIO {
private final boolean kUseHighFrequencySensorPolling = true;
private final TalonFX m_feederMotor;
private final DigitalInput m_noteSensor;
private final DigitalGlitchFilter m_glitchFilter;
Expand Down

0 comments on commit 1dbf78d

Please sign in to comment.