mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-25 01:41:40 +00:00
Add disabled param for PhotonCamera (#2484)
This commit is contained in:
@@ -65,6 +65,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
BooleanSubscriber driverModeSubscriber;
|
||||
IntegerPublisher fpsLimitPublisher;
|
||||
IntegerSubscriber fpsLimitSubscriber;
|
||||
BooleanSubscriber enabledSubscriber;
|
||||
BooleanPublisher enabledPublisher;
|
||||
StringSubscriber versionEntry;
|
||||
IntegerEntry inputSaveImgEntry, outputSaveImgEntry;
|
||||
IntegerPublisher pipelineIndexRequest, ledModeRequest;
|
||||
@@ -82,6 +84,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
driverModeSubscriber.close();
|
||||
fpsLimitPublisher.close();
|
||||
fpsLimitSubscriber.close();
|
||||
enabledPublisher.close();
|
||||
enabledSubscriber.close();
|
||||
versionEntry.close();
|
||||
inputSaveImgEntry.close();
|
||||
outputSaveImgEntry.close();
|
||||
@@ -155,6 +159,8 @@ public class PhotonCamera implements AutoCloseable {
|
||||
driverModeSubscriber = cameraTable.getBooleanTopic("driverMode").subscribe(false);
|
||||
fpsLimitPublisher = cameraTable.getIntegerTopic("fpsLimitRequest").publish();
|
||||
fpsLimitSubscriber = cameraTable.getIntegerTopic("fpsLimit").subscribe(-1);
|
||||
enabledPublisher = cameraTable.getBooleanTopic("enabledRequest").publish();
|
||||
enabledSubscriber = cameraTable.getBooleanTopic("enabled").subscribe(true);
|
||||
inputSaveImgEntry = cameraTable.getIntegerTopic("inputSaveImgCmd").getEntry(0);
|
||||
outputSaveImgEntry = cameraTable.getIntegerTopic("outputSaveImgCmd").getEntry(0);
|
||||
pipelineIndexRequest = cameraTable.getIntegerTopic("pipelineIndexRequest").publish();
|
||||
@@ -344,8 +350,6 @@ public class PhotonCamera implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the FPS limit set on the camera.
|
||||
*
|
||||
* @return The current FPS limit.
|
||||
*/
|
||||
public int getFPSLimit() {
|
||||
@@ -355,12 +359,32 @@ public class PhotonCamera implements AutoCloseable {
|
||||
/**
|
||||
* Sets the FPS limit on the camera.
|
||||
*
|
||||
* @param fps The FPS limit to set. Set to -1 for unlimited FPS.
|
||||
* <p>A negative FPS limit is treated as no FPS limit, and will run as fast as possible.
|
||||
*
|
||||
* <p>Otherwise, will limit processing to at most the provided FPS limit
|
||||
*
|
||||
* @param fps The FPS limit to set.
|
||||
*/
|
||||
public void setFPSLimit(int fps) {
|
||||
fpsLimitPublisher.set(fps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the camera is enabled, default is true.
|
||||
*
|
||||
* @param enabled Whether to enable the camera.
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
enabledPublisher.set(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the camera is enabled.
|
||||
*/
|
||||
public boolean getEnabled() {
|
||||
return enabledSubscriber.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -157,6 +157,8 @@ PhotonCamera::PhotonCamera(wpi::nt::NetworkTableInstance instance,
|
||||
fpsLimitSubscriber(rootTable->GetIntegerTopic("fpsLimit").Subscribe(-1)),
|
||||
fpsLimitPublisher(
|
||||
rootTable->GetIntegerTopic("fpsLimitRequest").Publish()),
|
||||
enabledSubscriber(rootTable->GetBooleanTopic("enabled").Subscribe(true)),
|
||||
enabledPublisher(rootTable->GetBooleanTopic("enabledRequest").Publish()),
|
||||
heartbeatSubscriber(
|
||||
rootTable->GetIntegerTopic("heartbeat").Subscribe(-1)),
|
||||
topicNameSubscriber(instance, PHOTON_PREFIX, {.topicsOnly = true}),
|
||||
@@ -291,6 +293,10 @@ void PhotonCamera::SetFPSLimit(int fpsLimit) {
|
||||
fpsLimitPublisher.Set(fpsLimit);
|
||||
}
|
||||
|
||||
bool PhotonCamera::GetEnabled() const { return enabledSubscriber.Get(); }
|
||||
|
||||
void PhotonCamera::SetEnabled(bool enabled) { enabledPublisher.Set(enabled); }
|
||||
|
||||
void PhotonCamera::TakeInputSnapshot() {
|
||||
inputSaveImgEntry.Set(inputSaveImgSubscriber.Get() + 1);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,17 @@ class PhotonCamera {
|
||||
bool GetDriverMode() const;
|
||||
|
||||
/**
|
||||
* @param fpsLimit The FPS limit to set. Use -1 for unlimited FPS.
|
||||
* Sets the FPS limit on the camera.
|
||||
*
|
||||
* <p>An FPS of 0 means to pause processing until a FPS limit greater than 0
|
||||
* is set.
|
||||
*
|
||||
* <p>A negative FPS limit is treated as no FPS limit, and will run as fast as
|
||||
* possible.
|
||||
*
|
||||
* <p>Otherwise, will limit processing to at most the provided FPS limit
|
||||
*
|
||||
* @param fps The FPS limit to set.
|
||||
*/
|
||||
void SetFPSLimit(int fpsLimit);
|
||||
|
||||
@@ -113,6 +123,17 @@ class PhotonCamera {
|
||||
*/
|
||||
int GetFPSLimit() const;
|
||||
|
||||
/**
|
||||
* Sets whether the camera is enabled, default is true.
|
||||
* @param enabled Whether to enable the camera.
|
||||
*/
|
||||
void SetEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @return Whether the camera is enabled.
|
||||
*/
|
||||
bool GetEnabled() const;
|
||||
|
||||
/**
|
||||
* Request the camera to save a new image file from the input
|
||||
* camera stream with overlays.
|
||||
@@ -233,6 +254,8 @@ class PhotonCamera {
|
||||
wpi::nt::BooleanPublisher driverModePublisher;
|
||||
wpi::nt::IntegerSubscriber fpsLimitSubscriber;
|
||||
wpi::nt::IntegerPublisher fpsLimitPublisher;
|
||||
wpi::nt::BooleanSubscriber enabledSubscriber;
|
||||
wpi::nt::BooleanPublisher enabledPublisher;
|
||||
|
||||
wpi::nt::IntegerSubscriber ledModeSubscriber;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user