Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
Spindexer gets treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatXliner committed Oct 31, 2024
1 parent 11c6e02 commit c7dc155
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 268 deletions.
10 changes: 5 additions & 5 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.shooter.ShooterIOSim;
import frc.robot.subsystems.shooter.ShooterIOTalonFX;
import frc.robot.subsystems.spindex.ShooterFeederIOTalonFX;
import frc.robot.subsystems.spindex.BaseSpindexConstants;
import frc.robot.subsystems.spindex.Spindex;
import frc.robot.subsystems.spindex.SpindexConstants;
import frc.robot.subsystems.spindex.SpindexIOTalonFX;
import frc.robot.subsystems.spindex.SpindexFeederConstants;
import frc.robot.subsystems.swerve.*;
import frc.robot.subsystems.turret.*;
import frc.robot.subsystems.vision.Vision;
Expand Down Expand Up @@ -104,9 +104,9 @@ public class RobotContainer {
private final Spindex spindex =
new Spindex(
Constants.FeatureFlags.kSpindexEnabled,
new SpindexIOTalonFX(),
new ShooterFeederIOTalonFX(),
new BeamBreakIOBanner(SpindexConstants.kSpindexBeamBreakDIO));
new SingleMotorSubsystemIOTalonFX<SpindexConstants>(),
new SingleMotorSubsystemIOTalonFX<SpindexFeederConstants>(),
new BeamBreakIOBanner(BaseSpindexConstants.kSpindexBeamBreakDIO));
private final Vision vision = new Vision(new VisionIOLimelight());

private final Superstructure superstructure =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2024 FRC 3256
// https://github.com/Team3256
//
// Use of this source code is governed by a
// license that can be found in the LICENSE file at
// the root directory of this project.

package frc.robot.subsystems.spindex;

public class BaseSpindexConstants {
public static int kFlashConfigRetries = 5;
public static double kStatusSignalUpdateFrequency = 50; // idk if this is right
public static boolean kUseMotionMagic = false;
public static int kSpindexBeamBreakDIO = 1;
}
29 changes: 0 additions & 29 deletions src/main/java/frc/robot/subsystems/spindex/ShooterFeederIO.java

This file was deleted.

This file was deleted.

29 changes: 15 additions & 14 deletions src/main/java/frc/robot/subsystems/spindex/Spindex.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import frc.robot.subsystems.BeamBreakIO;
import frc.robot.subsystems.BeamBreakIOInputsAutoLogged;
import frc.robot.utils.DisableSubsystem;
import frc.robot.utils.generics.SingleMotorSubsystemIO;
import frc.robot.utils.generics.SingleMotorSubsystemInputsAutoLogged;
import org.littletonrobotics.junction.Logger;

// Copyright (c) 2024 FRC 3256
Expand All @@ -23,24 +25,25 @@

public class Spindex extends DisableSubsystem {

private final SpindexIO spindexIO;
private final SpindexIOInputsAutoLogged spindexIOAutoLogged = new SpindexIOInputsAutoLogged();
private final SingleMotorSubsystemIO spindexIO;
private final SingleMotorSubsystemInputsAutoLogged spindexIOAutoLogged =
new SingleMotorSubsystemInputsAutoLogged();

private final BeamBreakIO beamBreakIO;
private final BeamBreakIOInputsAutoLogged beamBreakIOAutoLogged =
new BeamBreakIOInputsAutoLogged();

private final ShooterFeederIO shooterFeederIO;
private final ShooterFeederIOInputsAutoLogged shooterFeederIOAutoLogged =
new ShooterFeederIOInputsAutoLogged();
private final SingleMotorSubsystemIO shooterFeederIO;
private final SingleMotorSubsystemInputsAutoLogged shooterFeederIOAutoLogged =
new SingleMotorSubsystemInputsAutoLogged();

public final Trigger debouncedBeamBreak = new Trigger(() -> beamBreakIOAutoLogged.beamBroken);

// private beambreak Beambreak = new beamreak(1)
public Spindex(
boolean disabled,
SpindexIO spindexIO,
ShooterFeederIO shooterFeeder,
SingleMotorSubsystemIO spindexIO,
SingleMotorSubsystemIO shooterFeeder,
BeamBreakIO beamBreakIO) {
super(disabled);
this.spindexIO = spindexIO;
Expand All @@ -59,21 +62,19 @@ public void periodic() {
}

public Command setSpindexVoltage(double voltage) {
return this.run(() -> spindexIO.setSpindexVoltage(voltage)).finallyDo(spindexIO::off);
return this.run(() -> spindexIO.setVoltage(voltage)).finallyDo(spindexIO::off);
}

public Command setSpindexVelocity(double velocity) {
return this.run(() -> spindexIO.setSpindexVelocity(velocity)).finallyDo(spindexIO::off);
return this.run(() -> spindexIO.setVelocity(velocity)).finallyDo(spindexIO::off);
}

public Command setShooterFeederVoltage(double voltage) {
return this.run(() -> shooterFeederIO.setFeederVoltage(voltage))
.finallyDo(shooterFeederIO::off);
return this.run(() -> shooterFeederIO.setVoltage(voltage)).finallyDo(shooterFeederIO::off);
}

public Command setShooterFeederVelocity(double velocity) {
return this.run(() -> shooterFeederIO.setFeederVelocity(velocity))
.finallyDo(shooterFeederIO::off);
return this.run(() -> shooterFeederIO.setVelocity(velocity)).finallyDo(shooterFeederIO::off);
}

public Command goToShooter() {
Expand All @@ -83,7 +84,7 @@ public Command goToShooter() {
}

public Command feedNoteToShooter() {
return setShooterFeederVoltage(SpindexConstants.shooterFeederVoltage)
return setShooterFeederVoltage(SpindexFeederConstants.shooterFeederVoltage)
.until(() -> beamBreakIOAutoLogged.beamBroken)
.finallyDo(shooterFeederIO::off);
}
Expand Down
44 changes: 15 additions & 29 deletions src/main/java/frc/robot/subsystems/spindex/SpindexConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

package frc.robot.subsystems.spindex;

import com.ctre.phoenix6.configs.*;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.MotionMagicConfigs;
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 com.ctre.phoenix6.signals.NeutralModeValue;
import frc.robot.utils.generics.SingleMotorConstants;

public class SpindexConstants {
public static final int spindexMotorID = 0;
public static final double spindexMotorSpeedRPS = 0.8;
public static TalonFXConfiguration spindexMotorConfigs =
public class SpindexConstants extends BaseSpindexConstants implements SingleMotorConstants {
public static final int kMotorID = 0;
public static TalonFXConfiguration kMotorConfig =
new TalonFXConfiguration() // TODO: tune
.withSlot0(new Slot0Configs().withKS(0).withKV(0.1).withKP(1).withKI(0).withKD(0))
.withMotorOutput(
Expand All @@ -30,28 +34,10 @@ public class SpindexConstants {
new CurrentLimitsConfigs()
.withStatorCurrentLimitEnable(true)
.withStatorCurrentLimit(80));
;
public static int flashConfigRetries = 5;
public static double updateFrequency = 50; // idk if this is right
public static boolean useMotionMagic = false;
public static int kSpindexBeamBreakDIO = 1;
public static TalonFXConfiguration feederMotorConfigs =
new TalonFXConfiguration() // TODO: tune
.withSlot0(new Slot0Configs().withKS(0).withKV(0.1).withKP(1).withKI(0).withKD(0))
.withMotorOutput(
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Brake)
.withInverted(InvertedValue.Clockwise_Positive))
.withMotionMagic(
new MotionMagicConfigs()
.withMotionMagicAcceleration(120)
.withMotionMagicCruiseVelocity(60)
.withMotionMagicJerk(1200))
.withCurrentLimits(
new CurrentLimitsConfigs()
.withStatorCurrentLimitEnable(true)
.withStatorCurrentLimit(80));
;
public static int shooterFeederMotorID = 43;
public static double shooterFeederVoltage = 8;

public static final double spindexMotorSpeedRPS = 0.8;

public static class SimulationConstants {
public static final double kGearRatio = 1.0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2024 FRC 3256
// https://github.com/Team3256
//
// Use of this source code is governed by a
// license that can be found in the LICENSE file at
// the root directory of this project.

package frc.robot.subsystems.spindex;

import com.ctre.phoenix6.configs.*;
import com.ctre.phoenix6.signals.InvertedValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import frc.robot.utils.generics.SingleMotorConstants;

public class SpindexFeederConstants extends BaseSpindexConstants implements SingleMotorConstants {
public static int kMotorID = 43;
public static TalonFXConfiguration kMotorConfig =
new TalonFXConfiguration() // TODO: tune
.withSlot0(new Slot0Configs().withKS(0).withKV(0.1).withKP(1).withKI(0).withKD(0))
.withMotorOutput(
new MotorOutputConfigs()
.withNeutralMode(NeutralModeValue.Brake)
.withInverted(InvertedValue.Clockwise_Positive))
.withMotionMagic(
new MotionMagicConfigs()
.withMotionMagicAcceleration(120)
.withMotionMagicCruiseVelocity(60)
.withMotionMagicJerk(1200))
.withCurrentLimits(
new CurrentLimitsConfigs()
.withStatorCurrentLimitEnable(true)
.withStatorCurrentLimit(80));
;

public static double shooterFeederVoltage = 8;

public static class SimulationConstants {
public static final double kGearRatio = 1.0;
}
}
29 changes: 0 additions & 29 deletions src/main/java/frc/robot/subsystems/spindex/SpindexIO.java

This file was deleted.

Loading

0 comments on commit c7dc155

Please sign in to comment.