mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Robustify setting pipeline index (#790)
This commit is contained in:
@@ -29,6 +29,7 @@ import edu.wpi.first.networktables.BooleanSubscriber;
|
||||
import edu.wpi.first.networktables.DoubleArrayPublisher;
|
||||
import edu.wpi.first.networktables.DoublePublisher;
|
||||
import edu.wpi.first.networktables.IntegerEntry;
|
||||
import edu.wpi.first.networktables.IntegerPublisher;
|
||||
import edu.wpi.first.networktables.IntegerSubscriber;
|
||||
import edu.wpi.first.networktables.MultiSubscriber;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
@@ -60,7 +61,8 @@ public class PhotonCamera {
|
||||
DoublePublisher targetSkewEntry;
|
||||
StringSubscriber versionEntry;
|
||||
IntegerEntry inputSaveImgEntry, outputSaveImgEntry;
|
||||
IntegerEntry pipelineIndexEntry, ledModeEntry;
|
||||
IntegerPublisher pipelineIndexRequest, ledModeRequest;
|
||||
IntegerSubscriber pipelineIndexState, ledModeState;
|
||||
IntegerSubscriber heartbeatEntry;
|
||||
|
||||
public void close() {
|
||||
@@ -77,8 +79,11 @@ public class PhotonCamera {
|
||||
versionEntry.close();
|
||||
inputSaveImgEntry.close();
|
||||
outputSaveImgEntry.close();
|
||||
pipelineIndexEntry.close();
|
||||
ledModeEntry.close();
|
||||
pipelineIndexRequest.close();
|
||||
pipelineIndexState.close();
|
||||
ledModeRequest.close();
|
||||
ledModeState.close();
|
||||
pipelineIndexRequest.close();
|
||||
}
|
||||
|
||||
private final String path;
|
||||
@@ -122,9 +127,11 @@ public class PhotonCamera {
|
||||
driverModeSubscriber = rootTable.getBooleanTopic("driverModeRequest").subscribe(false);
|
||||
inputSaveImgEntry = rootTable.getIntegerTopic("inputSaveImgCmd").getEntry(0);
|
||||
outputSaveImgEntry = rootTable.getIntegerTopic("outputSaveImgCmd").getEntry(0);
|
||||
pipelineIndexEntry = rootTable.getIntegerTopic("pipelineIndex").getEntry(0);
|
||||
pipelineIndexRequest = rootTable.getIntegerTopic("pipelineIndexRequest").publish();
|
||||
pipelineIndexState = rootTable.getIntegerTopic("pipelineIndexState").subscribe(0);
|
||||
heartbeatEntry = rootTable.getIntegerTopic("heartbeat").subscribe(-1);
|
||||
ledModeEntry = mainTable.getIntegerTopic("ledMode").getEntry(-1);
|
||||
ledModeRequest = mainTable.getIntegerTopic("ledModeRequest").publish();
|
||||
ledModeState = mainTable.getIntegerTopic("ledModeState").subscribe(-1);
|
||||
versionEntry = mainTable.getStringTopic("version").subscribe("");
|
||||
|
||||
m_topicNameSubscriber =
|
||||
@@ -215,7 +222,7 @@ public class PhotonCamera {
|
||||
* @return The active pipeline index.
|
||||
*/
|
||||
public int getPipelineIndex() {
|
||||
return (int) pipelineIndexEntry.get(0);
|
||||
return (int) pipelineIndexState.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +231,7 @@ public class PhotonCamera {
|
||||
* @param index The active pipeline index.
|
||||
*/
|
||||
public void setPipelineIndex(int index) {
|
||||
pipelineIndexEntry.set(index);
|
||||
pipelineIndexRequest.set(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +240,7 @@ public class PhotonCamera {
|
||||
* @return The current LED mode.
|
||||
*/
|
||||
public VisionLEDMode getLEDMode() {
|
||||
int value = (int) ledModeEntry.get(-1);
|
||||
int value = (int) ledModeState.get(-1);
|
||||
switch (value) {
|
||||
case 0:
|
||||
return VisionLEDMode.kOff;
|
||||
@@ -253,7 +260,7 @@ public class PhotonCamera {
|
||||
* @param led The mode to set to.
|
||||
*/
|
||||
public void setLED(VisionLEDMode led) {
|
||||
ledModeEntry.set(led.value);
|
||||
ledModeRequest.set(led.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user