Skip to content

Commit 7c4d49b

Browse files
committed
make swerve work with talonFX
1 parent 76e2268 commit 7c4d49b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group = 'org.strykeforce'
11-
version = '20.1.1'
11+
version = '20.2.0'
1212

1313
sourceCompatibility = JavaVersion.VERSION_11
1414
targetCompatibility = JavaVersion.VERSION_11

src/main/java/org/strykeforce/thirdcoast/swerve/Wheel.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.strykeforce.thirdcoast.swerve.SwerveDrive.DriveMode.TELEOP;
55

66
import com.ctre.phoenix.ErrorCode;
7+
import com.ctre.phoenix.motorcontrol.can.BaseTalon;
78
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
89
import java.util.Objects;
910
import java.util.function.DoubleConsumer;
@@ -32,7 +33,7 @@ public class Wheel {
3233

3334
private static final Logger logger = LoggerFactory.getLogger(Wheel.class);
3435
private final double driveSetpointMax;
35-
private final TalonSRX driveTalon;
36+
private final BaseTalon driveTalon;
3637
private final TalonSRX azimuthTalon;
3738
protected DoubleConsumer driver;
3839
private boolean isInverted = false;
@@ -49,7 +50,7 @@ public class Wheel {
4950
* @param drive the configured drive TalonSRX
5051
* @param driveSetpointMax scales closed-loop drive output to this value when drive setpoint = 1.0
5152
*/
52-
public Wheel(TalonSRX azimuth, TalonSRX drive, double driveSetpointMax) {
53+
public Wheel(TalonSRX azimuth, BaseTalon drive, double driveSetpointMax) {
5354
this.driveSetpointMax = driveSetpointMax;
5455
azimuthTalon = Objects.requireNonNull(azimuth);
5556
driveTalon = Objects.requireNonNull(drive);
@@ -184,7 +185,7 @@ public TalonSRX getAzimuthTalon() {
184185
*
185186
* @return drive Talon instance used by wheel
186187
*/
187-
public TalonSRX getDriveTalon() {
188+
public BaseTalon getDriveTalon() {
188189
return driveTalon;
189190
}
190191

src/main/kotlin/org/strykeforce/thirdcoast/telemetry/TelemetryService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class TelemetryService(private val telemetryControllerFactory: Function<Inventor
119119
*/
120120
fun register(swerveDrive: SwerveDrive) = swerveDrive.wheels.forEach {
121121
register(TalonSRXItem(it.azimuthTalon))
122-
register(TalonSRXItem(it.driveTalon))
122+
if(it.driveTalon is TalonSRX) register(TalonSRXItem(it.driveTalon as TalonSRX))
123+
else if(it.driveTalon is TalonFX) register(TalonFXItem(it.driveTalon as TalonFX))
124+
else throw IllegalArgumentException()
123125
}
124126

125127
/**

0 commit comments

Comments
 (0)