-
Notifications
You must be signed in to change notification settings - Fork 1
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
678542c
commit f0b8868
Showing
13 changed files
with
338 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
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,50 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.IntakeConstants; | ||
import frc.robot.util.SubsystemProfiles; | ||
import java.util.HashMap; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
public class Intake extends SubsystemBase { | ||
private IntakeIO m_io; | ||
public final IntakeInputsAutoLogged m_inputs; | ||
private SubsystemProfiles m_profiles; | ||
|
||
public enum IntakeState { | ||
kIdle, | ||
kIntaking, | ||
kOuttaking | ||
} | ||
|
||
public Intake(IntakeIO io) { | ||
m_io = io; | ||
m_inputs = new IntakeInputsAutoLogged(); | ||
|
||
m_profiles = new SubsystemProfiles(IntakeState.class, new HashMap<>(), IntakeState.kIdle); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
m_io.updateInputs(m_inputs); | ||
|
||
Logger.processInputs("Intake", m_inputs); | ||
Logger.recordOutput("Intake/CurrentState", (IntakeState) m_profiles.getCurrentProfile()); | ||
} | ||
|
||
public void updateState(IntakeState state) { | ||
switch (state) { | ||
case kIdle: | ||
m_io.setVoltage(IntakeConstants.kIdleVoltage); | ||
break; | ||
case kIntaking: | ||
m_io.setVoltage(IntakeConstants.kIntakeVoltage); | ||
break; | ||
case kOuttaking: | ||
m_io.setVoltage(IntakeConstants.kOuttakeVoltage); | ||
break; | ||
} | ||
|
||
m_profiles.setCurrentProfile(state); | ||
} | ||
} |
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,16 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IntakeIO { | ||
@AutoLog | ||
public static class IntakeInputs { | ||
public double angularVelocityRPM; | ||
public double voltage; | ||
public double current; | ||
} | ||
|
||
public void updateInputs(IntakeInputs inputs); | ||
|
||
public void setVoltage(double voltage); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/frc/robot/subsystems/intake/IntakeIONeo.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,27 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
public class IntakeIONeo implements IntakeIO { | ||
private CANSparkMax m_motor; | ||
private RelativeEncoder m_encoder; | ||
|
||
public IntakeIONeo(int port) { | ||
m_motor = new CANSparkMax(port, MotorType.kBrushless); | ||
m_encoder = m_motor.getEncoder(); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IntakeInputs inputs) { | ||
inputs.angularVelocityRPM = m_encoder.getVelocity(); | ||
inputs.voltage = m_motor.getBusVoltage() * m_motor.getAppliedOutput(); | ||
inputs.current = m_motor.getOutputCurrent(); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double voltage) { | ||
m_motor.setVoltage(voltage); | ||
} | ||
} |
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,50 @@ | ||
package frc.robot.subsystems.kicker; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.KickerConstants; | ||
import frc.robot.util.SubsystemProfiles; | ||
import java.util.HashMap; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
public class Kicker extends SubsystemBase { | ||
private KickerIO m_io; | ||
public final KickerInputsAutoLogged m_inputs; | ||
private SubsystemProfiles m_profiles; | ||
|
||
public enum KickerState { | ||
kIdle, | ||
kShooting, | ||
kEjecting | ||
} | ||
|
||
public Kicker(KickerIO io) { | ||
m_io = io; | ||
m_inputs = new KickerInputsAutoLogged(); | ||
|
||
m_profiles = new SubsystemProfiles(KickerState.class, new HashMap<>(), KickerState.kIdle); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
m_io.updateInputs(m_inputs); | ||
|
||
Logger.processInputs("Kicker", m_inputs); | ||
Logger.recordOutput("Kicker/State", (KickerState) m_profiles.getCurrentProfile()); | ||
} | ||
|
||
public void updateState(KickerState state) { | ||
switch (state) { | ||
case kIdle: | ||
m_io.setVoltage(KickerConstants.kIdleVoltage); | ||
break; | ||
case kShooting: | ||
m_io.setVoltage(KickerConstants.kShootingVoltage); | ||
break; | ||
case kEjecting: | ||
m_io.setVoltage(KickerConstants.kEjectingVoltage); | ||
break; | ||
} | ||
|
||
m_profiles.setCurrentProfile(state); | ||
} | ||
} |
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,16 @@ | ||
package frc.robot.subsystems.kicker; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface KickerIO { | ||
@AutoLog | ||
public static class KickerInputs { | ||
public double angularVelocityRPM; | ||
public double voltage; | ||
public double current; | ||
} | ||
|
||
public void updateInputs(KickerInputs inputs); | ||
|
||
public void setVoltage(double voltage); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/frc/robot/subsystems/kicker/KickerIONeo.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,27 @@ | ||
package frc.robot.subsystems.kicker; | ||
|
||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
public class KickerIONeo implements KickerIO { | ||
private CANSparkMax m_motor; | ||
private RelativeEncoder m_encoder; | ||
|
||
public KickerIONeo(int port) { | ||
m_motor = new CANSparkMax(port, MotorType.kBrushless); | ||
m_encoder = m_motor.getEncoder(); | ||
} | ||
|
||
@Override | ||
public void updateInputs(KickerInputs inputs) { | ||
inputs.angularVelocityRPM = m_encoder.getVelocity(); | ||
inputs.voltage = m_motor.getAppliedOutput() * m_motor.getBusVoltage(); | ||
inputs.current = m_motor.getOutputCurrent(); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double voltage) { | ||
m_motor.setVoltage(voltage); | ||
} | ||
} |
Oops, something went wrong.