mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
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:
@@ -66,6 +66,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
PacketSubscriber<PhotonPipelineResult> resultSubscriber;
|
||||
BooleanPublisher driverModePublisher;
|
||||
BooleanSubscriber driverModeSubscriber;
|
||||
IntegerPublisher fpsLimitPublisher;
|
||||
IntegerSubscriber fpsLimitSubscriber;
|
||||
StringSubscriber versionEntry;
|
||||
IntegerEntry inputSaveImgEntry, outputSaveImgEntry;
|
||||
IntegerPublisher pipelineIndexRequest, ledModeRequest;
|
||||
@@ -81,6 +83,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
resultSubscriber.close();
|
||||
driverModePublisher.close();
|
||||
driverModeSubscriber.close();
|
||||
fpsLimitPublisher.close();
|
||||
fpsLimitSubscriber.close();
|
||||
versionEntry.close();
|
||||
inputSaveImgEntry.close();
|
||||
outputSaveImgEntry.close();
|
||||
@@ -144,6 +148,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
resultSubscriber = new PacketSubscriber<>(rawBytesEntry, PhotonPipelineResult.photonStruct);
|
||||
driverModePublisher = cameraTable.getBooleanTopic("driverModeRequest").publish();
|
||||
driverModeSubscriber = cameraTable.getBooleanTopic("driverMode").subscribe(false);
|
||||
fpsLimitPublisher = cameraTable.getIntegerTopic("fpsLimitRequest").publish();
|
||||
fpsLimitSubscriber = cameraTable.getIntegerTopic("fpsLimit").subscribe(-1);
|
||||
inputSaveImgEntry = cameraTable.getIntegerTopic("inputSaveImgCmd").getEntry(0);
|
||||
outputSaveImgEntry = cameraTable.getIntegerTopic("outputSaveImgCmd").getEntry(0);
|
||||
pipelineIndexRequest = cameraTable.getIntegerTopic("pipelineIndexRequest").publish();
|
||||
@@ -373,6 +379,24 @@ public class PhotonCamera implements AutoCloseable {
|
||||
driverModePublisher.set(driverMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FPS limit set on the camera.
|
||||
*
|
||||
* @return The current FPS limit.
|
||||
*/
|
||||
public int getFPSLimit() {
|
||||
return (int) fpsLimitSubscriber.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the FPS limit on the camera.
|
||||
*
|
||||
* @param fps The FPS limit to set. Set to -1 for unlimited FPS.
|
||||
*/
|
||||
public void setFPSLimit(int fps) {
|
||||
fpsLimitPublisher.set(fps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the camera to save a new image file from the input camera stream with overlays. Images
|
||||
* take up space in the filesystem of the PhotonCamera. Calling it frequently will fill up disk
|
||||
|
||||
Reference in New Issue
Block a user