mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-05 03:21:40 +00:00
Logging for NTDataPublisher (#560)
* logging for NTDataPublisher * logging name along with index * formatting lol * resolution logging * Removed pipelineManager object from data publisher
This commit is contained in:
@@ -28,6 +28,8 @@ import java.util.function.Supplier;
|
|||||||
import org.opencv.core.Point;
|
import org.opencv.core.Point;
|
||||||
import org.photonvision.common.dataflow.CVPipelineResultConsumer;
|
import org.photonvision.common.dataflow.CVPipelineResultConsumer;
|
||||||
import org.photonvision.common.dataflow.structures.Packet;
|
import org.photonvision.common.dataflow.structures.Packet;
|
||||||
|
import org.photonvision.common.logging.LogGroup;
|
||||||
|
import org.photonvision.common.logging.Logger;
|
||||||
import org.photonvision.targeting.PhotonPipelineResult;
|
import org.photonvision.targeting.PhotonPipelineResult;
|
||||||
import org.photonvision.targeting.PhotonTrackedTarget;
|
import org.photonvision.targeting.PhotonTrackedTarget;
|
||||||
import org.photonvision.targeting.TargetCorner;
|
import org.photonvision.targeting.TargetCorner;
|
||||||
@@ -36,6 +38,7 @@ import org.photonvision.vision.target.TrackedTarget;
|
|||||||
|
|
||||||
public class NTDataPublisher implements CVPipelineResultConsumer {
|
public class NTDataPublisher implements CVPipelineResultConsumer {
|
||||||
private final NetworkTable rootTable = NetworkTablesManager.getInstance().kRootTable;
|
private final NetworkTable rootTable = NetworkTablesManager.getInstance().kRootTable;
|
||||||
|
private final Logger logger = new Logger(NTDataPublisher.class, LogGroup.Data);
|
||||||
private NetworkTable subTable;
|
private NetworkTable subTable;
|
||||||
private NetworkTableEntry rawBytesEntry;
|
private NetworkTableEntry rawBytesEntry;
|
||||||
|
|
||||||
@@ -87,7 +90,7 @@ public class NTDataPublisher implements CVPipelineResultConsumer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newIndex == originalIndex) {
|
if (newIndex == originalIndex) {
|
||||||
// TODO: Log
|
logger.debug("Pipeline index is already " + newIndex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,9 +98,9 @@ public class NTDataPublisher implements CVPipelineResultConsumer {
|
|||||||
var setIndex = pipelineIndexSupplier.get();
|
var setIndex = pipelineIndexSupplier.get();
|
||||||
if (newIndex != setIndex) { // set failed
|
if (newIndex != setIndex) { // set failed
|
||||||
pipelineIndexEntry.forceSetNumber(setIndex);
|
pipelineIndexEntry.forceSetNumber(setIndex);
|
||||||
// TODO: Log
|
logger.warn("Failed to set pipeline index to " + newIndex);
|
||||||
}
|
}
|
||||||
// TODO: Log
|
logger.debug("Successfully set pipeline index to " + newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDriverModeChange(EntryNotification entryNotification) {
|
private void onDriverModeChange(EntryNotification entryNotification) {
|
||||||
@@ -105,12 +108,12 @@ public class NTDataPublisher implements CVPipelineResultConsumer {
|
|||||||
var originalDriverMode = driverModeSupplier.getAsBoolean();
|
var originalDriverMode = driverModeSupplier.getAsBoolean();
|
||||||
|
|
||||||
if (newDriverMode == originalDriverMode) {
|
if (newDriverMode == originalDriverMode) {
|
||||||
// TODO: Log
|
logger.debug("Driver mode is already " + newDriverMode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
driverModeConsumer.accept(newDriverMode);
|
driverModeConsumer.accept(newDriverMode);
|
||||||
// TODO: Log
|
logger.debug("Successfully set driver mode to " + newDriverMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
@SuppressWarnings("DuplicatedCode")
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class ScriptManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void queueEvent(ScriptEventType eventType) {
|
public static void queueEvent(ScriptEventType eventType) {
|
||||||
if (!Platform.currentPlatform.isWindows()) {
|
if (!Platform.isWindows()) {
|
||||||
try {
|
try {
|
||||||
queuedEvents.putLast(eventType);
|
queuedEvents.putLast(eventType);
|
||||||
logger.info("Queued event: " + eventType.name());
|
logger.info("Queued event: " + eventType.name());
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class USBCameraSource extends VisionSource {
|
|||||||
|
|
||||||
logger = new Logger(USBCameraSource.class, config.nickname, LogGroup.Camera);
|
logger = new Logger(USBCameraSource.class, config.nickname, LogGroup.Camera);
|
||||||
camera = new UsbCamera(config.nickname, config.path);
|
camera = new UsbCamera(config.nickname, config.path);
|
||||||
cvSink = CameraServer.getInstance().getVideo(this.camera);
|
cvSink = CameraServer.getVideo(this.camera);
|
||||||
|
|
||||||
cameraQuirks =
|
cameraQuirks =
|
||||||
QuirkyCamera.getQuirkyCamera(
|
QuirkyCamera.getQuirkyCamera(
|
||||||
|
|||||||
@@ -107,4 +107,41 @@ public class CVPipelineSettings implements Cloneable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CVPipelineSettings{"
|
||||||
|
+ "pipelineIndex="
|
||||||
|
+ pipelineIndex
|
||||||
|
+ ", pipelineType="
|
||||||
|
+ pipelineType
|
||||||
|
+ ", inputImageFlipMode="
|
||||||
|
+ inputImageFlipMode
|
||||||
|
+ ", inputImageRotationMode="
|
||||||
|
+ inputImageRotationMode
|
||||||
|
+ ", pipelineNickname='"
|
||||||
|
+ pipelineNickname
|
||||||
|
+ '\''
|
||||||
|
+ ", cameraExposure="
|
||||||
|
+ cameraExposure
|
||||||
|
+ ", cameraBrightness="
|
||||||
|
+ cameraBrightness
|
||||||
|
+ ", cameraGain="
|
||||||
|
+ cameraGain
|
||||||
|
+ ", cameraRedGain="
|
||||||
|
+ cameraRedGain
|
||||||
|
+ ", cameraBlueGain="
|
||||||
|
+ cameraBlueGain
|
||||||
|
+ ", cameraVideoModeIndex="
|
||||||
|
+ cameraVideoModeIndex
|
||||||
|
+ ", streamingFrameDivisor="
|
||||||
|
+ streamingFrameDivisor
|
||||||
|
+ ", ledMode="
|
||||||
|
+ ledMode
|
||||||
|
+ ", inputShouldShow="
|
||||||
|
+ inputShouldShow
|
||||||
|
+ ", outputShouldShow="
|
||||||
|
+ outputShouldShow
|
||||||
|
+ '}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,28 @@ public class PipelineManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the settings for a pipeline by index.
|
||||||
|
*
|
||||||
|
* @param index Index of pipeline whose nickname needs getting.
|
||||||
|
* @return the nickname of the pipeline whose index was provided.
|
||||||
|
*/
|
||||||
|
public String getPipelineNickname(int index) {
|
||||||
|
if (index < 0) {
|
||||||
|
switch (index) {
|
||||||
|
case DRIVERMODE_INDEX:
|
||||||
|
return driverModePipeline.getSettings().pipelineNickname;
|
||||||
|
case CAL_3D_INDEX:
|
||||||
|
return calibration3dPipeline.getSettings().pipelineNickname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var setting : userPipelineSettings) {
|
||||||
|
if (setting.pipelineIndex == index) return setting.pipelineNickname;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of nicknames for all user pipelines
|
* Gets a list of nicknames for all user pipelines
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -370,6 +370,7 @@ public class VisionModule {
|
|||||||
|
|
||||||
void setPipeline(int index) {
|
void setPipeline(int index) {
|
||||||
logger.info("Setting pipeline to " + index);
|
logger.info("Setting pipeline to " + index);
|
||||||
|
logger.info("Pipeline name: " + pipelineManager.getPipelineNickname(index));
|
||||||
pipelineManager.setIndex(index);
|
pipelineManager.setIndex(index);
|
||||||
var pipelineSettings = pipelineManager.getPipelineSettings(index);
|
var pipelineSettings = pipelineManager.getPipelineSettings(index);
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,16 @@ public abstract class VisionSourceSettables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoMode(VideoMode mode) {
|
public void setVideoMode(VideoMode mode) {
|
||||||
|
logger.info(
|
||||||
|
"Setting video mode to "
|
||||||
|
+ "FPS: "
|
||||||
|
+ mode.fps
|
||||||
|
+ " Width: "
|
||||||
|
+ mode.width
|
||||||
|
+ " Height: "
|
||||||
|
+ mode.height
|
||||||
|
+ " Pixel Format: "
|
||||||
|
+ mode.pixelFormat);
|
||||||
setVideoModeInternal(mode);
|
setVideoModeInternal(mode);
|
||||||
calculateFrameStaticProps();
|
calculateFrameStaticProps();
|
||||||
}
|
}
|
||||||
@@ -80,6 +90,7 @@ public abstract class VisionSourceSettables {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFOV(double fov) {
|
public void setFOV(double fov) {
|
||||||
|
logger.info("Setting FOV to " + fov);
|
||||||
configuration.FOV = fov;
|
configuration.FOV = fov;
|
||||||
calculateFrameStaticProps();
|
calculateFrameStaticProps();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user