Skip to content
Open
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
2 changes: 1 addition & 1 deletion ThriftTsConfig
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/command/testing/IndexCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public IndexCommand(IndexSubsystem baseSubsystem, double speed) {

@Override
public void execute() {
m_indexSubsystem.runMotor(m_speed);
m_indexSubsystem.runMotors(m_speed);
}

@Override
public void end(boolean interrupted) {
m_indexSubsystem.stopMotor();
m_indexSubsystem.stopMotors();
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/constant/IndexConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
public class IndexConstants {
public static final int indexMotorID = 36;
public static final double indexMotorSpeed = 0.45;
public static final boolean indexMotorInverted = false;
public static final int feedMotorID = 0;
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAN device IDs for Spark Flex controllers are expected to be in the valid CAN ID range (commonly 1–63). Using 0 is typically invalid and will prevent the feed motor from being addressed correctly. Set feedMotorID to the actual configured CAN ID for the feed SparkFlex.

Suggested change
public static final int feedMotorID = 0;
public static final int feedMotorID = 37;

Copilot uses AI. Check for mistakes.
public static final double feedMotorSpeed = 0;
public static final boolean feedMotorInverted = false;
}
25 changes: 17 additions & 8 deletions src/main/java/frc/robot/subsystem/IndexSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class IndexSubsystem extends SubsystemBase {
private static IndexSubsystem instance;

private final SparkFlex m_indexMotor;
private final SparkFlex m_feedMotor;

public static IndexSubsystem GetInstance() {
if (instance == null) {
Expand All @@ -25,22 +26,30 @@ public static IndexSubsystem GetInstance() {

private IndexSubsystem() {
m_indexMotor = new SparkFlex(IndexConstants.indexMotorID, MotorType.kBrushless);
configureMotor();
m_feedMotor = new SparkFlex(IndexConstants.feedMotorID, MotorType.kBrushless);
configureMotors();
}

private void configureMotor() {
SparkFlexConfig config = new SparkFlexConfig();
config.idleMode(IdleMode.kBrake);
config.inverted(true);
private void configureMotors() {
SparkFlexConfig indexConfig = new SparkFlexConfig();
indexConfig.idleMode(IdleMode.kBrake);
indexConfig.inverted(IndexConstants.indexMotorInverted);

m_indexMotor.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
SparkFlexConfig feedConfig = new SparkFlexConfig();
feedConfig.idleMode(IdleMode.kBrake);
feedConfig.inverted(IndexConstants.feedMotorInverted);

m_indexMotor.configure(indexConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
m_feedMotor.configure(feedConfig, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
}

public void runMotor(double speed) {
public void runMotors(double speed) {
m_indexMotor.set(MathUtil.clamp(speed, -1.0, 1.0));
m_feedMotor.set(MathUtil.clamp(speed, -1.0, 1.0));
}

public void stopMotor() {
public void stopMotors() {
m_indexMotor.set(0.0);
m_feedMotor.set(0.0);
}
}
Loading