Skip to content
Merged
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 buildSrc/src/main/groovy/java-common-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ javadoc {
// CTRE (Phoenix 5 & 6)
links += "https://api.ctr-electronics.com/phoenix6/release/java/"
// WPILib
links += "https://github.wpilib.org/allwpilib/docs/2027/java/"
links += "https://github.wpilib.org/allwpilib/docs/release/java/"
// REVLib
links += "https://codedocs.revrobotics.com/java/"
// PhotonVision
Expand Down
2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java-common-conventions'
id 'edu.wpi.first.GradleRIO' version '2025.1.1'
id 'edu.wpi.first.GradleRIO' version '2026.1.1-beta-1'
id 'maven-publish'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@

import static com.team2813.lib2813.util.InputValidation.checkCanId;

import com.ctre.phoenix6.CANBus;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
import com.ctre.phoenix6.configs.SlotConfigs;
import com.ctre.phoenix6.configs.TalonFXConfiguration;
import com.ctre.phoenix6.configs.TalonFXConfigurator;
import com.ctre.phoenix6.controls.*;
import com.ctre.phoenix6.hardware.TalonFX;
import com.ctre.phoenix6.signals.MotorAlignmentValue;
import com.ctre.phoenix6.signals.NeutralModeValue;
import com.team2813.lib2813.control.ControlMode;
import com.team2813.lib2813.control.DeviceInformation;
Expand All @@ -37,6 +39,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

public class TalonFXWrapper implements PIDMotor {
/** A list of followers, so that they aren't garbage collected */
Expand Down Expand Up @@ -225,31 +228,45 @@ public void configPID(double p, double i, double d) {
configPIDF(0, p, i, d, 0);
}

@Deprecated(forRemoval = true)
public void addFollower(int deviceNumber, String canbus, InvertType invertType) {
addFollower(deviceNumber, new CANBus(canbus), invertType);
}

public void addFollower(int deviceNumber, CANBus canbus, InvertType invertType) {
TalonFX follower = new TalonFX(checkCanId(deviceNumber), canbus);
if (InvertType.rotationValues.contains(invertType)) {
Optional<MotorAlignmentValue> alignmentValue = toMotorAlignmentValue(invertType);
if (alignmentValue.isEmpty()) {
TalonFXConfiguration conf = new TalonFXConfiguration();
// guaranteed to succeed
conf.MotorOutput.Inverted = invertType.phoenixInvert().orElseThrow(AssertionError::new);
follower.setControl(new StrictFollower(information.id()));
} else {
follower.setControl(
new Follower(information.id(), invertType.equals(InvertType.OPPOSE_MASTER)));
follower.setControl(new Follower(information.id(), alignmentValue.get()));
}
followers.add(follower); // add to follower list so TalonFX follower object is preserved
}

public void addFollower(int deviceNumber, InvertType invertType) {
TalonFX follower = new TalonFX(checkCanId(deviceNumber));
if (InvertType.rotationValues.contains(invertType)) {
Optional<MotorAlignmentValue> alignmentValue = toMotorAlignmentValue(invertType);
if (alignmentValue.isEmpty()) {
TalonFXConfiguration conf = new TalonFXConfiguration();
// guaranteed to succeed
conf.MotorOutput.Inverted = invertType.phoenixInvert().orElseThrow(AssertionError::new);
follower.setControl(new StrictFollower(information.id()));
} else {
follower.setControl(
new Follower(information.id(), invertType.equals(InvertType.OPPOSE_MASTER)));
follower.setControl(new Follower(information.id(), alignmentValue.get()));
}
followers.add(follower); // add to follower list so TalonFX follower object is preserved
}

private static Optional<MotorAlignmentValue> toMotorAlignmentValue(InvertType invertType) {
if (InvertType.rotationValues.contains(invertType)) {
return Optional.empty();
}
return invertType.equals(InvertType.FOLLOW_MASTER)
? Optional.of(MotorAlignmentValue.Aligned)
: Optional.of(MotorAlignmentValue.Opposed);
}
}
Loading
Loading