diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a72b229b2..852627cf5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,7 +119,7 @@ jobs: path: build/html build-photonlib-host: env: - MACOSX_DEPLOYMENT_TARGET: 10.14 + MACOSX_DEPLOYMENT_TARGET: 11 strategy: fail-fast: false matrix: @@ -127,9 +127,9 @@ jobs: - os: windows-2022 artifact-name: Win64 architecture: x64 - # Mac builds are broken due to opencv class loading issues -- disable for now - # - os: macos-11 - # artifact-name: macOS + - os: macos-12 + artifact-name: macOS + architecture: x64 - os: ubuntu-22.04 artifact-name: Linux diff --git a/build.gradle b/build.gradle index d6ddaeaad4..8f4fe228ba 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,11 @@ plugins { id "com.diffplug.spotless" version "6.22.0" - id "com.github.johnrengelman.shadow" version "7.1.2" - id "com.github.node-gradle.node" version "3.1.1" apply false - id "edu.wpi.first.GradleJni" version "1.1.0" - id "edu.wpi.first.GradleVsCode" version "1.3.0" id "edu.wpi.first.NativeUtils" version "2024.2.0" apply false id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2" - id "org.hidetake.ssh" version "2.10.1" - id 'edu.wpi.first.WpilibTools' version '1.1.0' + id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-2" + id 'edu.wpi.first.WpilibTools' version '1.3.0' } -import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency; - allprojects { repositories { mavenCentral() @@ -93,5 +87,5 @@ spotless { } wrapper { - gradleVersion '8.3' + gradleVersion '8.4' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2a..7f93135c49 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 24c4386e93..10587529d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services\.gradle\.org/distributions/gradle-8\.4-bin\.zip +distributionPath=permwrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=permwrapper/dists diff --git a/gradlew b/gradlew index 89a57c4dfe..1aa94a4269 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright � 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +16,50 @@ # limitations under the License. # +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME @@ -36,15 +80,12 @@ do esac done +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -90,22 +131,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -150,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -162,6 +214,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c4..93e3f59f13 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/photon-core/build.gradle b/photon-core/build.gradle index 5ebef599a4..6fbf407797 100644 --- a/photon-core/build.gradle +++ b/photon-core/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.1.0' + id 'edu.wpi.first.WpilibTools' version '1.3.0' } import java.nio.file.Path @@ -36,24 +36,3 @@ task writeCurrentVersionJava { } build.dependsOn writeCurrentVersionJava - -def testNativeConfigName = 'wpilibTestNative' -def testNativeConfig = configurations.create(testNativeConfigName) - -def folder = project.layout.buildDirectory.dir('NativeTest') - -def testNativeTasks = wpilibTools.createExtractionTasks { - taskPostfix = "Test" - configurationName = testNativeConfigName - rootTaskFolder.set(folder) -} - -testNativeTasks.addToSourceSetResources(sourceSets.test) - -testNativeConfig.dependencies.add wpilibTools.deps.cscore() -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore") -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet") -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("hal") -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil") -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag") -testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath") 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 d109f97834..593b4fbfcf 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 @@ -22,12 +22,12 @@ import edu.wpi.first.cscore.CameraServerCvJNI; import edu.wpi.first.cscore.CameraServerJNI; import edu.wpi.first.hal.JNIWrapper; +import edu.wpi.first.math.WPIMathJNI; import edu.wpi.first.math.geometry.Translation2d; 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.RuntimeLoader; import edu.wpi.first.util.WPIUtilJNI; import java.awt.*; import java.io.File; @@ -40,29 +40,27 @@ public class TestUtils { public static boolean loadLibraries() { - JNIWrapper.Helper.setExtractOnStaticLoad(false); - WPIUtilJNI.Helper.setExtractOnStaticLoad(false); NetworkTablesJNI.Helper.setExtractOnStaticLoad(false); - WPINetJNI.Helper.setExtractOnStaticLoad(false); + WPIUtilJNI.Helper.setExtractOnStaticLoad(false); + WPIMathJNI.Helper.setExtractOnStaticLoad(false); CameraServerJNI.Helper.setExtractOnStaticLoad(false); CameraServerCvJNI.Helper.setExtractOnStaticLoad(false); + JNIWrapper.Helper.setExtractOnStaticLoad(false); + WPINetJNI.Helper.setExtractOnStaticLoad(false); AprilTagJNI.Helper.setExtractOnStaticLoad(false); try { - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); - CombinedRuntimeLoader.loadLibraries( TestUtils.class, "wpiutiljni", + "wpimathjni", "ntcorejni", "wpinetjni", "wpiHaljni", + Core.NATIVE_LIBRARY_NAME, "cscorejni", - "cscorejnicvstatic", "apriltagjni"); + return true; } catch (IOException e) { e.printStackTrace(); diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index d99ea5804a..02cb0fd064 100644 --- a/photon-lib/build.gradle +++ b/photon-lib/build.gradle @@ -1,12 +1,12 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.1.0' + id "java" + id 'cpp' + id "google-test-test-suite" + id 'edu.wpi.first.WpilibTools' version '1.3.0' } import java.nio.file.Path -apply plugin: "cpp" -apply plugin: "java" -apply plugin: "google-test-test-suite" apply plugin: "edu.wpi.first.NativeUtils" apply from: "${rootDir}/shared/config.gradle" @@ -16,20 +16,14 @@ test { useJUnitPlatform() } -sourceCompatibility = JavaVersion.VERSION_11 -targetCompatibility = JavaVersion.VERSION_11 +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} -wpilibTools.deps.wpilibVersion = wpilibVersion +wpilibTools.deps.wpilibVersion = wpi.versions.wpilibVersion.get() println("Building for WPILib ${wpilibTools.deps.wpilibVersion}") -// From wpilib shared/config.gradle: -// NativeUtils adds the following OpenCV warning suppression for Linux, but not -// for macOS -// https://github.com/opencv/opencv/issues/20269 -nativeUtils.platformConfigs.osxuniversal.cppCompiler.args.add("-Wno-deprecated-anon-enum-enum-conversion") -nativeUtils.platformConfigs.linuxathena.cppCompiler.args.add("-Wno-deprecated-anon-enum-enum-conversion") -// nativeUtils.platformConfigs.linuxx64.cppCompiler.args.add("-Wno-deprecated-anon-enum-enum-conversion") - // Apply Java configuration dependencies { implementation project(":photon-targeting") @@ -44,16 +38,15 @@ dependencies { implementation wpilibTools.deps.wpilibJava("ntcore") implementation wpilibTools.deps.wpilibJava("wpilibj") implementation wpilibTools.deps.wpilibJava("apriltag") + implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) // Jackson - implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-core:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4" - - implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:$openCVversion" - implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-jni:$openCVversion:$jniPlatform" + implementation group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: wpi.versions.jacksonVersion.get() + implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: wpi.versions.jacksonVersion.get() + implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: wpi.versions.jacksonVersion.get() - implementation "org.ejml:ejml-simple:0.42" + implementation group: "org.ejml", name: "ejml-simple", version: wpi.versions.ejmlVersion.get() + implementation group: "us.hebi.quickbuf", name: "quickbuf-runtime", version: wpi.versions.quickbufVersion.get(); // Junit testImplementation wpilibTools.deps.wpilibJava("cscore") @@ -167,10 +160,10 @@ def testNativeTasks = wpilibTools.createExtractionTasks { testNativeTasks.addToSourceSetResources(sourceSets.test) -testNativeConfig.dependencies.add wpilibTools.deps.cscore() +testNativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore") testNativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore") testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet") testNativeConfig.dependencies.add wpilibTools.deps.wpilib("hal") testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil") testNativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath") -testNativeConfig.dependencies.add wpilibTools.deps.cscore() +testNativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) diff --git a/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java b/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java index 65afa427ec..1ad02b5b4d 100644 --- a/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java +++ b/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java @@ -31,7 +31,7 @@ import edu.wpi.first.math.MathUtil; import edu.wpi.first.math.Pair; import edu.wpi.first.math.geometry.Pose3d; -import edu.wpi.first.util.RuntimeLoader; +import edu.wpi.first.util.CombinedRuntimeLoader; import edu.wpi.first.util.WPIUtilJNI; import java.util.ArrayList; import java.util.List; @@ -89,10 +89,7 @@ public class PhotonCameraSim implements AutoCloseable { static { try { - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); + CombinedRuntimeLoader.loadLibraries(OpenCVHelp.class, Core.NATIVE_LIBRARY_NAME, "cscorejni"); } catch (Exception e) { throw new RuntimeException("Failed to load native libraries!", e); } diff --git a/photon-lib/src/main/java/org/photonvision/simulation/VideoSimUtil.java b/photon-lib/src/main/java/org/photonvision/simulation/VideoSimUtil.java index 7a32e413a3..cc9ead27fb 100644 --- a/photon-lib/src/main/java/org/photonvision/simulation/VideoSimUtil.java +++ b/photon-lib/src/main/java/org/photonvision/simulation/VideoSimUtil.java @@ -28,7 +28,7 @@ import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Translation3d; import edu.wpi.first.math.util.Units; -import edu.wpi.first.util.RuntimeLoader; +import edu.wpi.first.util.CombinedRuntimeLoader; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.ArrayList; @@ -68,10 +68,7 @@ public class VideoSimUtil { static { try { - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); + CombinedRuntimeLoader.loadLibraries(OpenCVHelp.class, Core.NATIVE_LIBRARY_NAME, "cscorejni"); } catch (Exception e) { throw new RuntimeException("Failed to load native libraries!", e); } diff --git a/photon-lib/src/test/java/org/photonvision/OpenCVTest.java b/photon-lib/src/test/java/org/photonvision/OpenCVTest.java index e483833111..3cab3d496e 100644 --- a/photon-lib/src/test/java/org/photonvision/OpenCVTest.java +++ b/photon-lib/src/test/java/org/photonvision/OpenCVTest.java @@ -40,7 +40,6 @@ import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.networktables.NetworkTablesJNI; import edu.wpi.first.util.CombinedRuntimeLoader; -import edu.wpi.first.util.RuntimeLoader; import edu.wpi.first.util.WPIUtilJNI; import java.util.List; import org.junit.jupiter.api.BeforeAll; @@ -101,13 +100,9 @@ public static void setUp() { "ntcorejni", "wpinetjni", "wpiHaljni", + Core.NATIVE_LIBRARY_NAME, "cscorejni", - "cscorejnicvstatic"); - - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); + "apriltagjni"); } catch (Exception e) { e.printStackTrace(); } diff --git a/photon-lib/src/test/java/org/photonvision/VisionSystemSimTest.java b/photon-lib/src/test/java/org/photonvision/VisionSystemSimTest.java index c53e006717..d9ed86d8ed 100644 --- a/photon-lib/src/test/java/org/photonvision/VisionSystemSimTest.java +++ b/photon-lib/src/test/java/org/photonvision/VisionSystemSimTest.java @@ -46,7 +46,6 @@ import edu.wpi.first.networktables.NetworkTableInstance; import edu.wpi.first.networktables.NetworkTablesJNI; import edu.wpi.first.util.CombinedRuntimeLoader; -import edu.wpi.first.util.RuntimeLoader; import edu.wpi.first.util.WPIUtilJNI; import java.util.ArrayList; import java.util.List; @@ -101,13 +100,9 @@ public static void setUp() { "ntcorejni", "wpinetjni", "wpiHaljni", + Core.NATIVE_LIBRARY_NAME, "cscorejni", - "cscorejnicvstatic"); - - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); + "apriltagjni"); } catch (Exception e) { e.printStackTrace(); } diff --git a/photon-server/build.gradle b/photon-server/build.gradle index 4a8b1691f1..2fdfcff4ec 100644 --- a/photon-server/build.gradle +++ b/photon-server/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.1.0' + id "application" + id 'com.github.johnrengelman.shadow' version '8.1.1' + id "com.github.node-gradle.node" version "7.0.1" + id "org.hidetake.ssh" version "2.11.2" + id 'edu.wpi.first.WpilibTools' version '1.3.0' } -apply plugin: "application" -apply plugin: "com.github.johnrengelman.shadow" -apply plugin: "org.hidetake.ssh" - evaluationDependsOn(':photon-core') mainClassName = 'org.photonvision.Main' @@ -15,26 +15,12 @@ version versionString + (project.hasProperty('pionly') ? "-raspi" : "") apply from: "${rootDir}/shared/common.gradle" -def nativeConfigName = 'wpilibTestNative' -def nativeConfig = configurations.create(nativeConfigName) - -def nativeTasks = wpilibTools.createExtractionTasks { configurationName = nativeConfigName } - -nativeTasks.addToSourceSetResources(sourceSets.main) - -nativeConfig.dependencies.add wpilibTools.deps.cscore() -nativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore") -nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet") -nativeConfig.dependencies.add wpilibTools.deps.wpilib("hal") -nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil") -nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag") -nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath") - dependencies { implementation project(':photon-core') implementation project(':photon-targeting') implementation "io.javalin:javalin:$javalinVersion" + implementation "org.slf4j:slf4j-simple:2.0.7" implementation wpilibTools.deps.wpilibJava("wpiutil") implementation wpilibTools.deps.wpilibJava("wpimath") @@ -42,43 +28,35 @@ dependencies { implementation wpilibTools.deps.wpilibJava("hal") implementation wpilibTools.deps.wpilibJava("ntcore") implementation wpilibTools.deps.wpilibJava("wpilibj") + implementation wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) implementation "org.msgpack:msgpack-core:0.9.0" implementation "org.msgpack:jackson-dataformat-msgpack:0.9.0" - - implementation "org.slf4j:slf4j-simple:2.0.7" } shadowJar { + archiveBaseName = "photonvision" + archiveVersion = project.version as String + archiveClassifier.set(wpilibTools.currentPlatform.platformName) configurations = [ project.configurations.runtimeClasspath ] - String name = "photonvision-${project.version}" - archiveClassifier.set(wpilibTools.platformMapper.currentPlatform.platformName) - archiveBaseName = "photonvision" - archiveVersion = project.version - // archiveFileName.set("${name}.jar") } -task runNpmOnClient(type: Exec) { - workingDir "${projectDir}/../photon-client" - if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) { - commandLine 'cmd', '/c', 'npm run build' - } else { - commandLine 'npm', 'run', 'build' - } + +node { + nodeProjectDir = file("${projectDir}/../photon-client") } -task copyClientUIToResources(type: Copy) { +tasks.register('copyClientUIToResources', Copy) { from "${projectDir}/../photon-client/dist/" into "${projectDir}/src/main/resources/web/" } -task buildAndCopyUI {} - -buildAndCopyUI.dependsOn copyClientUIToResources -copyClientUIToResources.dependsOn runNpmOnClient -copyClientUIToResources.shouldRunAfter runNpmOnClient +tasks.register("buildAndCopyUI") { + dependsOn "npm_run_build" + finalizedBy "copyClientUIToResources" +} run { if (project.hasProperty("profile")) { @@ -108,9 +86,6 @@ remotes { } } -import java.io.*; -import java.net.*; - task findDeployTarget { doLast { if(project.hasProperty('tgtIP')){ @@ -148,18 +123,9 @@ run { environment "PATH_PREFIX", "../" } -// task overrideToPi { -// doLast { -// project.setProperty('ArchOverride', 'linuxarm32') -// } -// } - - - task deploy { - //dependsOn overrideToPi - dependsOn assemble dependsOn findDeployTarget + dependsOn assemble doLast { println 'Starting deployment to ' + findDeployTarget.rmt.host diff --git a/photon-targeting/build.gradle b/photon-targeting/build.gradle index e4cc2d7d96..256b66ce70 100644 --- a/photon-targeting/build.gradle +++ b/photon-targeting/build.gradle @@ -1,11 +1,16 @@ -apply plugin: "java" +plugins { + id "java" + id 'edu.wpi.first.WpilibTools' version '1.3.0' +} apply from: "${rootDir}/shared/common.gradle" dependencies { implementation wpilibTools.deps.wpilibJava("wpimath") implementation wpilibTools.deps.wpilibJava("apriltag") - implementation "org.ejml:ejml-simple:0.42" + implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) + + implementation group: "org.ejml", name: "ejml-simple", version: wpi.versions.ejmlVersion.get() // Junit testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") diff --git a/photon-targeting/src/main/java/org/photonvision/estimation/OpenCVHelp.java b/photon-targeting/src/main/java/org/photonvision/estimation/OpenCVHelp.java index 9e9b0fd84a..1f3b8b9761 100644 --- a/photon-targeting/src/main/java/org/photonvision/estimation/OpenCVHelp.java +++ b/photon-targeting/src/main/java/org/photonvision/estimation/OpenCVHelp.java @@ -26,7 +26,7 @@ import edu.wpi.first.math.geometry.Transform3d; import edu.wpi.first.math.geometry.Translation3d; import edu.wpi.first.math.numbers.*; -import edu.wpi.first.util.RuntimeLoader; +import edu.wpi.first.util.CombinedRuntimeLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -54,10 +54,7 @@ public final class OpenCVHelp { static { try { - var loader = - new RuntimeLoader<>( - Core.NATIVE_LIBRARY_NAME, RuntimeLoader.getDefaultExtractionRoot(), Core.class); - loader.loadLibrary(); + CombinedRuntimeLoader.loadLibraries(OpenCVHelp.class, Core.NATIVE_LIBRARY_NAME, "cscorejni"); } catch (Exception e) { throw new RuntimeException("Failed to load native libraries!", e); } diff --git a/photonlib-java-examples/simaimandrange/2020-field.png b/photonlib-java-examples/simaimandrange/2020-field.png new file mode 100644 index 0000000000..8b18648e82 Binary files /dev/null and b/photonlib-java-examples/simaimandrange/2020-field.png differ diff --git a/photonlib-java-examples/simaimandrange/2020-infiniterecharge.json b/photonlib-java-examples/simaimandrange/2020-infiniterecharge.json new file mode 100644 index 0000000000..7109f5c6e3 --- /dev/null +++ b/photonlib-java-examples/simaimandrange/2020-infiniterecharge.json @@ -0,0 +1,19 @@ +{ + "game": "Infinite Recharge", + "field-image": "2020-field.png", + "field-corners": { + "top-left": [ + 96, + 25 + ], + "bottom-right": [ + 1040, + 514 + ] + }, + "field-size": [ + 52.4375, + 26.9375 + ], + "field-unit": "foot" +} diff --git a/photonlib-java-examples/simaimandrange/simgui.json b/photonlib-java-examples/simaimandrange/simgui.json index 2ebe473318..4ff3cc0f5c 100644 --- a/photonlib-java-examples/simaimandrange/simgui.json +++ b/photonlib-java-examples/simaimandrange/simgui.json @@ -22,6 +22,7 @@ ], "weight": 3.0 }, + "bottom": 514, "cameras": { "arrowColor": [ 0.0, @@ -33,7 +34,19 @@ "selectable": false, "style": "Hidden" }, + "height": 8.210550308227539, + "image": "2020-field.png", + "left": 96, + "right": 1040, "targets": { + "arrowColor": [ + 0.27848100662231445, + 1.0, + 0.0, + 255.0 + ], + "arrowSize": 58, + "arrowWeight": 6.0, "color": [ 0.05063295364379883, 1.0, @@ -43,6 +56,8 @@ "style": "Hidden", "weight": 1.0 }, + "top": 25, + "width": 15.982950210571289, "window": { "visible": true } diff --git a/photonlib-java-examples/swervedriveposeestsim/2023-field.json b/photonlib-java-examples/swervedriveposeestsim/2023-field.json new file mode 100644 index 0000000000..ff4c5ca238 --- /dev/null +++ b/photonlib-java-examples/swervedriveposeestsim/2023-field.json @@ -0,0 +1,19 @@ +{ + "game": "Charged Up", + "field-image": "2023-field.png", + "field-corners": { + "top-left": [ + 46, + 36 + ], + "bottom-right": [ + 1088, + 544 + ] + }, + "field-size": [ + 54.27083, + 26.2916 + ], + "field-unit": "foot" + } diff --git a/photonlib-java-examples/swervedriveposeestsim/2023-field.png b/photonlib-java-examples/swervedriveposeestsim/2023-field.png new file mode 100644 index 0000000000..ab3f0ff333 Binary files /dev/null and b/photonlib-java-examples/swervedriveposeestsim/2023-field.png differ diff --git a/photonlib-java-examples/swervedriveposeestsim/simgui.json b/photonlib-java-examples/swervedriveposeestsim/simgui.json index 23b949fb97..76fbf80d35 100644 --- a/photonlib-java-examples/swervedriveposeestsim/simgui.json +++ b/photonlib-java-examples/swervedriveposeestsim/simgui.json @@ -57,10 +57,12 @@ "weight": 2.0 }, "apriltag": { + "arrows": false, "image": "tag-green.png", - "length": 0.5, - "width": 0.4000000059604645 + "length": 0.6000000238418579, + "width": 0.5 }, + "bottom": 544, "cameras": { "arrowColor": [ 0.29535865783691406, @@ -75,7 +77,11 @@ "weight": 1.0, "width": 1.0 }, - "height": 8.013699531555176, + "height": 8.013679504394531, + "image": "2023-field.png", + "left": 46, + "right": 1088, + "top": 36, "visibleTargetPoses": { "arrows": false, "image": "tag-blue.png", @@ -83,7 +89,7 @@ "selectable": false, "width": 0.4000000059604645 }, - "width": 16.541749954223633, + "width": 16.541748046875, "window": { "visible": true } diff --git a/shared/common.gradle b/shared/common.gradle index 408889d2ba..55f58760a9 100644 --- a/shared/common.gradle +++ b/shared/common.gradle @@ -1,31 +1,33 @@ -import java.nio.file.Path -import java.time.LocalDateTime -import java.time.format.DateTimeFormatter - // Plugins -apply plugin: "jacoco" apply plugin: "java" +apply plugin: "jacoco" java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } -wpilibTools.deps.wpilibVersion = wpilibVersion +wpilibTools.deps.wpilibVersion = wpi.versions.wpilibVersion.get() -dependencies { - // Jackson - implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-core:2.12.4" - implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4" +def nativeConfigName = 'wpilibTestNative' +def nativeConfig = configurations.create(nativeConfigName) - // Apache commons - implementation group: "org.apache.commons", name: "commons-lang3", version: "3.12.0" - implementation group: "commons-io", name: "commons-io", version: "2.11.0" - implementation group: "commons-cli", name: "commons-cli", version: "1.5.0" - implementation "org.apache.commons:commons-collections4:4.4" - implementation "org.apache.commons:commons-exec:1.3" +def nativeTasks = wpilibTools.createExtractionTasks { + configurationName = nativeConfigName +} +nativeTasks.addToSourceSetResources(sourceSets.main) + +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpimath") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpinet") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("wpiutil") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("ntcore") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("cscore") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("apriltag") +nativeConfig.dependencies.add wpilibTools.deps.wpilib("hal") +nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) + +dependencies { // WPILib deps implementation wpilibTools.deps.wpilibJava("wpiutil") implementation wpilibTools.deps.wpilibJava("cameraserver") @@ -35,13 +37,23 @@ dependencies { implementation wpilibTools.deps.wpilibJava("ntcore") implementation wpilibTools.deps.wpilibJava("hal") implementation wpilibTools.deps.wpilibJava("wpilibj") + implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get()) - implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:$openCVversion" - implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-jni:$openCVversion:$jniPlatform" + // Jackson + implementation group: "com.fasterxml.jackson.core", name: "jackson-annotations", version: wpi.versions.jacksonVersion.get() + implementation group: "com.fasterxml.jackson.core", name: "jackson-core", version: wpi.versions.jacksonVersion.get() + implementation group: "com.fasterxml.jackson.core", name: "jackson-databind", version: wpi.versions.jacksonVersion.get() + + // Apache commons + implementation group: "org.apache.commons", name: "commons-lang3", version: "3.12.0" + implementation group: "commons-io", name: "commons-io", version: "2.11.0" + implementation group: "commons-cli", name: "commons-cli", version: "1.5.0" + implementation "org.apache.commons:commons-collections4:4.4" + implementation "org.apache.commons:commons-exec:1.3" - implementation "org.ejml:ejml-simple:0.42" + implementation group: "org.ejml", name: "ejml-simple", version: wpi.versions.ejmlVersion.get() + implementation group: "us.hebi.quickbuf", name: "quickbuf-runtime", version: wpi.versions.quickbufVersion.get(); - // test stuff testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") // wpilib serde @@ -57,7 +69,7 @@ test { finalizedBy jacocoTestReport } -task testHeadless(type: Test) { +tasks.register('testHeadless', Test) { group = "verification" systemProperty("java.awt.headless", "true") useJUnitPlatform() @@ -65,13 +77,12 @@ task testHeadless(type: Test) { workingDir = "../" } -task generateJavaDocs(type: Javadoc) { +tasks.register('generateJavaDocs', Javadoc) { source = sourceSets.main.allJava classpath = sourceSets.main.compileClasspath destinationDir = file("${projectDir}/build/docs") } - jacoco { toolVersion = "0.8.9" reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir') diff --git a/shared/config.gradle b/shared/config.gradle index f7c7c33c6b..ca2df48acb 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -1,3 +1,5 @@ +apply plugin: "edu.wpi.first.NativeUtils" + // Configure Native-Utils WPI Plugin nativeUtils.addWpiNativeUtils() nativeUtils.withCrossRoboRIO() @@ -6,15 +8,12 @@ nativeUtils.withCrossLinuxArm64() // Configure WPI dependencies. nativeUtils.wpi.configureDependencies { + wpiVersion = wpilibVersion opencvYear = 'frc2024' + opencvVersion = openCVversion googleTestYear = "frc2023" - - wpiVersion = wpilibVersion - wpimathVersion = wpilibVersion niLibVersion = "2024.1.1" - opencvVersion = openCVversion googleTestVersion = "1.12.1-2" - imguiVersion = "1.86-1" } // Configure warnings and errors