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 f593638b90..8f4fe228ba 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,11 @@ plugins { - id "com.diffplug.spotless" version "6.19.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 "com.diffplug.spotless" version "6.22.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() @@ -49,6 +43,10 @@ wpilibTools.deps.wpilibVersion = wpilibVersion spotless { java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**', "photon-core\\src\\main\\java\\org\\photonvision\\PhotonVersion.java", "photon-lib\\src\\main\\java\\org\\photonvision\\PhotonVersion.java" + } toggleOffOn() googleJavaFormat() indentWithTabs(2) @@ -57,13 +55,37 @@ spotless { trimTrailingWhitespace() endWithNewline() } - java { - target "**/*.java" - targetExclude("photon-core/src/main/java/org/photonvision/PhotonVersion.java") - targetExclude("photon-lib/src/main/java/org/photonvision/PhotonVersion.java") + groovyGradle { + target fileTree('.') { + include '**/*.gradle' + exclude '**/build/**', '**/build-*/**' + } + greclipse() + indentWithSpaces(4) + trimTrailingWhitespace() + endWithNewline() + } + format 'xml', { + target fileTree('.') { + include '**/*.xml' + exclude '**/build/**', '**/build-*/**', "**/.idea/**" + } + eclipseWtp('xml') + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() + } + format 'misc', { + target fileTree('.') { + include '**/*.md', '**/.gitignore' + exclude '**/build/**', '**/build-*/**' + } + trimTrailingWhitespace() + indentWithSpaces(2) + endWithNewline() } } 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-client/src/components/dashboard/tabs/AprilTagTab.vue b/photon-client/src/components/dashboard/tabs/AprilTagTab.vue index fa56016a56..25ef85b492 100644 --- a/photon-client/src/components/dashboard/tabs/AprilTagTab.vue +++ b/photon-client/src/components/dashboard/tabs/AprilTagTab.vue @@ -25,7 +25,7 @@ const interactiveCols = computed( diff --git a/photon-client/src/components/dashboard/tabs/PnPTab.vue b/photon-client/src/components/dashboard/tabs/PnPTab.vue index dddf4b072a..c242344a92 100644 --- a/photon-client/src/components/dashboard/tabs/PnPTab.vue +++ b/photon-client/src/components/dashboard/tabs/PnPTab.vue @@ -21,15 +21,16 @@ const interactiveCols = computed( v-model="useCameraSettingsStore().currentPipelineSettings.targetModel" label="Target Model" :items="[ - { name: '2020 High Goal Outer', value: TargetModel.InfiniteRechargeHighGoalOuter }, - { name: '2020 High Goal Inner', value: TargetModel.InfiniteRechargeHighGoalInner }, + { name: '2016 High Goal', value: TargetModel.StrongholdHighGoal }, { name: '2019 Dual Target', value: TargetModel.DeepSpaceDualTarget }, + { name: '2020 High Goal Outer', value: TargetModel.InfiniteRechargeHighGoalOuter }, { name: '2020 Power Cell (7in)', value: TargetModel.CircularPowerCell7in }, { name: '2022 Cargo Ball (9.5in)', value: TargetModel.RapidReactCircularCargoBall }, - { name: '2016 High Goal', value: TargetModel.StrongholdHighGoal }, { name: '200mm AprilTag', value: TargetModel.Apriltag_200mm }, { name: '6in (16h5) Aruco', value: TargetModel.Aruco6in_16h5 }, - { name: '6in (16h5) AprilTag', value: TargetModel.Apriltag6in_16h5 } + { name: '6in (16h5) AprilTag', value: TargetModel.Apriltag6in_16h5 }, + { name: '6.5in (36h11) Aruco', value: TargetModel.Aruco6p5in_36h11 }, + { name: '6.5in (36h11) AprilTag', value: TargetModel.Apriltag6p5in_36h11 } ]" :select-cols="interactiveCols" @input="(value) => useCameraSettingsStore().changeCurrentPipelineSetting({ targetModel: value }, false)" diff --git a/photon-client/src/types/PipelineTypes.ts b/photon-client/src/types/PipelineTypes.ts index d6debea90d..08d231b732 100644 --- a/photon-client/src/types/PipelineTypes.ts +++ b/photon-client/src/types/PipelineTypes.ts @@ -21,15 +21,16 @@ export enum RobotOffsetPointMode { } export enum TargetModel { - InfiniteRechargeHighGoalOuter = 0, - InfiniteRechargeHighGoalInner = 1, - DeepSpaceDualTarget = 2, + StrongholdHighGoal = 0, + DeepSpaceDualTarget = 1, + InfiniteRechargeHighGoalOuter = 2, CircularPowerCell7in = 3, RapidReactCircularCargoBall = 4, - StrongholdHighGoal = 5, - Apriltag_200mm = 6, - Aruco6in_16h5 = 7, - Apriltag6in_16h5 = 8 + Apriltag_200mm = 5, + Aruco6in_16h5 = 6, + Apriltag6in_16h5 = 7, + Aruco6p5in_36h11 = 8, + Apriltag6p5in_36h11 = 9 } export interface PipelineSettings { 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-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java index 97ec1f2f3c..f49aaab5d2 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/AprilTagPipeline.java @@ -31,6 +31,7 @@ import org.photonvision.common.configuration.ConfigManager; import org.photonvision.common.util.math.MathUtils; import org.photonvision.targeting.MultiTargetPNPResults; +import org.photonvision.vision.apriltag.AprilTagFamily; import org.photonvision.vision.frame.Frame; import org.photonvision.vision.frame.FrameThresholdType; import org.photonvision.vision.pipe.CVPipe.CVPipeResult; @@ -69,27 +70,15 @@ protected void setPipeParamsImpl() { // Sanitize thread count - not supported to have fewer than 1 threads settings.threads = Math.max(1, settings.threads); - // if (cameraQuirks.hasQuirk(CameraQuirk.PiCam) && LibCameraJNI.isSupported()) { - // // TODO: Picam grayscale - // LibCameraJNI.setRotation(settings.inputImageRotationMode.value); - // // LibCameraJNI.setShouldCopyColor(true); // need the color image to grayscale - // } - - // TODO (HACK): tag width is Fun because it really belongs in the "target model" - // We need the tag width for the JNI to figure out target pose, but we need a - // target model for the draw 3d targets pipeline to work... - // for now, hard code tag width based on enum value - double tagWidth = Units.inchesToMeters(3 * 2); // for 6in 16h5 tag. - - // AprilTagDetectorParams aprilTagDetectionParams = - // new AprilTagDetectorParams( - // settings.tagFamily, - // settings.decimate, - // settings.blur, - // settings.threads, - // settings.debug, - // settings.refineEdges); + double tagWidth; + if (settings.tagFamily == AprilTagFamily.kTag36h11) { + // 2024 tag, guess 6.5in + tagWidth = Units.inchesToMeters(6.5); + } else { + // 2023/other: best guess is 6in + tagWidth = Units.inchesToMeters(6); + } var config = new AprilTagDetector.Config(); config.numThreads = settings.threads; diff --git a/photon-core/src/main/java/org/photonvision/vision/target/TargetModel.java b/photon-core/src/main/java/org/photonvision/vision/target/TargetModel.java index de6635b588..3e8a967ba2 100644 --- a/photon-core/src/main/java/org/photonvision/vision/target/TargetModel.java +++ b/photon-core/src/main/java/org/photonvision/vision/target/TargetModel.java @@ -121,7 +121,22 @@ public enum TargetModel implements Releasable { new Point3(-Units.inchesToMeters(3), Units.inchesToMeters(3), 0), new Point3(-Units.inchesToMeters(3), -Units.inchesToMeters(3), 0), new Point3(Units.inchesToMeters(3), -Units.inchesToMeters(3), 0)), - Units.inchesToMeters(3 * 2)); + Units.inchesToMeters(3 * 2)), + // 2024 FRC tag. 6.5in inner tag, 8.125 overall + kAruco6p5in_36h11( + List.of( + new Point3(Units.inchesToMeters(6.5 / 2.0), Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(Units.inchesToMeters(6.5 / 2.0), -Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(-Units.inchesToMeters(6.5 / 2.0), -Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(Units.inchesToMeters(6.5 / 2.0), -Units.inchesToMeters(6.5 / 2.0), 0)), + Units.inchesToMeters(6.5)), + k6p5in_36h11( + List.of( + new Point3(-Units.inchesToMeters(6.5 / 2.0), Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(Units.inchesToMeters(6.5 / 2.0), Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(Units.inchesToMeters(6.5 / 2.0), -Units.inchesToMeters(6.5 / 2.0), 0), + new Point3(-Units.inchesToMeters(6.5 / 2.0), -Units.inchesToMeters(6.5 / 2.0), 0)), + Units.inchesToMeters(6.5)); @JsonIgnore private MatOfPoint3f realWorldTargetCoordinates; @JsonIgnore private final MatOfPoint3f visualizationBoxBottom = new MatOfPoint3f(); diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index baae8fcc7d..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") @@ -120,17 +113,17 @@ task generateVendorJson() { outputs.file photonlibFileOutput inputs.file photonlibFileInput - println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput" + println "Writing vendor JSON ${pubVersion} to $photonlibFileOutput" - if (photonlibFileOutput.exists()) { - photonlibFileOutput.delete() - } - photonlibFileOutput.parentFile.mkdirs() + if (photonlibFileOutput.exists()) { + photonlibFileOutput.delete() + } + photonlibFileOutput.parentFile.mkdirs() - def read = photonlibFileInput.text + def read = photonlibFileInput.text .replace('${photon_version}', pubVersion) .replace('${frc_year}', frcYear) - photonlibFileOutput.text = read + photonlibFileOutput.text = read outputs.upToDateWhen { false } } @@ -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 8e427bcbdd..15f1dce1fb 100644 --- a/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java +++ b/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java @@ -34,7 +34,7 @@ import edu.wpi.first.math.Pair; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Rotation2d; -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; @@ -96,10 +96,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 92b50a81b8..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,50 +28,44 @@ 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 { - configurations = [project.configurations.runtimeClasspath] - String name = "photonvision-${project.version}" - archiveClassifier.set(wpilibTools.platformMapper.currentPlatform.platformName) archiveBaseName = "photonvision" - archiveVersion = project.version - // archiveFileName.set("${name}.jar") + archiveVersion = project.version as String + archiveClassifier.set(wpilibTools.currentPlatform.platformName) + configurations = [ + project.configurations.runtimeClasspath + ] } -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")) { jvmArgs=[ - "-Dcom.sun.management.jmxremote=true", - "-Dcom.sun.management.jmxremote.ssl=false", - "-Dcom.sun.management.jmxremote.authenticate=false", - "-Dcom.sun.management.jmxremote.port=5000", - "-Djava.rmi.server.hostname=0.0.0.0", + "-Dcom.sun.management.jmxremote=true", + "-Dcom.sun.management.jmxremote.ssl=false", + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Dcom.sun.management.jmxremote.port=5000", + "-Djava.rmi.server.hostname=0.0.0.0", ] } } @@ -106,9 +86,6 @@ remotes { } } -import java.io.*; -import java.net.*; - task findDeployTarget { doLast { if(project.hasProperty('tgtIP')){ @@ -143,23 +120,14 @@ task findDeployTarget { } run { - environment "PATH_PREFIX", "../" + environment "PATH_PREFIX", "../" } -// task overrideToPi { -// doLast { -// project.setProperty('ArchOverride', 'linuxarm32') -// } -// } - - - task deploy { - //dependsOn overrideToPi - dependsOn assemble dependsOn findDeployTarget + dependsOn assemble - doLast { + doLast { println 'Starting deployment to ' + findDeployTarget.rmt.host println 'targetArch = ' + wpilibTools.platformMapper.currentPlatform.platformName ssh.run{ @@ -170,7 +138,7 @@ task deploy { execute 'sleep 3' // Copy into a folder owned by PI. Mostly because, as far as I can tell, the put command doesn't support sudo. put from: "${projectDir}/build/libs/photonvision-${project.version}-${wpilibTools.platformMapper.currentPlatform.platformName}.jar", into: "/tmp/photonvision.jar" - //belt-and-suspenders. Make sure the old jar is gone first. + //belt-and-suspenders. Make sure the old jar is gone first. execute 'sudo rm -f /opt/photonvision/photonvision.jar' //Copy in the new .jar and make sure it's executable execute 'sudo mv /tmp/photonvision.jar /opt/photonvision/photonvision.jar' 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 3f89918d62..e7028d58cc 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-cpp-examples/examples.gradle b/photonlib-cpp-examples/examples.gradle index 976440f33f..1207d05f1d 100644 --- a/photonlib-cpp-examples/examples.gradle +++ b/photonlib-cpp-examples/examples.gradle @@ -4,11 +4,11 @@ def EXCLUDED_DIRS = ["bin", "build"] // List all non-hidden directories not in EXCUDED_DIRS ext.exampleFolderNames = file("${rootDir}") - .listFiles() - .findAll { - return (it.isDirectory() - && !it.isHidden() - && !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".") - && it.toPath().resolve("build.gradle").toFile().exists()) - } - .collect { it.name } + .listFiles() + .findAll { + return (it.isDirectory() + && !it.isHidden() + && !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".") + && it.toPath().resolve("build.gradle").toFile().exists()) + } + .collect { it.name } diff --git a/photonlib-java-examples/aimandrange/build.gradle b/photonlib-java-examples/aimandrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/aimandrange/build.gradle +++ b/photonlib-java-examples/aimandrange/build.gradle @@ -78,7 +78,11 @@ wpi.sim.addDriverstation() // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE } diff --git a/photonlib-java-examples/aimattarget/build.gradle b/photonlib-java-examples/aimattarget/build.gradle index 1442f184c9..d0f6ecfecc 100644 --- a/photonlib-java-examples/aimattarget/build.gradle +++ b/photonlib-java-examples/aimattarget/build.gradle @@ -78,7 +78,11 @@ wpi.sim.addDriverstation() // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE } diff --git a/photonlib-java-examples/examples.gradle b/photonlib-java-examples/examples.gradle index 976440f33f..1207d05f1d 100644 --- a/photonlib-java-examples/examples.gradle +++ b/photonlib-java-examples/examples.gradle @@ -4,11 +4,11 @@ def EXCLUDED_DIRS = ["bin", "build"] // List all non-hidden directories not in EXCUDED_DIRS ext.exampleFolderNames = file("${rootDir}") - .listFiles() - .findAll { - return (it.isDirectory() - && !it.isHidden() - && !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".") - && it.toPath().resolve("build.gradle").toFile().exists()) - } - .collect { it.name } + .listFiles() + .findAll { + return (it.isDirectory() + && !it.isHidden() + && !(it.name in EXCLUDED_DIRS) && !it.name.startsWith(".") + && it.toPath().resolve("build.gradle").toFile().exists()) + } + .collect { it.name } diff --git a/photonlib-java-examples/getinrange/build.gradle b/photonlib-java-examples/getinrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/getinrange/build.gradle +++ b/photonlib-java-examples/getinrange/build.gradle @@ -78,7 +78,11 @@ wpi.sim.addDriverstation() // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE } 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/build.gradle b/photonlib-java-examples/simaimandrange/build.gradle index 7dda3b59b0..f3750f10b2 100644 --- a/photonlib-java-examples/simaimandrange/build.gradle +++ b/photonlib-java-examples/simaimandrange/build.gradle @@ -78,7 +78,11 @@ wpi.sim.addDriverstation() // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE } 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/build.gradle b/photonlib-java-examples/swervedriveposeestsim/build.gradle index d0be7323ec..a4d1b60579 100644 --- a/photonlib-java-examples/swervedriveposeestsim/build.gradle +++ b/photonlib-java-examples/swervedriveposeestsim/build.gradle @@ -78,7 +78,11 @@ wpi.sim.addDriverstation() // in order to make them all available at runtime. Also adding the manifest so WPILib // knows where to look for our Robot Class. jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from { + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) duplicatesStrategy = DuplicatesStrategy.INCLUDE } 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 cb4ce3f80b..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') @@ -89,7 +100,7 @@ jacocoTestReport { afterEvaluate { classDirectories.setFrom(files(classDirectories.files.collect { fileTree(dir: it, - exclude: "edu/wpi/**" + exclude: "edu/wpi/**" ) })) } diff --git a/shared/config.gradle b/shared/config.gradle index 3d5f91b150..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 @@ -78,7 +77,7 @@ ext.createComponentZipTasks = { components, names, base, type, project, func -> if (it in NativeLibrarySpec && stringNames.contains(it.name)) { it.binaries.each { if (!it.buildable) return - def target = nativeUtils.getPublishClassifier(it) + def target = nativeUtils.getPublishClassifier(it) if (configMap.containsKey(target)) { configMap.get(target).add(it) } else { @@ -128,7 +127,7 @@ ext.createAllCombined = { list, name, base, type, project -> list.each { if (it.name.endsWith('debug')) return - from project.zipTree(it.archiveFile) + from project.zipTree(it.archiveFile) dependsOn it } } @@ -140,7 +139,6 @@ ext.createAllCombined = { list, name, base, type, project -> } return task - } // Create the standard ZIP format for the dependencies. diff --git a/versioningHelper.gradle b/versioningHelper.gradle index 4b085f3121..e9dd6e3d0a 100644 --- a/versioningHelper.gradle +++ b/versioningHelper.gradle @@ -3,7 +3,8 @@ import java.time.LocalDateTime import java.time.format.DateTimeFormatter gradle.allprojects { - ext.getCurrentVersion = { -> + ext.getCurrentVersion = { + -> def stdout = new ByteArrayOutputStream() String tagIsh try {