-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
84 additions
and
4 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
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,26 @@ | ||
package frc.robot.subsystems.algae; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
|
||
public class Algae extends SubsystemBase { | ||
private final AlgaeIO m_io; | ||
|
||
public Algae(AlgaeIO io) { | ||
m_io = io; | ||
} | ||
|
||
public Command shootAlgae() { | ||
return this.run(() -> m_io.setSpeed(-0.1)); | ||
} | ||
|
||
public Command stop() { | ||
return this.run(() -> m_io.setSpeed(0)); | ||
} | ||
|
||
public Command intake() { | ||
return this.run(() -> m_io.setSpeed(1)); | ||
} | ||
} | ||
|
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,12 @@ | ||
package frc.robot.subsystems.algae; | ||
|
||
public interface AlgaeIO { | ||
|
||
public static class AlgaeIOInputs { | ||
public double speed = 0.0; | ||
} | ||
|
||
public default void setSpeed(double speed) {} | ||
|
||
public default void setBrakeMode(boolean enableBrakeMode) {} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/frc/robot/subsystems/algae/AlgaeIOTalonFX.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,33 @@ | ||
package frc.robot.subsystems.algae; | ||
|
||
import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
import com.ctre.phoenix6.controls.DutyCycleOut; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
|
||
public class AlgaeIOTalonFX implements AlgaeIO { | ||
|
||
private final TalonFX m_algaeMotor; | ||
|
||
public AlgaeIOTalonFX (){ | ||
m_algaeMotor = new TalonFX(23, "CANivore2"); | ||
|
||
final TalonFXConfiguration algaeMotorConfig = new TalonFXConfiguration(); | ||
algaeMotorConfig.CurrentLimits.SupplyCurrentLimit = 40.0; | ||
algaeMotorConfig.CurrentLimits.SupplyCurrentLimitEnable = true; | ||
|
||
m_algaeMotor.getConfigurator().apply(algaeMotorConfig); | ||
} | ||
|
||
@Override | ||
public void setSpeed(double speed) { | ||
m_algaeMotor.setControl(new DutyCycleOut(speed)); | ||
} | ||
|
||
@Override | ||
public void setBrakeMode(boolean enableBrakeMode) { | ||
final NeutralModeValue neutralModeValue = | ||
enableBrakeMode ? NeutralModeValue.Brake : NeutralModeValue.Coast; | ||
m_algaeMotor.setNeutralMode(neutralModeValue); | ||
} | ||
} |