Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
update Wrist
Browse files Browse the repository at this point in the history
  • Loading branch information
legoguy1000 committed Jan 27, 2024
1 parent 1bff7a8 commit 2dedcaf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 161 deletions.
24 changes: 14 additions & 10 deletions src/main/java/frc/robot/subsystems/WristIntake.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package frc.robot.subsystems;

import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.hardware.TalonFX;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
Expand All @@ -12,7 +11,8 @@
*/
public class WristIntake extends SubsystemBase {

private final WPI_TalonFX wristIntakeMotor = new WPI_TalonFX(Constants.Wrist.WRIST_INTAKE_ID);
private TalonFXConfiguration wristMotorConfig = new TalonFXConfiguration();
private final TalonFX wristIntakeMotor = new TalonFX(Constants.Wrist.WRIST_INTAKE_ID);

private boolean invertForCone = true;

Expand All @@ -21,17 +21,20 @@ public class WristIntake extends SubsystemBase {
*/
public WristIntake() {
wristIntakeMotor.setInverted(false);
wristIntakeMotor.setNeutralMode(NeutralMode.Brake);
wristMotorConfig.MotorOutput.NeutralMode = Constants.Swerve.driveNeutralMode;
wristIntakeMotor.getConfigurator().apply(wristMotorConfig);

}

@Override
public void periodic() {
SmartDashboard.putNumber("Wrist Intake Current", wristIntakeMotor.getStatorCurrent());
SmartDashboard.putNumber("Wrist Intake Current",
wristIntakeMotor.getStatorCurrent().getValueAsDouble());
}

// Runs wrist intake motor to intake a game piece.
public void intake() {
wristIntakeMotor.set(ControlMode.PercentOutput, Constants.Wrist.INTAKE_SPEED);
wristIntakeMotor.set(Constants.Wrist.INTAKE_SPEED);
}

/**
Expand All @@ -40,7 +43,7 @@ public void intake() {
* @param power power of motors from -1 to 1
*/
public void setMotor(double power) {
wristIntakeMotor.set(ControlMode.PercentOutput, (invertForCone ? -1 : 1) * power);
wristIntakeMotor.set((invertForCone ? -1 : 1) * power);
}

/**
Expand All @@ -49,7 +52,7 @@ public void setMotor(double power) {
* @param power power of motors from -1 to 1
*/
public void setMotorRaw(double power) {
wristIntakeMotor.set(ControlMode.PercentOutput, power);
wristIntakeMotor.set(power);
}

/**
Expand All @@ -64,7 +67,8 @@ public void panic() {
* Get if motor is stalling by checking if the stator current exceeds a constant
*/
public boolean getVoltageSpike(boolean passedTime) {
return wristIntakeMotor.getStatorCurrent() > Constants.Wrist.STALL_CURRENT;
return wristIntakeMotor.getStatorCurrent()
.getValueAsDouble() > Constants.Wrist.STALL_CURRENT;
}

public void setInvert(boolean invert) {
Expand Down
151 changes: 0 additions & 151 deletions vendordeps/Phoenix5.json

This file was deleted.

0 comments on commit 2dedcaf

Please sign in to comment.