11package org.strykeforce.telemetry.measurable
22
33import 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