Skip to content

Commit 757e315

Browse files
committed
Intake periodic update
1 parent b5e156d commit 757e315

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package frc.robot.subsystems.intake;
22

3-
import static edu.wpi.first.units.Units.MetersPerSecond;
4-
import static edu.wpi.first.units.Units.RotationsPerSecond;
5-
63
import frc.robot.preferences.DoublePreference;
74

85
public class IntakePreferences {
96

107
private IntakePreferences(){};
118

129
public static DoublePreference rollerIntakeSpeed = new DoublePreference("Intake/Roller Intake Speed", 0.1);
13-
public static DoublePreference intakeCollectPosition = new DoublePreference("Intake/Stowed Intake Position", 3);
10+
public static DoublePreference intakeCollectPosition = new DoublePreference("Intake/Stowed Intake Position", 3); //in rotations
1411
}

src/main/java/frc/robot/subsystems/intake/IntakeSubsystem.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
package frc.robot.subsystems.intake;
22

33
import static edu.wpi.first.units.Units.Rotations;
4-
import static edu.wpi.first.units.Units.RotationsPerSecond;
54

65
import com.ctre.phoenix6.controls.PositionTorqueCurrentFOC;
76
import com.ctre.phoenix6.hardware.TalonFX;
87

98
import edu.wpi.first.wpilibj2.command.Command;
109
import edu.wpi.first.wpilibj2.command.Commands;
1110
import edu.wpi.first.wpilibj2.command.SubsystemBase;
12-
import edu.wpi.first.wpilibj2.command.WaitUntilCommand;
1311

1412
public class IntakeSubsystem extends SubsystemBase{
1513
private final TalonFX rollerMotor;
1614
private final TalonFX extensionMotor;
1715

1816
private double currentPositionTarget;
17+
private PositionTorqueCurrentFOC positionControl;
1918

2019
public IntakeSubsystem(){
2120
rollerMotor = new TalonFX(IntakeConstants.ROLLER_MOTOR_ID);
2221
extensionMotor = new TalonFX(IntakeConstants.EXTENSION_MOTOR_ID);
2322
extensionMotor.getConfigurator().apply(IntakeConstants.createExtensionMotorSlot0Configs());
2423
extensionMotor.setPosition(0);
2524
currentPositionTarget = 0;
25+
positionControl = new PositionTorqueCurrentFOC(0);
26+
}
27+
28+
@Override
29+
public void periodic(){
30+
extensionMotor.setControl(positionControl.withPosition(currentPositionTarget));
2631
}
2732

2833
public Command spinRollerCommand(){
@@ -38,16 +43,15 @@ private boolean atExtensionSetpoint(){
3843
}
3944

4045
public Command setIntakePositionCommand(double position){
41-
currentPositionTarget = position;
42-
return runOnce(() -> extensionMotor.setControl(new PositionTorqueCurrentFOC(position))).andThen(Commands.waitUntil(() -> atExtensionSetpoint()));
46+
return runOnce(() -> currentPositionTarget = position).andThen(Commands.waitUntil(() -> atExtensionSetpoint()));
4347
}
4448

4549
public Command collectCommand(){
4650
return setIntakePositionCommand(IntakePreferences.intakeCollectPosition.getValue()).andThen(spinRollerCommand()).withName("Activate Intake Collection");
4751
}
4852

4953
public Command stowCommand(){
50-
return stopRollerCommand().andThen(setIntakePositionCommand(0.0)).withName("Stow Intake");
54+
return stopRollerCommand().andThen(setIntakePositionCommand(0)).withName("Stow Intake");
5155
}
5256

5357

0 commit comments

Comments
 (0)