-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'vision' of https://github.com/robototes/Reefscape2025 i…
…nto vision
- Loading branch information
Showing
4 changed files
with
71 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
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
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,48 @@ | ||
package frc.robot.subsystems; | ||
|
||
import static edu.wpi.first.units.Units.Volts; | ||
|
||
import com.ctre.phoenix6.configs.CurrentLimitsConfigs; | ||
import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
import com.ctre.phoenix6.configs.TalonFXConfigurator; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
import edu.wpi.first.units.measure.Voltage; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Hardware; | ||
import java.util.function.Supplier; | ||
|
||
public class SpinnyClaw extends SubsystemBase { | ||
// Remove once we implement PID speed | ||
public static int placeholderPIDSpeed; | ||
|
||
// TalonFX | ||
private final TalonFX motor; | ||
|
||
public SpinnyClaw() { | ||
motor = new TalonFX(Hardware.SPINNY_CLAW_MOTOR_ID); | ||
factoryDefaults(); | ||
} | ||
|
||
// (+) is to move arm up, and (-) is down | ||
public Command movingVoltage(Supplier<Voltage> speedControl) { | ||
return run(() -> motor.setVoltage(speedControl.get().in(Volts))) | ||
.finallyDo(() -> motor.setVoltage(0)); | ||
} | ||
|
||
// TalonFX config | ||
public void factoryDefaults() { | ||
TalonFXConfiguration configuration = new TalonFXConfiguration(); | ||
TalonFXConfigurator cfg = motor.getConfigurator(); | ||
var currentLimits = new CurrentLimitsConfigs(); | ||
configuration.MotorOutput.NeutralMode = NeutralModeValue.Brake; | ||
cfg.apply(configuration); | ||
// enabling stator current limits | ||
currentLimits.StatorCurrentLimit = 5; // starting low for testing | ||
currentLimits.StatorCurrentLimitEnable = true; | ||
currentLimits.SupplyCurrentLimit = 5; // starting low for testing | ||
currentLimits.SupplyCurrentLimitEnable = true; | ||
cfg.apply(currentLimits); | ||
} | ||
} |