Files
PhotonVision/chameleon-server/src/main/java/com/chameleonvision/common/scripting/ScriptEvent.java
Banks T 1149bf9c55 Pipeline Bringup (#94)
* Refactor package structure, various cleanups

* Add pipeline classes, settings, separate enums

* updated Largest ContourSortMode and added centermost

* Add DriverPipeline classes, apply spotless

* Add crosshair to DriverMode, cleanups

* Add FrameStaticProperties as member in Frame

Add FrameStaticProperties as member in Frame

* Finish ReflectivePipeline, various tweaks

* Apply Spotless

* Move test images

* add Releasable interface, implement in classes

* add TestUtils class, move testimages

* Refactor CVPipeline, add ReflectivePipelineTest

* Fix ConcurrentModificationException bug in group contours pipe with potential targets

* Resolve memory leaks due to unnecessary instantiation of Points

* Apply spotless

* Add CVMat, ReflectionUtils to help track rogue Mats

* various cleanups, add DummyFrameConsumer

* Add logback

* Add slv4j logger to replace the current debugLogger

I'm waiting on stuff to be less skeletoned to add more

* Add perimeter, MatOfPoint2f getters to Contour

* Create CornerDetectionPipe based on old solvePNPPipe

* Add ContourShape class for approxPolyDp Start on ColoredShape tracking

* Add point detection, fix convex hull calculation in Contour

* Make Draw2dContours pipe respect showMultiple

* Update Contour.java

* Clean up draw 3d, fix convex hull bug in corner detection

* Update geometry classes

* Add lifecam calibration data

* Implement solvePNP, bounding box top and bottom

* Fix JSON mat bug and lifecam default calibration for tests, fix 3d drawing

* run spotless

* Refactor calibration into `common.calibration`

* Update .gitignore

* Add offset method to get2020Target

* Various cleanups, add PipelineType enum

* Apply spotless

Co-authored-by: ori agranat <oriagranat9@gmail.com>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2020-04-12 18:37:14 -04:00

38 lines
1.3 KiB
Java

package com.chameleonvision.common.scripting;
import com.chameleonvision.common.util.ShellExec;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ScriptEvent {
private static final ShellExec executor = new ShellExec(true, true);
public final ScriptConfig config;
private final Logger logger = LoggerFactory.getLogger(ScriptEvent.class);
public ScriptEvent(ScriptConfig config) {
this.config = config;
}
public int run() throws IOException {
int retVal = executor.executeBashCommand(config.command);
String output = executor.getOutput();
String error = executor.getError();
if (!error.isEmpty()) {
System.err.printf("Error when running \"%s\" script: %s\n", config.eventType.name(), error);
} else if (!output.isEmpty()) {
logger.info(
String.format("Output from \"%s\" script: %s\n", config.eventType.name(), output));
}
logger.info(
String.format(
"Script for %s ran with command line: \"%s\", exit code: %d, output: %s, "
+ "error: %s\n",
config.eventType.name(), config.command, retVal, output, error));
return retVal;
}
}