Skip to content

Commit d97d28e

Browse files
authored
Merge pull request #113 from strykeforce/2025-initial
2025 initial
2 parents 4312924 + c452bef commit d97d28e

20 files changed

+979
-1264
lines changed

build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ plugins {
44
id "java"
55
id "idea"
66
id "maven-publish"
7-
id "org.jetbrains.kotlin.jvm" version "1.7.21"
8-
id "com.google.devtools.ksp" version "1.7.21-1.0.8"
9-
id "edu.wpi.first.GradleRIO" version "2024.2.1"
7+
id "org.jetbrains.kotlin.jvm" version "1.9.0" //1.7.21
8+
id "com.google.devtools.ksp" version "1.9.0-1.0.13" //1.7.21-1.0.8
9+
id "edu.wpi.first.GradleRIO" version "2025.1.1"
1010
id "com.diffplug.spotless" version "6.12.1"
1111
}
1212

1313
group = "org.strykeforce"
14-
version = "24.0.6"
14+
version = "25.0.0"
1515

16-
sourceCompatibility = JavaVersion.VERSION_17
17-
targetCompatibility = JavaVersion.VERSION_17
16+
java {
17+
targetCompatibility = JavaVersion.VERSION_17
18+
sourceCompatibility = JavaVersion.VERSION_17
19+
}
1820

1921
deploy {
2022
targets {
@@ -82,7 +84,7 @@ dependencies {
8284
testImplementation("org.junit.jupiter:junit-jupiter")
8385
testImplementation('org.assertj:assertj-core:3.23.1')
8486
testImplementation('org.mockito:mockito-junit-jupiter:4.8.0')
85-
testImplementation("org.mockito.kotlin:mockito-kotlin:4.0.0")
87+
testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") //4.0.0
8688
testImplementation('org.skyscreamer:jsonassert:1.5.1')
8789
testRuntimeOnly('ch.qos.logback:logback-classic:1.4.4')
8890

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginManagement {
44
repositories {
55
mavenLocal()
66
gradlePluginPortal()
7-
String frcYear = '2024'
7+
String frcYear = '2025'
88
File frcHome
99
if (OperatingSystem.current().isWindows()) {
1010
String publicFolder = System.getenv('PUBLIC')

src/main/java/org/strykeforce/gyro/SF_AHRS.java

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
11
package org.strykeforce.gyro;
22

3-
import com.kauailabs.navx.frc.AHRS;
3+
// import com.kauailabs.navx.frc.AHRS;
4+
import com.studica.frc.AHRS;
5+
import com.studica.frc.AHRS.NavXComType;
6+
import com.studica.frc.AHRS.NavXUpdateRate;
47
import edu.wpi.first.math.geometry.Rotation2d;
5-
import edu.wpi.first.wpilibj.I2C;
6-
import edu.wpi.first.wpilibj.SPI;
7-
import edu.wpi.first.wpilibj.SerialPort;
88

9-
public class SF_AHRS extends AHRS implements Gyro {
9+
public class SF_AHRS implements Gyro {
1010
private AHRS ahrs;
1111

12-
public SF_AHRS(SPI.Port spi_port_id, byte update_rate_hz) {
13-
ahrs = new AHRS(spi_port_id, update_rate_hz);
12+
public SF_AHRS(NavXComType comType) {
13+
ahrs = new AHRS(comType);
1414
}
1515

16-
public SF_AHRS(SPI.Port spi_port_id, int spi_bitrate, byte update_rate_hz) {
17-
ahrs = new AHRS(spi_port_id, spi_bitrate, update_rate_hz);
16+
public SF_AHRS(NavXComType comType, NavXUpdateRate updateRate) {
17+
ahrs = new AHRS(comType, updateRate);
1818
}
1919

20-
public SF_AHRS(I2C.Port i2c_port_id, byte update_rate_hz) {
21-
ahrs = new AHRS(i2c_port_id, update_rate_hz);
22-
}
23-
24-
public SF_AHRS(SerialPort.Port serial_port_id, SerialDataType data_type, byte update_rate_hz) {
25-
ahrs = new AHRS(serial_port_id, data_type, update_rate_hz);
26-
}
27-
28-
public SF_AHRS(SPI.Port spi_port_id) {
29-
ahrs = new AHRS(spi_port_id);
30-
}
31-
32-
public SF_AHRS(I2C.Port i2c_port_id) {
33-
ahrs = new AHRS(i2c_port_id);
34-
}
35-
36-
public SF_AHRS(SerialPort.Port serial_port_id) {
37-
ahrs = new AHRS(serial_port_id);
20+
public SF_AHRS(NavXComType comType, int customRateHz) {
21+
ahrs = new AHRS(comType, customRateHz);
3822
}
3923

4024
public SF_AHRS() {
41-
ahrs = new AHRS();
25+
ahrs = new AHRS(NavXComType.kMXP_SPI);
4226
}
4327

4428
@Override

src/main/java/org/strykeforce/gyro/SF_PIGEON2.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
package org.strykeforce.gyro;
22

3+
import com.ctre.phoenix6.StatusSignal;
34
import com.ctre.phoenix6.configs.Pigeon2Configuration;
45
import com.ctre.phoenix6.configs.Pigeon2Configurator;
56
import com.ctre.phoenix6.hardware.Pigeon2;
67
import edu.wpi.first.math.geometry.Rotation2d;
8+
import edu.wpi.first.units.measure.Angle;
9+
import edu.wpi.first.units.measure.AngularVelocity;
710
import org.strykeforce.telemetry.TelemetryService;
811

912
public class SF_PIGEON2 implements Gyro {
1013
private Pigeon2 pigeon2;
1114
private Pigeon2Configurator configurator;
15+
private StatusSignal<Angle> yawGetter;
16+
private StatusSignal<AngularVelocity> yawRateGetter;
1217

1318
public SF_PIGEON2(int deviceId) {
1419
pigeon2 = new Pigeon2(deviceId);
@@ -18,6 +23,8 @@ public SF_PIGEON2(int deviceId) {
1823
public SF_PIGEON2(int deviceId, String canbus) {
1924
pigeon2 = new Pigeon2(deviceId, canbus);
2025
configurator = pigeon2.getConfigurator();
26+
yawGetter = pigeon2.getYaw();
27+
yawRateGetter = pigeon2.getAngularVelocityZWorld();
2128
}
2229

2330
@Override
@@ -27,12 +34,12 @@ public void reset() {
2734

2835
@Override
2936
public double getAngle() {
30-
return pigeon2.getAngle();
37+
return -yawGetter.refresh().getValueAsDouble();
3138
}
3239

3340
@Override
3441
public double getRate() {
35-
return pigeon2.getRate();
42+
return -yawRateGetter.refresh().getValueAsDouble();
3643
}
3744

3845
@Override
@@ -49,15 +56,15 @@ public void applyConfig(Pigeon2Configuration config) {
4956
}
5057

5158
public Double getRoll() {
52-
return pigeon2.getRoll().getValue();
59+
return pigeon2.getRoll().getValueAsDouble();
5360
}
5461

5562
public Double getPitch() {
56-
return pigeon2.getPitch().getValue();
63+
return pigeon2.getPitch().getValueAsDouble();
5764
}
5865

5966
public Double getYaw() {
60-
return pigeon2.getYaw().getValue();
67+
return pigeon2.getYaw().getValueAsDouble();
6168
}
6269

6370
public void registerWith(TelemetryService telemetryService) {

0 commit comments

Comments
 (0)