diff --git a/build.gradle b/build.gradle index 83c94701da..4ba2dad4cc 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import edu.wpi.first.toolchain.* plugins { id "com.diffplug.spotless" version "6.24.0" - id "edu.wpi.first.NativeUtils" version "2024.7.2" apply false + id "edu.wpi.first.NativeUtils" version "2024.6.1" apply false id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2" id "edu.wpi.first.GradleRIO" version "2024.3.2" id 'edu.wpi.first.WpilibTools' version '1.3.0' @@ -28,7 +28,7 @@ ext.allOutputsFolder = file("$project.buildDir/outputs") apply from: "versioningHelper.gradle" ext { - wpilibVersion = "2025.0.0-alpha-1" + wpilibVersion = "2024.3.2" wpimathVersion = wpilibVersion openCVversion = "4.8.0-2" joglVersion = "2.4.0" diff --git a/photon-core/src/main/java/edu/wpi/first/util/RuntimeDetector.java b/photon-core/src/main/java/edu/wpi/first/util/RuntimeDetector.java deleted file mode 100644 index eedafc4f85..0000000000 --- a/photon-core/src/main/java/edu/wpi/first/util/RuntimeDetector.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) Photon Vision. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package edu.wpi.first.util; - -import java.io.File; - -/** - * A utility class for detecting and providing platform-specific such as OS and CPU architecture. - */ -public final class RuntimeDetector { - private static String filePrefix; - private static String fileExtension; - private static String filePath; - - private static synchronized void computePlatform() { - if (fileExtension != null && filePath != null && filePrefix != null) { - return; - } - - boolean intel32 = is32BitIntel(); - boolean intel64 = is64BitIntel(); - boolean arm64 = isArm64(); - - if (isWindows()) { - filePrefix = ""; - fileExtension = ".dll"; - if (intel32) { - filePath = "/windows/x86/"; - } else { - filePath = "/windows/x86-64/"; - } - } else if (isMac()) { - filePrefix = "lib"; - fileExtension = ".dylib"; - filePath = "/osx/universal/"; - } else if (isLinux()) { - filePrefix = "lib"; - fileExtension = ".so"; - if (intel32) { - filePath = "/linux/x86/"; - } else if (intel64) { - filePath = "/linux/x86-64/"; - } else if (isAthena()) { - filePath = "/linux/athena/"; - } else if (isArm32()) { - filePath = "/linux/arm32/"; - } else if (arm64) { - filePath = "/linux/arm64/"; - } else { - filePath = "/linux/nativearm/"; - } - } else { - throw new IllegalStateException("Failed to determine OS"); - } - } - - /** - * Get the file prefix for the current system. - * - * @return The file prefix. - */ - public static synchronized String getFilePrefix() { - computePlatform(); - - return filePrefix; - } - - /** - * Get the file extension for the current system. - * - * @return The file extension. - */ - public static synchronized String getFileExtension() { - computePlatform(); - - return fileExtension; - } - - /** - * Get the platform path for the current system. - * - * @return The platform path. - */ - public static synchronized String getPlatformPath() { - computePlatform(); - - return filePath; - } - - /** - * Get the path to the requested resource. - * - * @param libName Library name. - * @return The path to the requested resource. - */ - public static synchronized String getLibraryResource(String libName) { - computePlatform(); - - return filePath + filePrefix + libName + fileExtension; - } - - /** - * Get the path to the hash to the requested resource. - * - * @param libName Library name. - * @return The path to the hash to the requested resource. - */ - public static synchronized String getHashLibraryResource(String libName) { - computePlatform(); - - return filePath + libName + ".hash"; - } - - /** - * Check if hardware platform is Athena. - * - * @return True if hardware platform is Athena. - */ - public static boolean isAthena() { - File runRobotFile = new File("/usr/local/frc/bin/frcRunRobot.sh"); - return runRobotFile.exists(); - } - - /** - * Check if OS is Arm32. - * - * @return True if OS is Arm32. - */ - public static boolean isArm32() { - String arch = System.getProperty("os.arch"); - return "arm".equals(arch) || "arm32".equals(arch); - } - - /** - * Check if architecture is Arm64. - * - * @return if architecture is Arm64. - */ - public static boolean isArm64() { - String arch = System.getProperty("os.arch"); - return "aarch64".equals(arch) || "arm64".equals(arch); - } - - /** - * Check if OS is Linux. - * - * @return if OS is Linux. - */ - public static boolean isLinux() { - return System.getProperty("os.name").startsWith("Linux"); - } - - /** - * Check if OS is Windows. - * - * @return if OS is Windows. - */ - public static boolean isWindows() { - return System.getProperty("os.name").startsWith("Windows"); - } - - /** - * Check if OS is Mac. - * - * @return if OS is Mac. - */ - public static boolean isMac() { - return System.getProperty("os.name").startsWith("Mac"); - } - - /** - * Check if OS is 32bit Intel. - * - * @return if OS is 32bit Intel. - */ - public static boolean is32BitIntel() { - String arch = System.getProperty("os.arch"); - return "x86".equals(arch) || "i386".equals(arch); - } - - /** - * Check if OS is 64bit Intel. - * - * @return if OS is 64bit Intel. - */ - public static boolean is64BitIntel() { - String arch = System.getProperty("os.arch"); - return "amd64".equals(arch) || "x86_64".equals(arch); - } - - private RuntimeDetector() {} -} diff --git a/photon-core/src/main/java/org/photonvision/common/util/TestUtils.java b/photon-core/src/main/java/org/photonvision/common/util/TestUtils.java index 0f0dd70e81..25b7112635 100644 --- a/photon-core/src/main/java/org/photonvision/common/util/TestUtils.java +++ b/photon-core/src/main/java/org/photonvision/common/util/TestUtils.java @@ -19,23 +19,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import edu.wpi.first.apriltag.jni.AprilTagJNI; +import edu.wpi.first.cscore.CameraServerCvJNI; import edu.wpi.first.cscore.CameraServerJNI; -import edu.wpi.first.cscore.OpenCvLoader; import edu.wpi.first.hal.JNIWrapper; +import edu.wpi.first.math.WPIMathJNI; import edu.wpi.first.math.geometry.Translation2d; -import edu.wpi.first.math.jni.ArmFeedforwardJNI; -import edu.wpi.first.math.jni.DAREJNI; -import edu.wpi.first.math.jni.EigenJNI; -import edu.wpi.first.math.jni.Ellipse2dJNI; -import edu.wpi.first.math.jni.Pose3dJNI; -import edu.wpi.first.math.jni.StateSpaceUtilJNI; -import edu.wpi.first.math.jni.TrajectoryUtilJNI; import edu.wpi.first.math.util.Units; import edu.wpi.first.net.WPINetJNI; import edu.wpi.first.networktables.NetworkTablesJNI; import edu.wpi.first.util.CombinedRuntimeLoader; import edu.wpi.first.util.WPIUtilJNI; -import java.awt.*; +import java.awt.HeadlessException; import java.io.File; import java.io.IOException; import java.nio.file.Path; @@ -52,21 +46,23 @@ public static boolean loadLibraries() { NetworkTablesJNI.Helper.setExtractOnStaticLoad(false); WPIUtilJNI.Helper.setExtractOnStaticLoad(false); + WPIMathJNI.Helper.setExtractOnStaticLoad(false); CameraServerJNI.Helper.setExtractOnStaticLoad(false); - OpenCvLoader.Helper.setExtractOnStaticLoad(false); + CameraServerCvJNI.Helper.setExtractOnStaticLoad(false); + // OpenCvLoader.Helper.setExtractOnStaticLoad(false); JNIWrapper.Helper.setExtractOnStaticLoad(false); WPINetJNI.Helper.setExtractOnStaticLoad(false); AprilTagJNI.Helper.setExtractOnStaticLoad(false); // wpimathjni is a bit odd, it's all in the wpimathjni shared lib, but the java side stuff has // been split. - ArmFeedforwardJNI.Helper.setExtractOnStaticLoad(false); - DAREJNI.Helper.setExtractOnStaticLoad(false); - EigenJNI.Helper.setExtractOnStaticLoad(false); - Ellipse2dJNI.Helper.setExtractOnStaticLoad(false); - Pose3dJNI.Helper.setExtractOnStaticLoad(false); - StateSpaceUtilJNI.Helper.setExtractOnStaticLoad(false); - TrajectoryUtilJNI.Helper.setExtractOnStaticLoad(false); + // ArmFeedforwardJNI.Helper.setExtractOnStaticLoad(false); + // DAREJNI.Helper.setExtractOnStaticLoad(false); + // EigenJNI.Helper.setExtractOnStaticLoad(false); + // Ellipse2dJNI.Helper.setExtractOnStaticLoad(false); + // Pose3dJNI.Helper.setExtractOnStaticLoad(false); + // StateSpaceUtilJNI.Helper.setExtractOnStaticLoad(false); + // TrajectoryUtilJNI.Helper.setExtractOnStaticLoad(false); try { CombinedRuntimeLoader.loadLibraries( diff --git a/photon-lib/src/test/java/org/photonvision/OpenCVTest.java b/photon-lib/src/test/java/org/photonvision/OpenCVTest.java index 88531f6e73..84549545ea 100644 --- a/photon-lib/src/test/java/org/photonvision/OpenCVTest.java +++ b/photon-lib/src/test/java/org/photonvision/OpenCVTest.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.*; -import edu.wpi.first.cscore.OpenCvLoader; +import edu.wpi.first.cscore.CameraServerCvJNI; import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Rotation2d; @@ -77,7 +77,7 @@ public static void assertSame(Transform3d trf1, Transform3d trf2) { @BeforeAll public static void setUp() throws IOException { - OpenCvLoader.forceLoad(); + CameraServerCvJNI.forceLoad(); // NT live for debug purposes NetworkTableInstance.getDefault().startServer();