Skip to content

Commit 459d402

Browse files
committed
Implement Registrable for MeasurableSubsystem
1 parent 6445ec3 commit 459d402

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/main/java/org/strykeforce/swerve/SwerveModule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ default void setDesiredState(SwerveModuleState desiredState) {
5959
* Loads the current azimuth absolute encoder reference position and sets selected sensor encoder.
6060
*/
6161
void loadAndSetAzimuthZeroReference();
62-
6362
}

src/main/kotlin/org/strykeforce/telemetry/measurable/MeasurableSubsystem.kt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
11
package org.strykeforce.telemetry.measurable
22

33
import edu.wpi.first.wpilibj2.command.SubsystemBase
4+
import org.strykeforce.telemetry.Registrable
5+
import org.strykeforce.telemetry.TelemetryService
46

5-
abstract class MeasurableSubsystem() : SubsystemBase(), Measurable {
7+
/**
8+
* A [Subsystem] that can send telemetry to the Third Coast grapher.
9+
*
10+
* To implement, override the [Measurable.measures] method, for example:
11+
*
12+
* <code><pre>
13+
* @Override
14+
* public Set<Measure> getMeasures() {
15+
* return Set.of(
16+
* new Measure("Gyro Rotation2d (deg)", () -> swerveDrive.getHeading().getDegrees()),
17+
* new Measure("Gyro Angle (deg)", swerveDrive::getGyroAngle),
18+
* new Measure("Odometry X", () -> swerveDrive.getPoseMeters().getX()),
19+
* new Measure("Odometry Y", () -> swerveDrive.getPoseMeters().getY()),
20+
* );
21+
* }</pre></code>
22+
*
23+
* The robot will call [registerWith] during initialization, default behavior is to register this
24+
* subsystem with the [TelemetryService]. If you wish to additionally register internal classes with
25+
* the telemetry service, override the [registerWith] method, for example:
26+
*
27+
* <code><pre>
28+
* @Override
29+
* public void registerWith(TelemetryService: telemetryService) {
30+
* super.registerWith(telemetryService);
31+
* telemetryService.register(talon);
32+
* }</pre></code>
33+
*/
34+
abstract class MeasurableSubsystem() : SubsystemBase(), Measurable, Registrable {
635

736
override val description = name
837

@@ -16,4 +45,6 @@ abstract class MeasurableSubsystem() : SubsystemBase(), Measurable {
1645
val result = type.compareTo(other.type)
1746
return if (result != 0) result else deviceId.compareTo(other.deviceId)
1847
}
48+
49+
override fun registerWith(telemetryService: TelemetryService) = telemetryService.register(this)
1950
}

0 commit comments

Comments
 (0)