Compare commits

...

2 Commits

Author SHA1 Message Date
Matt
b2d939b3b5 Avoid implicit downcast in corner detection (#219) 2021-01-08 02:42:54 -05:00
Chris Gerth
f7e29a1992 Update which-cam-controls-LEDs logic (#220)
Modified VisionModule.java to cause any camera the either has a vendor-defined FOV or the PiCam quirks to control the LED state.

This is a bit of a patch, and directly assumes that piCam's are the devices primarily used for vision processing.

This fixes a tiny bit of pain experienced with a pi3b + picam v1 + usb Cam where not having the USB cam causes the LED's to be working normally, but plugging in the USB cam causes them to be always off.

Parallel issue entered in documentation to add this to known limitations of photon - if you had a set of all usb cameras, we wouldn't know which one is being used for vision processing, and would not be able to control the LED's accordingly. The ultimate solution is just to have teams control the NT entry themselves, which is easy enough. But, docs shouild be updated to reflect that.
2021-01-07 23:42:05 -08:00
2 changed files with 12 additions and 5 deletions

View File

@@ -174,7 +174,7 @@ public class CornerDetectionPipe
// and maximize their distance from the center of the min area rectangle
var leftList = new ArrayList<Point>();
var rightList = new ArrayList<Point>();
var averageXCoordinate = 0;
double averageXCoordinate = 0.0;
for (var p : pointList) {
averageXCoordinate += p.x;
}

View File

@@ -141,7 +141,7 @@ public class VisionModule {
}
// Configure LED's if supported by the underlying hardware
if (HardwareManager.getInstance().visionLED != null) {
if (HardwareManager.getInstance().visionLED != null && this.camShouldControlLEDs()) {
HardwareManager.getInstance()
.visionLED
.setPipelineModeSupplier(() -> pipelineManager.getCurrentPipelineSettings().ledMode);
@@ -277,7 +277,7 @@ public class VisionModule {
void setDriverMode(boolean isDriverMode) {
pipelineManager.setDriverMode(isDriverMode);
if (isVendorCamera()) setVisionLEDs(!isDriverMode);
setVisionLEDs(!isDriverMode);
saveAndBroadcastAll();
}
@@ -375,14 +375,21 @@ public class VisionModule {
visionSource.getSettables().setGain(Math.max(0, config.cameraGain));
}
if (isVendorCamera()) setVisionLEDs(config.ledMode);
setVisionLEDs(config.ledMode);
visionSource.getSettables().getConfiguration().currentPipelineIndex =
pipelineManager.getCurrentPipelineIndex();
}
private boolean camShouldControlLEDs() {
// Heuristic - if the camera has a known FOV or is a piCam, assume it's in use for
// vision processing, and should command stuff to the LED's.
// TODO: Make LED control a property of the camera itself and controllable in the UI.
return isVendorCamera() || cameraQuirks.hasQuirk(CameraQuirk.PiCam);
}
private void setVisionLEDs(boolean on) {
if (HardwareManager.getInstance().visionLED != null)
if (camShouldControlLEDs() && HardwareManager.getInstance().visionLED != null)
HardwareManager.getInstance().visionLED.setState(on);
}