This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4539959
commit 4ab8516
Showing
2 changed files
with
42 additions
and
0 deletions.
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
40 changes: 40 additions & 0 deletions
40
src/main/java/org/team1540/robot2023/commands/wristintake/RollerIntake.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,40 @@ | ||
package org.team1540.robot2023.commands.wristintake; | ||
|
||
import com.ctre.phoenix.motorcontrol.ControlMode; | ||
import com.ctre.phoenix.motorcontrol.NeutralMode; | ||
import com.ctre.phoenix.motorcontrol.StatorCurrentLimitConfiguration; | ||
import com.ctre.phoenix.motorcontrol.can.TalonFX; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import org.team1540.robot2023.utils.AverageFilter; | ||
|
||
import static org.team1540.robot2023.Constants.RollerIntakeConstants.*; | ||
|
||
public class RollerIntake extends SubsystemBase { | ||
private final TalonFX motor = new TalonFX(ROLLER_INTAKE_ID); | ||
private final AverageFilter averageFilter = new AverageFilter(5); | ||
|
||
public RollerIntake() { | ||
motor.configStatorCurrentLimit( | ||
new StatorCurrentLimitConfiguration(true, INTAKE_IDLE_CURRENT, INTAKE_IDLE_CURRENT, 0) | ||
); | ||
motor.setNeutralMode(NeutralMode.Brake); | ||
motor.setInverted(false); // TODO: 8/29/2023 figure out inversion | ||
} | ||
|
||
public void setSpeed(double speed) { | ||
motor.set(ControlMode.PercentOutput, speed); | ||
} | ||
|
||
public void stop() { | ||
setSpeed(0); | ||
} | ||
|
||
public boolean hasGamePiece() { | ||
return averageFilter.getAverage() < VELOCITY_THRESH; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
averageFilter.add(motor.getSelectedSensorVelocity()); | ||
} | ||
} |