Skip to content

Commit

Permalink
Update logic so that aimer locks when intaking and only when intaking
Browse files Browse the repository at this point in the history
  • Loading branch information
aidnem committed Oct 26, 2024
1 parent 1d0fbc8 commit 9e97a9f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/constants/ScoringConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class ScoringConstants {

public static final double aimMaxAngleRotations = 0.361328 - 0.184570;
public static final double aimMinAngleRotations = -0.217285;
public static final double aimLockVoltage = -0.5;

public static final double aimAngleTolerance = 0.015;

Expand Down
16 changes: 10 additions & 6 deletions src/main/java/frc/robot/subsystems/scoring/AimerIORoboRio.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,18 @@ public void applyOutputs(AimerOutputs outputs) {

request = motionMagicVoltage;

if (lockNegativeAtHome && !override) {
talonFXConfigs.CurrentLimits.StatorCurrentLimit =
ScoringConstants.aimerCurrentLimit / 5;
aimerMotor.getConfigurator().apply(talonFXConfigs);
request = new VoltageOut(-0.05);
if (lockNegativeAtHome
&& getEncoderPosition()
< ScoringConstants.aimMinAngleRotations
+ ScoringConstants.intakeAngleToleranceRotations
&& !override) {
// talonFXConfigs.CurrentLimits.StatorCurrentLimit =
// ScoringConstants.aimerCurrentLimit / 5;
// aimerMotor.getConfigurator().apply(talonFXConfigs);
request = new VoltageOut(ScoringConstants.aimLockVoltage);
} else {
talonFXConfigs.CurrentLimits.StatorCurrentLimit = ScoringConstants.aimerCurrentLimit;
aimerMotor.getConfigurator().apply(talonFXConfigs);
// aimerMotor.getConfigurator().apply(talonFXConfigs);
motionMagicVoltage.withPosition(goalAngleRot);
request = motionMagicVoltage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,8 @@ private void idle() {
}

private void intake() {
if (!aimerAtIntakePosition()) {
aimerIo.setAimAngleRot(ScoringConstants.aimMinAngleRotations);
} else {
aimerIo.setNegativeHomeLockMode(true);
}
aimerIo.setAimAngleRot(ScoringConstants.aimMinAngleRotations);
aimerIo.setNegativeHomeLockMode(true);

if (!hasNote()) {
shooterIo.setKickerVolts(ScoringConstants.kickerIntakeVolts);
Expand Down Expand Up @@ -509,6 +506,8 @@ public void enabledInit() {

@Override
public void periodic() {
aimerIo.setNegativeHomeLockMode(false); // This should be false in all states but intake
// Intake will set it to true later in the loop.

if (!SmartDashboard.containsKey("Aimer Offset")) {
SmartDashboard.putNumber("Aimer Offset", ScoringConstants.aimerStaticOffset);
Expand Down

0 comments on commit 9e97a9f

Please sign in to comment.