mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Driver Mode fixes
This commit is contained in:
@@ -91,10 +91,10 @@ public class VisionProcess {
|
||||
initNT(newTable);
|
||||
}
|
||||
|
||||
public void setCameraName(String newName) {
|
||||
public void setCameraNickname(String newName) {
|
||||
getCamera().getProperties().setNickname(newName);
|
||||
var newTable = NetworkTableInstance.getDefault().getTable("/chameleon-vision/" + newName);
|
||||
resetNT(newTable);
|
||||
pipelineManager.ntIndexEntry = ntPipelineEntry;
|
||||
}
|
||||
|
||||
private void initNT(NetworkTable newTable) {
|
||||
|
||||
@@ -18,6 +18,7 @@ public class DriverVisionPipeline extends CVPipeline<DriverPipelineResult, CVPip
|
||||
public DriverVisionPipeline(CVPipelineSettings settings) {
|
||||
super(settings);
|
||||
draw2dContoursSettings.showCrosshair = true;
|
||||
draw2dContoursPipe = new Draw2dContoursPipe(draw2dContoursSettings, cameraCapture.getProperties().getStaticProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,13 +26,7 @@ public class DriverVisionPipeline extends CVPipeline<DriverPipelineResult, CVPip
|
||||
|
||||
inputMat.copyTo(outputMat);
|
||||
|
||||
var camProps = cameraCapture.getProperties().getStaticProperties();
|
||||
if(draw2dContoursPipe == null) {
|
||||
draw2dContoursPipe = new Draw2dContoursPipe(draw2dContoursSettings, camProps);
|
||||
} else {
|
||||
draw2dContoursPipe.setConfig(false,camProps);
|
||||
}
|
||||
|
||||
draw2dContoursPipe.setConfig(false, cameraCapture.getProperties().getStaticProperties());
|
||||
draw2dContoursPipe.run(Pair.of(outputMat, blankList)).getLeft().copyTo(outputMat);
|
||||
|
||||
return new DriverPipelineResult(null, outputMat, 0);
|
||||
|
||||
@@ -98,7 +98,11 @@ public class PipelineManager {
|
||||
}
|
||||
|
||||
public CVPipeline getCurrentPipeline() {
|
||||
return pipelines.get(currentPipelineIndex);
|
||||
if (currentPipelineIndex <= DRIVERMODE_INDEX) {
|
||||
return driverModePipeline;
|
||||
} else {
|
||||
return pipelines.get(currentPipelineIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentPipeline(int index) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.chameleonvision.network.NetworkIPMode;
|
||||
import com.chameleonvision.vision.VisionManager;
|
||||
import com.chameleonvision.vision.VisionProcess;
|
||||
import com.chameleonvision.vision.camera.CameraCapture;
|
||||
import com.chameleonvision.vision.enums.StreamDivisor;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.javalin.http.Context;
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.chameleonvision.vision.pipeline.CVPipelineSettings;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import edu.wpi.first.networktables.NetworkTable;
|
||||
import io.javalin.websocket.WsBinaryMessageContext;
|
||||
import io.javalin.websocket.WsCloseContext;
|
||||
import io.javalin.websocket.WsConnectContext;
|
||||
@@ -66,8 +65,7 @@ public class SocketHandler {
|
||||
break;
|
||||
}
|
||||
case "changeCameraName": {
|
||||
currentCamera.getProperties().setNickname((String) entry.getValue());
|
||||
currentProcess.setCameraName((String) entry.getValue());
|
||||
currentProcess.setCameraNickname((String) entry.getValue());
|
||||
sendFullSettings();
|
||||
VisionManager.saveCurrentCameraSettings();
|
||||
break;
|
||||
@@ -87,15 +85,12 @@ public class SocketHandler {
|
||||
String val = mapper.writeValueAsString(origPipeline);
|
||||
CVPipelineSettings newPipeline = mapper.readValue(val, origPipeline.getClass());
|
||||
|
||||
// TODO: move to PipelineManager
|
||||
newPipeline.nickname += "(Copy)";
|
||||
|
||||
if (cameraIndex != -1) {
|
||||
VisionProcess newProcess = VisionManager.getVisionProcessByIndex(cameraIndex);
|
||||
if (newProcess != null) {
|
||||
currentProcess.pipelineManager.duplicatePipeline(newPipeline, newProcess);
|
||||
} else {
|
||||
System.err.println("Failed to get new camera for pipeline duplication!");
|
||||
System.err.println("Failed to get destination camera for pipeline duplication!");
|
||||
}
|
||||
} else {
|
||||
currentProcess.pipelineManager.duplicatePipeline(newPipeline);
|
||||
@@ -141,9 +136,12 @@ public class SocketHandler {
|
||||
default: {
|
||||
|
||||
// only change settings when we aren't in driver mode
|
||||
if(currentProcess.pipelineManager.getDriverMode()) break;
|
||||
if(currentProcess.pipelineManager.getDriverMode()) {
|
||||
setField(currentProcess.pipelineManager.driverModePipeline.settings, entry.getKey(), entry.getValue());
|
||||
} else {
|
||||
setField(currentPipeline.settings, entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
setField(currentPipeline.settings, entry.getKey(), entry.getValue());
|
||||
switch (entry.getKey()) {
|
||||
case "exposure": {
|
||||
currentCamera.setExposure((Integer) entry.getValue());
|
||||
@@ -158,8 +156,7 @@ public class SocketHandler {
|
||||
break;
|
||||
}
|
||||
case "streamDivisor":{
|
||||
VisionProcess currentVisionProcess = VisionManager.getCurrentUIVisionProcess();
|
||||
currentVisionProcess.cameraStreamer.setDivisor(StreamDivisor.values()[(Integer) entry.getValue()], true);
|
||||
currentProcess.cameraStreamer.setDivisor(StreamDivisor.values()[(Integer) entry.getValue()], true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user