3d, camera calibration, backend settings hookup (#80)

* Implement new UI backend stuff

* Kinda partially add resolution accuracy list

* camera calibration go brrrrrrrr

* ayyyy calibration works

* Maybe fix grouping

* Reorganize camera view

* Fix settings not getting sent

* Make pretty (#4)

* Reorganize camera view

* Apply some cosmetic layout changes to the cameras page

* Fix pipeline rollback bug when starting on non-dashboard pages

Co-authored-by: Matt <matthew.morley.ca@gmail.com>

* Fix naming mismatch

* Mostly make stuff work

* rename robot-relative pose to camera-relative pose

* SolvePNP memes, fix isFovConfigurable

* Change config path to photonvision_config

* netmask go poof, fix zip download?

* Update index.js

* Fix multi cam stuff?

* Use LinearFilter instead

* Fix multicam

* aaa

* start adding restart device and restart program, fix square size bug

* Add some debug stuff

* oop

* Start fixing tests

* Fix tests

* Make target box proportinal

* run spotless

* Make crosshair h o t p i n k

* Address review comments

* Address review 2 electric booaloo

* Possibly implement vendor FOV?

* Make centroid crosshair gren

* actually use FOV

* Fix tests

* actually fix tests

Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com>
This commit is contained in:
Matt
2020-08-14 12:39:21 -07:00
committed by GitHub
parent 86ea661ed9
commit b3436765e1
86 changed files with 2106 additions and 1173 deletions

View File

@@ -26,6 +26,7 @@ import org.photonvision.common.util.ShellExec;
public abstract class GPIOBase {
private static final Logger logger = new Logger(GPIOBase.class, LogGroup.General);
private static final ShellExec runCommand = new ShellExec(true, true);
public static HashMap<String, String> commands =
new HashMap<>() {
@@ -39,8 +40,6 @@ public abstract class GPIOBase {
}
};
private static final ShellExec runCommand = new ShellExec(true, true);
public static String execute(String command) {
try {
runCommand.executeBashCommand(command);

View File

@@ -17,6 +17,7 @@
package org.photonvision.common.hardware;
import java.io.IOException;
import java.util.HashMap;
import org.photonvision.common.configuration.HardwareConfig;
import org.photonvision.common.hardware.GPIO.CustomGPIO;
@@ -24,12 +25,20 @@ import org.photonvision.common.hardware.GPIO.GPIOBase;
import org.photonvision.common.hardware.GPIO.PiGPIO;
import org.photonvision.common.hardware.metrics.MetricsBase;
import org.photonvision.common.hardware.metrics.MetricsPublisher;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;
import org.photonvision.common.util.ShellExec;
public class HardwareManager {
HardwareConfig hardwareConfig;
private static final HashMap<Integer, GPIOBase> LEDs = new HashMap<>();
private final HashMap<Integer, GPIOBase> LEDs = new HashMap<>();
private final ShellExec shellExec = new ShellExec(true, false);
private final Logger logger = new Logger(HardwareManager.class, LogGroup.General);
public static HardwareManager getInstance() {
if (Singleton.INSTANCE == null) {
Singleton.INSTANCE = new HardwareManager();
}
return Singleton.INSTANCE;
}
@@ -52,6 +61,7 @@ public class HardwareManager {
// Start hardware metrics thread
MetricsPublisher.getInstance().startTask();
}
/** Example: HardwareManager.getInstance().getPWM(port).dimLEDs(int dimValue); */
public GPIOBase getGPIO(int pin) {
return LEDs.get(pin);
@@ -81,7 +91,20 @@ public class HardwareManager {
LEDs.values().forEach(GPIOBase::shutdown);
}
public boolean restartDevice() {
try {
return shellExec.executeBashCommand(hardwareConfig.restartHardwareCommand) == 0;
} catch (IOException e) {
logger.error("Could not restart device!", e);
return false;
}
}
public HardwareConfig getConfig() {
return hardwareConfig;
}
private static class Singleton {
private static final HardwareManager INSTANCE = new HardwareManager();
private static HardwareManager INSTANCE;
}
}

View File

@@ -36,8 +36,9 @@ public enum Platform {
// Completely unsupported
UNSUPPORTED("Unsupported Platform");
private static final ShellExec shell = new ShellExec(true, false);
public final String value;
public final boolean isRoot = checkForRoot();
public static final boolean isRoot = checkForRoot();
Platform(String value) {
this.value = value;
@@ -54,21 +55,21 @@ public enum Platform {
return this == WINDOWS_64 || this == WINDOWS_32;
}
public boolean isLinux() {
return this == LINUX_64 || this == LINUX_RASPBIAN || this == LINUX_ARM64;
public static boolean isLinux() {
return getCurrentPlatform() == LINUX_64
|| getCurrentPlatform() == LINUX_RASPBIAN
|| getCurrentPlatform() == LINUX_ARM64;
}
public static boolean isRaspberryPi() {
return CurrentPlatform.equals(LINUX_RASPBIAN);
}
private static ShellExec shell = new ShellExec(true, false);
@SuppressWarnings("StatementWithEmptyBody")
private boolean checkForRoot() {
private static boolean checkForRoot() {
if (isLinux()) {
try {
shell.execute("id", null, true, "-u");
shell.executeBashCommand("id -u");
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -17,28 +17,22 @@
package org.photonvision.common.hardware.metrics;
public class CPU extends MetricsBase {
public class CPUMetrics extends MetricsBase {
private CPU() {}
public static CPU getInstance() {
return Singleton.INSTANCE;
}
public CPUMetrics() {}
public double getMemory() {
if (cpuMemoryCommand.isEmpty()) return 0;
return execute(cpuMemoryCommand);
}
// TODO: Command should return in Celsius
public double getTemp() {
if (cpuTemperatureCommand.isEmpty()) return 0;
return execute(cpuTemperatureCommand) / 1000;
}
public double getUtilization() {
return execute(cpuUtilizationCommand);
}
private static class Singleton {
public static final CPU INSTANCE = new CPU();
}
}

View File

@@ -17,14 +17,7 @@
package org.photonvision.common.hardware.metrics;
public class GPU extends MetricsBase {
private GPU() {}
public static GPU getInstance() {
return Singleton.INSTANCE;
}
public class GPUMetrics extends MetricsBase {
public double getMemory() {
return execute(gpuMemoryCommand);
}
@@ -32,8 +25,4 @@ public class GPU extends MetricsBase {
public double getTemp() {
return execute(gpuTemperatureCommand) / 10;
}
private static class Singleton {
public static final GPU INSTANCE = new GPU();
}
}

View File

@@ -28,18 +28,18 @@ import org.photonvision.server.UIUpdateType;
public class MetricsPublisher {
private final HashMap<String, Double> metrics;
private static final Logger logger = new Logger(MetricsPublisher.class, LogGroup.General);
private static CPU cpu;
private static GPU gpu;
private static RAM ram;
private static CPUMetrics cpuMetrics;
private static GPUMetrics gpuMetrics;
private static RAMMetrics ramMetrics;
public static MetricsPublisher getInstance() {
return Singleton.INSTANCE;
}
private MetricsPublisher() {
cpu = CPU.getInstance();
gpu = GPU.getInstance();
ram = RAM.getInstance();
cpuMetrics = new CPUMetrics();
gpuMetrics = new GPUMetrics();
ramMetrics = new RAMMetrics();
metrics = new HashMap<>();
}
@@ -49,12 +49,12 @@ public class MetricsPublisher {
.addTask(
"Metrics",
() -> {
metrics.put("cpuTemp", cpu.getTemp());
metrics.put("cpuUtil", cpu.getUtilization());
metrics.put("cpuMem", cpu.getMemory());
metrics.put("gpuTemp", gpu.getTemp());
metrics.put("gpuMem", gpu.getMemory());
metrics.put("ramUtil", ram.getUsedRam());
metrics.put("cpuTemp", cpuMetrics.getTemp());
metrics.put("cpuUtil", cpuMetrics.getUtilization());
metrics.put("cpuMem", cpuMetrics.getMemory());
metrics.put("gpuTemp", gpuMetrics.getTemp());
metrics.put("gpuMem", gpuMetrics.getMemory());
metrics.put("ramUtil", ramMetrics.getUsedRam());
DataChangeService.getInstance()
.publishEvent(

View File

@@ -17,19 +17,10 @@
package org.photonvision.common.hardware.metrics;
public class RAM extends MetricsBase {
private RAM() {}
public static RAM getInstance() {
return Singleton.INSTANCE;
}
public class RAMMetrics extends MetricsBase {
// TODO: Output in MBs for consistency
public double getUsedRam() {
if (ramUsageCommand.isEmpty()) return 0;
return execute(ramUsageCommand) / 1000;
}
private static class Singleton {
public static final RAM INSTANCE = new RAM();
}
}