Add NT controlled framerate limiter (#2257)

Adds a method to lower the speed of a pipeline over NT, primarily to
reduce power consumption.
This commit is contained in:
Sam Freund
2025-12-29 23:01:10 -06:00
committed by GitHub
parent fddff5dbca
commit 80d3efe00e
16 changed files with 234 additions and 15 deletions

View File

@@ -53,6 +53,9 @@ public class NTTopicSet {
public BooleanPublisher driverModePublisher;
public BooleanSubscriber driverModeSubscriber;
public IntegerPublisher fpsLimitPublisher;
public IntegerSubscriber fpsLimitSubscriber;
public DoublePublisher latencyMillisEntry;
public DoublePublisher fpsEntry;
public BooleanPublisher hasTargetEntry;
@@ -100,6 +103,11 @@ public class NTTopicSet {
// Fun little hack to make the request show up
driverModeSubscriber.getTopic().publish().setDefault(false);
fpsLimitPublisher = subTable.getIntegerTopic("fpsLimit").publish();
fpsLimitSubscriber = subTable.getIntegerTopic("fpsLimitRequest").subscribe(-1);
fpsLimitSubscriber.getTopic().publish().setDefault(-1);
latencyMillisEntry = subTable.getDoubleTopic("latencyMillis").publish();
fpsEntry = subTable.getDoubleTopic("fps").publish();
hasTargetEntry = subTable.getBooleanTopic("hasTarget").publish();
@@ -129,6 +137,9 @@ public class NTTopicSet {
if (driverModePublisher != null) driverModePublisher.close();
if (driverModeSubscriber != null) driverModeSubscriber.close();
if (fpsLimitPublisher != null) fpsLimitPublisher.close();
if (fpsLimitSubscriber != null) fpsLimitSubscriber.close();
if (latencyMillisEntry != null) latencyMillisEntry.close();
if (fpsEntry != null) fpsEntry.close();
if (hasTargetEntry != null) hasTargetEntry.close();