Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/team2813/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public final class Constants {
// CAN IDs - All directions are from when the robot is viewed from behind, unless otherwise
// stated.
// Roller Motors. Aliases: Feeder motors, Magazine motors
public static final int MAIN_FEEDER_MOTOR_CAN_ID = 25; // Top roller motor.
public static final int FOLLOWER_FEEDER_MOTOR_CAN_ID = 15; // Bottom roller motor.
// These force balls from the hopper into the shooter.
public static final int FEEDER_MOTOR_CAN_ID = 25; // Feeder motor.

// Indexer Motors. Aliases: Vectoring motors
public static final int INDEXER_MOTOR_ID = 24;
Expand Down
18 changes: 5 additions & 13 deletions src/main/java/com/team2813/subsystems/hopper/HopperConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.MotorOutputConfigs;
import com.ctre.phoenix6.configs.Slot0Configs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.signals.InvertedValue;
import edu.wpi.first.units.measure.Voltage;
Expand Down Expand Up @@ -39,24 +40,15 @@ public static Voltage getFeederOuttakeVoltage() {
return Volts.of(Preferences.getDouble(FEEDER_OUTTAKE_VOLTAGE_NT, -6));
}

// TOP
public static final TalonFXConfiguration MAIN_ROLLER_MOTOR_CONFIG =
// The motor on the bottom feeders.
public static final TalonFXConfiguration FEEDER_MOTOR_CONFIG =
new TalonFXConfiguration()
.withMotorOutput(new MotorOutputConfigs().withInverted(InvertedValue.Clockwise_Positive))
.withCurrentLimits(
new CurrentLimitsConfigs()
.withSupplyCurrentLimit(Amps.of(30))
.withStatorCurrentLimit(Amps.of(60)));

// Bottom Motor, opposite of main motor.
public static final TalonFXConfiguration FOLLOWER_FEEDER_MOTOR_CONFIG =
new TalonFXConfiguration()
.withMotorOutput(
new MotorOutputConfigs().withInverted(InvertedValue.CounterClockwise_Positive))
.withCurrentLimits(
new CurrentLimitsConfigs()
.withSupplyCurrentLimit(Amps.of(30))
.withStatorCurrentLimit(Amps.of(60)));
.withStatorCurrentLimit(Amps.of(60)))
.withSlot0(new Slot0Configs().withKS(0.2).withKV(0.116));

// TODO: Change this later to the actual number.
public static final double FEEDER_MOTOR_TO_ROLLER_GEARING = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/team2813/subsystems/hopper/HopperIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public interface HopperIO {
@AutoLog
class HopperIOInputs {
// Roller/Magazine
public Voltage mainFeederMotorVoltage = Volts.of(0);
public AngularVelocity mainFeederMotorRPS = RotationsPerSecond.of(0);
public Current mainFeederMotorStatorCurrent = Amps.of(0);
public Current mainFeederMotorSupplyCurrent = Amps.of(0);
public Voltage feederMotorVoltage = Volts.of(0);
public AngularVelocity feederMotorRPS = RotationsPerSecond.of(0);
public Current feederMotorStatorCurrent = Amps.of(0);
public Current feederMotorSupplyCurrent = Amps.of(0);
}

/**
Expand Down
39 changes: 19 additions & 20 deletions src/main/java/com/team2813/subsystems/hopper/HopperIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,44 @@
import edu.wpi.first.units.measure.Voltage;

public class HopperIOReal implements HopperIO {
private final TalonFX mainFeederMotor; // Top magazine motor.
private final TalonFX feederMotor; // Top magazine motor.

// Prep the fields we will log for each motor.
// By having a status signal stored, we can refresh all the motor values at once.
// Before, we would refresh all the motor values just to get one value, causing a performance
// issue.
StatusSignal<Voltage> mainFeederVoltage;
StatusSignal<AngularVelocity> mainFeederRPS;
StatusSignal<Current> mainFeederStatorCurrent; // Motor Control to Stator
StatusSignal<Current> mainFeederSupplyCurrent; // Battery to Stator
StatusSignal<Voltage> feederVoltage;
StatusSignal<AngularVelocity> feederRPS;
StatusSignal<Current> feederStatorCurrent; // Motor Control to Stator
StatusSignal<Current> feederSupplyCurrent; // Battery to Stator

public HopperIOReal() {
mainFeederMotor = new TalonFX(Constants.MAIN_FEEDER_MOTOR_CAN_ID);
mainFeederMotor.getConfigurator().apply(HopperConstants.MAIN_ROLLER_MOTOR_CONFIG);
feederMotor = new TalonFX(Constants.FEEDER_MOTOR_CAN_ID);
feederMotor.getConfigurator().apply(HopperConstants.FEEDER_MOTOR_CONFIG);

mainFeederVoltage = mainFeederMotor.getMotorVoltage();
mainFeederRPS = mainFeederMotor.getRotorVelocity();
mainFeederStatorCurrent = mainFeederMotor.getStatorCurrent();
mainFeederSupplyCurrent = mainFeederMotor.getSupplyCurrent();
feederVoltage = feederMotor.getMotorVoltage();
feederRPS = feederMotor.getRotorVelocity();
feederStatorCurrent = feederMotor.getStatorCurrent();
feederSupplyCurrent = feederMotor.getSupplyCurrent();

BaseStatusSignal.setUpdateFrequencyForAll(
50, mainFeederVoltage, mainFeederRPS, mainFeederStatorCurrent, mainFeederSupplyCurrent);
50, feederVoltage, feederRPS, feederStatorCurrent, feederSupplyCurrent);

ParentDevice.optimizeBusUtilizationForAll(mainFeederMotor);
ParentDevice.optimizeBusUtilizationForAll(feederMotor);
}

@Override
public void updateState(HopperIOInputs inputs) {
BaseStatusSignal.refreshAll(
mainFeederVoltage, mainFeederRPS, mainFeederStatorCurrent, mainFeederSupplyCurrent);
BaseStatusSignal.refreshAll(feederVoltage, feederRPS, feederStatorCurrent, feederSupplyCurrent);

inputs.mainFeederMotorVoltage = mainFeederVoltage.getValue();
inputs.mainFeederMotorRPS = mainFeederRPS.getValue();
inputs.mainFeederMotorStatorCurrent = mainFeederStatorCurrent.getValue();
inputs.mainFeederMotorSupplyCurrent = mainFeederSupplyCurrent.getValue();
inputs.feederMotorVoltage = feederVoltage.getValue();
inputs.feederMotorRPS = feederRPS.getValue();
inputs.feederMotorStatorCurrent = feederStatorCurrent.getValue();
inputs.feederMotorSupplyCurrent = feederSupplyCurrent.getValue();
}

@Override
public void setMotorVoltage(Voltage rollerVoltage, Voltage feederVoltage) {
mainFeederMotor.setVoltage(rollerVoltage.in(Volts));
feederMotor.setVoltage(rollerVoltage.in(Volts));
}
}
28 changes: 13 additions & 15 deletions src/main/java/com/team2813/subsystems/hopper/HopperIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@
public class HopperIOSim implements HopperIO {

// Roller Motor simulation declaration.
private final TalonFX mainFeederMotor;
private final TalonFXSimState mainFeederMotorSimState;
private final TalonFX feederMotor;
private final TalonFXSimState feederMotorSimState;

private final FlywheelSim feederSim; // Used for simulating voltage of the roller.

public HopperIOSim() {
mainFeederMotor = new TalonFX(Constants.MAIN_FEEDER_MOTOR_CAN_ID);
mainFeederMotor.getConfigurator().apply(HopperConstants.MAIN_ROLLER_MOTOR_CONFIG);
mainFeederMotorSimState = mainFeederMotor.getSimState();
feederMotor = new TalonFX(Constants.FEEDER_MOTOR_CAN_ID);
feederMotor.getConfigurator().apply(HopperConstants.FEEDER_MOTOR_CONFIG);
feederMotorSimState = feederMotor.getSimState();

// The "0.01" value is the moment of inertia, as the CAD is not complete, a more accurate value
// is unavailable.
feederSim =
new FlywheelSim(
LinearSystemId.createFlywheelSystem(
Expand All @@ -38,26 +36,26 @@ public HopperIOSim() {
public void updateState(HopperIOInputs inputs) {
updateSimulation();

mainFeederMotorSimState.setSupplyVoltage(Volts.of(12));
feederMotorSimState.setSupplyVoltage(Volts.of(12));

inputs.mainFeederMotorVoltage = mainFeederMotor.getMotorVoltage().getValue();
inputs.mainFeederMotorRPS = mainFeederMotor.getRotorVelocity().getValue();
inputs.mainFeederMotorStatorCurrent = mainFeederMotor.getStatorCurrent().getValue();
inputs.mainFeederMotorSupplyCurrent = mainFeederMotor.getSupplyCurrent().getValue();
inputs.feederMotorVoltage = feederMotor.getMotorVoltage().getValue();
inputs.feederMotorRPS = feederMotor.getRotorVelocity().getValue();
inputs.feederMotorStatorCurrent = feederMotor.getStatorCurrent().getValue();
inputs.feederMotorSupplyCurrent = feederMotor.getSupplyCurrent().getValue();
}

public void updateSimulation() {
feederSim.update(Constants.SIM_TIME_PERIOD);

// Feed the velocity and acceleration of the roller simulation into the simulation motors to
// accurately model them.
mainFeederMotorSimState.setRotorAcceleration(feederSim.getAngularAcceleration());
mainFeederMotorSimState.setRotorVelocity(feederSim.getAngularVelocity());
feederMotorSimState.setRotorAcceleration(feederSim.getAngularAcceleration());
feederMotorSimState.setRotorVelocity(feederSim.getAngularVelocity());
}

@Override
public void setMotorVoltage(Voltage rollerVoltage, Voltage feederVoltage) {
// Rollers
mainFeederMotor.setVoltage(rollerVoltage.in(Volts));
feederMotor.setVoltage(rollerVoltage.in(Volts));
}
}
6 changes: 3 additions & 3 deletions vendordeps/AdvantageKit.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "AdvantageKit.json",
"name": "AdvantageKit",
"version": "26.0.0",
"version": "26.0.2",
"uuid": "d820cc26-74e3-11ec-90d6-0242ac120003",
"frcYear": "2026",
"mavenUrls": [
Expand All @@ -12,14 +12,14 @@
{
"groupId": "org.littletonrobotics.akit",
"artifactId": "akit-java",
"version": "26.0.0"
"version": "26.0.2"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.akit",
"artifactId": "akit-wpilibio",
"version": "26.0.0",
"version": "26.0.2",
"skipInvalidPlatforms": false,
"isJar": false,
"validPlatforms": [
Expand Down
Loading
Loading