mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-23 01:21:40 +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:
@@ -196,6 +196,9 @@ PhotonCamera::PhotonCamera(nt::NetworkTableInstance instance,
|
||||
rootTable->GetBooleanTopic("driverMode").Subscribe(false)),
|
||||
driverModePublisher(
|
||||
rootTable->GetBooleanTopic("driverModeRequest").Publish()),
|
||||
fpsLimitSubscriber(rootTable->GetIntegerTopic("fpsLimit").Subscribe(-1)),
|
||||
fpsLimitPublisher(
|
||||
rootTable->GetIntegerTopic("fpsLimitRequest").Publish()),
|
||||
heartbeatSubscriber(
|
||||
rootTable->GetIntegerTopic("heartbeat").Subscribe(-1)),
|
||||
topicNameSubscriber(instance, PHOTON_PREFIX, {.topicsOnly = true}),
|
||||
@@ -322,6 +325,14 @@ void PhotonCamera::SetDriverMode(bool driverMode) {
|
||||
driverModePublisher.Set(driverMode);
|
||||
}
|
||||
|
||||
bool PhotonCamera::GetDriverMode() const { return driverModeSubscriber.Get(); }
|
||||
|
||||
int PhotonCamera::GetFPSLimit() const { return fpsLimitSubscriber.Get(); }
|
||||
|
||||
void PhotonCamera::SetFPSLimit(int fpsLimit) {
|
||||
fpsLimitPublisher.Set(fpsLimit);
|
||||
}
|
||||
|
||||
void PhotonCamera::TakeInputSnapshot() {
|
||||
inputSaveImgEntry.Set(inputSaveImgSubscriber.Get() + 1);
|
||||
}
|
||||
@@ -330,8 +341,6 @@ void PhotonCamera::TakeOutputSnapshot() {
|
||||
outputSaveImgEntry.Set(outputSaveImgSubscriber.Get() + 1);
|
||||
}
|
||||
|
||||
bool PhotonCamera::GetDriverMode() const { return driverModeSubscriber.Get(); }
|
||||
|
||||
void PhotonCamera::SetPipelineIndex(int index) { pipelineIndexPub.Set(index); }
|
||||
|
||||
int PhotonCamera::GetPipelineIndex() const {
|
||||
|
||||
@@ -103,6 +103,16 @@ class PhotonCamera {
|
||||
*/
|
||||
bool GetDriverMode() const;
|
||||
|
||||
/**
|
||||
* @param fpsLimit The FPS limit to set. Use -1 for unlimited FPS.
|
||||
*/
|
||||
void SetFPSLimit(int fpsLimit);
|
||||
|
||||
/**
|
||||
* @return The FPS limit set on the camera, or -1 if no limit is set.
|
||||
*/
|
||||
int GetFPSLimit() const;
|
||||
|
||||
/**
|
||||
* Request the camera to save a new image file from the input
|
||||
* camera stream with overlays.
|
||||
@@ -210,6 +220,9 @@ class PhotonCamera {
|
||||
|
||||
nt::BooleanSubscriber driverModeSubscriber;
|
||||
nt::BooleanPublisher driverModePublisher;
|
||||
nt::IntegerSubscriber fpsLimitSubscriber;
|
||||
nt::IntegerPublisher fpsLimitPublisher;
|
||||
|
||||
nt::IntegerSubscriber ledModeSubscriber;
|
||||
|
||||
nt::IntegerSubscriber heartbeatSubscriber;
|
||||
|
||||
Reference in New Issue
Block a user