-
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.
Attempt at implementing io logging for subsystems
Only intake is implemented like how the examples show. The implementations for the elevator and drivebase are incorrect and likely will not work
- Loading branch information
1 parent
fb0fc9f
commit f3e05df
Showing
9 changed files
with
182 additions
and
114 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
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,22 @@ | ||
package frc.robot.subsystems; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IntakeIO { | ||
@AutoLog | ||
public static class IntakeIOInputs { | ||
public double currentExtension = 0.0; | ||
public double velocityRadPerSec = 0.0; | ||
public double appliedVolts = 0.0; | ||
public double[] currentAmps = new double[] {}; | ||
} | ||
|
||
/** Updates the set of loggable inputs. */ | ||
public default void updateInputs(IntakeIOInputs inputs) {} | ||
|
||
/** Run closed loop at the specified velocity. */ | ||
public default void setMotorPower(double power) {} | ||
|
||
/** Stop in open loop. */ | ||
public default void stop() {} | ||
} |
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,78 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix.motorcontrol.NeutralMode; | ||
import com.ctre.phoenix.motorcontrol.TalonFXControlMode; | ||
import com.ctre.phoenix.motorcontrol.can.TalonFX; | ||
import edu.wpi.first.math.filter.LinearFilter; | ||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; | ||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class IntakeIOTalonFX extends SubsystemBase { | ||
private TalonFX intakeMotor; | ||
private ShuffleboardTab shuffleboard = Shuffleboard.getTab("Intake Subsystem"); | ||
private Modes currentIntakeMode; | ||
private LinearFilter filter; | ||
private double filterOutput; | ||
private boolean isCone; | ||
// private final TimeOfFlight coneToF, cubeToF; | ||
|
||
/** Creates a new IntakeIOTalonFX. */ | ||
public IntakeIOTalonFX() { | ||
intakeMotor = new TalonFX(Constants.Intake.Ports.INTAKE_MOTOR_PORT); | ||
|
||
intakeMotor.configFactoryDefault(); | ||
intakeMotor.clearStickyFaults(); | ||
|
||
intakeMotor.setNeutralMode(NeutralMode.Brake); | ||
intakeMotor.setInverted(true); | ||
|
||
filter = LinearFilter.movingAverage(30); | ||
|
||
currentIntakeMode = Modes.OFF; | ||
|
||
filterOutput = 0.0; | ||
|
||
isCone = false; | ||
} | ||
|
||
public enum Modes { | ||
INTAKE, | ||
OUTTAKE, | ||
HOLD, | ||
OFF; | ||
} | ||
|
||
public void setMotorPower(double power) { | ||
intakeMotor.set(TalonFXControlMode.PercentOutput, power); | ||
} | ||
|
||
public double getMotorPower() { | ||
return intakeMotor.getMotorOutputPercent(); | ||
} | ||
|
||
public Modes getMode() { | ||
return currentIntakeMode; | ||
} | ||
|
||
public void setMode(Modes hold) { | ||
currentIntakeMode = hold; | ||
} | ||
|
||
public void setIsCone(boolean isCone) { | ||
this.isCone = isCone; | ||
} | ||
|
||
public boolean getIsCone() { | ||
return isCone; | ||
} | ||
|
||
public double getFilterOutput() { | ||
return filterOutput; | ||
} | ||
} |
Oops, something went wrong.