Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of RuntimeDetector #1536

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import edu.wpi.first.cscore.UsbCamera;
import edu.wpi.first.cscore.VideoException;
import edu.wpi.first.cscore.VideoProperty;
import edu.wpi.first.util.RuntimeDetector;
import java.util.*;
import org.photonvision.common.configuration.CameraConfiguration;
import org.photonvision.common.hardware.Platform;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;
import org.photonvision.vision.camera.CameraQuirk;
Expand Down Expand Up @@ -113,7 +113,7 @@ protected GenericUSBCameraSettables createSettables(
GenericUSBCameraSettables settables;

if (quirks.hasQuirk(CameraQuirk.LifeCamControls)) {
if (RuntimeDetector.isWindows()) {
if (Platform.isWindows()) {
logger.debug("Using Microsoft Lifecam 3000 Windows-Specific Settables");
settables = new LifeCam3kWindowsCameraSettables(config, camera);
} else {
Expand All @@ -124,7 +124,7 @@ protected GenericUSBCameraSettables createSettables(
logger.debug("Using PlayStation Eye Camera Settables");
settables = new PsEyeCameraSettables(config, camera);
} else if (quirks.hasQuirk(CameraQuirk.ArduOV2311Controls)) {
if (RuntimeDetector.isWindows()) {
if (Platform.isWindows()) {
logger.debug("Using Arducam OV2311 Windows-Specific Settables");
settables = new ArduOV2311WindowsCameraSettables(config, camera);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.photonvision.common.hardware;

import edu.wpi.first.util.RuntimeDetector;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down Expand Up @@ -115,6 +115,11 @@ public static boolean isSupported() {
return currentPlatform.isSupported;
}

public static boolean isAthena() {
File runRobotFile = new File("/usr/local/frc/bin/frcRunRobot.sh");
return runRobotFile.exists();
}

//////////////////////////////////////////////////////

// Debug info related to unknown platforms for debug help
Expand All @@ -124,52 +129,66 @@ public static boolean isSupported() {
String.format("Unknown Platform. OS: %s, Architecture: %s", OS_NAME, OS_ARCH);

public static Platform getCurrentPlatform() {
if (RuntimeDetector.isWindows()) {
if (RuntimeDetector.is32BitIntel()) {
String OS_NAME;
if (Platform.OS_NAME != null) {
OS_NAME = Platform.OS_NAME;
} else {
OS_NAME = System.getProperty("os.name");
}

String OS_ARCH;
if (Platform.OS_ARCH != null) {
OS_ARCH = Platform.OS_ARCH;
} else {
OS_ARCH = System.getProperty("os.arch");
}

if (OS_NAME.startsWith("Windows")) {
if (OS_ARCH.equals("x86") || OS_ARCH.equals("i386")) {
return WINDOWS_32;
} else if (RuntimeDetector.is64BitIntel()) {
} else if (OS_ARCH.equals("amd64") || OS_ARCH.equals("x86_64")) {
return WINDOWS_64;
} else {
// please don't try this
return UNKNOWN;
}
}

if (RuntimeDetector.isMac()) {
if (OS_NAME.startsWith("Mac")) {
// TODO - once we have real support, this might have to be more granular
return MACOS;
}

if (RuntimeDetector.isLinux()) {
if (OS_NAME.startsWith("Linux")) {
if (isPiSBC()) {
if (RuntimeDetector.isArm32()) {
if (OS_ARCH.equals("arm") || OS_ARCH.equals("arm32")) {
return LINUX_RASPBIAN32;
} else if (RuntimeDetector.isArm64()) {
} else if (OS_ARCH.equals("aarch64") || OS_ARCH.equals("arm64")) {
return LINUX_RASPBIAN64;
} else {
// Unknown/exotic installation
return UNKNOWN;
}
} else if (isJetsonSBC()) {
if (RuntimeDetector.isArm64()) {
if (OS_ARCH.equals("aarch64") || OS_ARCH.equals("arm64")) {
// TODO - do we need to check OS version?
return LINUX_AARCH64;
} else {
// Unknown/exotic installation
return UNKNOWN;
}
} else if (RuntimeDetector.is64BitIntel()) {
} else if (OS_ARCH.equals("amd64") || OS_ARCH.equals("x86_64")) {
return LINUX_64;
} else if (RuntimeDetector.is32BitIntel()) {
} else if (OS_ARCH.equals("x86") || OS_ARCH.equals("i386")) {
return LINUX_32;
} else if (RuntimeDetector.isArm64()) {
} else if (OS_ARCH.equals("aarch64") || OS_ARCH.equals("arm64")) {
// TODO - os detection needed?
if (isOrangePi()) {
return LINUX_RK3588_64;
} else {
return LINUX_AARCH64;
}
} else if (RuntimeDetector.isArm32()) {
} else if (OS_ARCH.equals("arm") || OS_ARCH.equals("arm32")) {
return LINUX_ARM32;
} else {
// Unknown or otherwise unsupported platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.photonvision.jni;

import edu.wpi.first.util.RuntimeDetector;
import edu.wpi.first.util.RuntimeLoader;
import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -42,7 +41,7 @@ public static boolean load_() throws IOException, UnsatisfiedLinkError {
var clazz = PhotonTargetingJniLoader.class;

for (var libraryName : List.of("photontargeting", "photontargetingJNI")) {
if (RuntimeDetector.isAthena()) {
if (Platform.isAthena()) {
System.out.println("Detected rio - loading directly");
RuntimeLoader.loadLibrary(libraryName);
continue;
Expand Down
Loading