Skip to content

Commit

Permalink
Bump wpilib versions to 2024 beta 1 (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 authored Oct 15, 2023
1 parent 82e3da6 commit 9991f86
Show file tree
Hide file tree
Showing 52 changed files with 125 additions and 115 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ jobs:
run: |
chmod +x gradlew
./gradlew copyPhotonlib -x check
./gradlew buildAllExamples -x check --max-workers 2
./gradlew build -x check --max-workers 2
- name: Build C++ examples
working-directory: photonlib-cpp-examples
run: |
chmod +x gradlew
./gradlew copyPhotonlib -x check
./gradlew buildAllExamples -x check --max-workers 2
./gradlew build -x check --max-workers 2
photon-build-all:
# The type of runner that the job will run on.
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -225,6 +225,7 @@ jobs:
include:
- 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
Expand Down Expand Up @@ -255,7 +256,7 @@ jobs:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2023-22.04
- container: wpilib/roborio-cross-ubuntu:2024-22.04
artifact-name: Athena
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
artifact-name: Raspbian
Expand Down
18 changes: 12 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ 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.0.0"
id "edu.wpi.first.GradleVsCode" version "1.1.0"
id "edu.wpi.first.NativeUtils" version "2023.11.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.0.0'
id 'edu.wpi.first.WpilibTools' version '1.1.0'
}

import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency;
Expand All @@ -26,10 +26,12 @@ allprojects {
apply from: "versioningHelper.gradle"

ext {
wpilibVersion = "2023.4.2"
opencvVersion = "4.6.0-4"
wpilibVersion = "2024.1.1-beta-1"
openCVversion = "4.8.0-1"
joglVersion = "2.4.0-rc-20200307"
javalinVersion = "5.6.2"
frcYear = "2024"

pubVersion = versionString
isDev = pubVersion.startsWith("dev")

Expand Down Expand Up @@ -61,3 +63,7 @@ spotless {
targetExclude("photon-lib/src/main/java/org/photonvision/PhotonVersion.java")
}
}

wrapper {
gradleVersion '8.3'
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services\.gradle\.org/distributions/gradle-8\.3-bin\.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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##*/}
Expand Down
2 changes: 1 addition & 1 deletion photon-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'edu.wpi.first.WpilibTools' version '1.0.0'
id 'edu.wpi.first.WpilibTools' version '1.1.0'
}

import java.nio.file.Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

package org.photonvision.vision.aruco;

import org.opencv.aruco.Aruco;
import org.opencv.aruco.ArucoDetector;
import org.opencv.aruco.DetectorParameters;
import org.opencv.aruco.Dictionary;
import org.opencv.objdetect.ArucoDetector;
import org.opencv.objdetect.DetectorParameters;
import org.opencv.objdetect.Objdetect;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;

Expand All @@ -31,15 +30,17 @@ public class ArucoDetectorParams {
private int m_iterations = -1;
private double m_accuracy = -1;

DetectorParameters parameters = DetectorParameters.create();
DetectorParameters parameters = new DetectorParameters();
ArucoDetector detector;

public ArucoDetectorParams() {
setDecimation(1);
setCornerAccuracy(25);
setCornerRefinementMaxIterations(100);

detector = new ArucoDetector(Dictionary.get(Aruco.DICT_APRILTAG_16h5), parameters);
detector =
new ArucoDetector(
Objdetect.getPredefinedDictionary(Objdetect.DICT_APRILTAG_16h5), parameters);
}

public void setDecimation(float decimate) {
Expand All @@ -56,7 +57,7 @@ public void setDecimation(float decimate) {
public void setCornerRefinementMaxIterations(int iters) {
if (iters == m_iterations || iters <= 0) return;

parameters.set_cornerRefinementMethod(Aruco.CORNER_REFINE_SUBPIX);
parameters.set_cornerRefinementMethod(Objdetect.CORNER_REFINE_SUBPIX);
parameters.set_cornerRefinementMaxIterations(iters); // 200

m_iterations = iters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import edu.wpi.first.math.util.Units;
import java.util.ArrayList;
import org.opencv.aruco.Aruco;
import org.opencv.aruco.ArucoDetector;
import org.opencv.core.Mat;
import org.opencv.objdetect.ArucoDetector;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import edu.wpi.first.math.util.Units;
import java.util.List;
import org.opencv.aruco.DetectorParameters;
import org.opencv.core.Mat;
import org.opencv.objdetect.DetectorParameters;
import org.photonvision.vision.aruco.ArucoDetectionResult;
import org.photonvision.vision.aruco.PhotonArucoDetector;
import org.photonvision.vision.pipe.CVPipe;
Expand All @@ -45,6 +45,6 @@ public void setParams(ArucoDetectionPipeParams params) {
}

public DetectorParameters getParameters() {
return params == null ? null : params.detectorParams.get_params();
return params == null ? null : params.detectorParams.getDetectorParameters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.photonvision.vision.pipe.impl;

import java.util.Objects;
import org.opencv.aruco.ArucoDetector;
import org.opencv.objdetect.ArucoDetector;
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;

public class ArucoDetectionPipeParams {
Expand Down
12 changes: 7 additions & 5 deletions photon-lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'edu.wpi.first.WpilibTools' version '1.0.0'
id 'edu.wpi.first.WpilibTools' version '1.1.0'
}

import java.nio.file.Path
Expand Down Expand Up @@ -50,10 +50,10 @@ dependencies {
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.frc2023.opencv:opencv-java:$opencvVersion"
implementation "edu.wpi.first.thirdparty.frc2023.opencv:opencv-jni:$opencvVersion:$jniPlatform"
implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:$openCVversion"
implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-jni:$openCVversion:$jniPlatform"

implementation "org.ejml:ejml-simple:0.41"
implementation "org.ejml:ejml-simple:0.42"

// Junit
testImplementation wpilibTools.deps.wpilibJava("cscore")
Expand Down Expand Up @@ -126,7 +126,9 @@ task generateVendorJson() {
if (photonlibFileOutput.exists()) {
photonlibFileOutput.delete()
}
def read = photonlibFileInput.text.replace('${photon_version}', pubVersion)
def read = photonlibFileInput.text
.replace('${photon_version}', pubVersion)
.replace('${frc_year}', frcYear)
photonlibFileOutput.write(read)
}

Expand Down
21 changes: 13 additions & 8 deletions photon-lib/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ copyAllOutputs.dependsOn outputVersions

ext.addTaskToCopyAllOutputs = { task ->
copyAllOutputs.dependsOn task
copyAllOutputs.inputs.file task.archivePath
copyAllOutputs.from task.archivePath
copyAllOutputs.inputs.file task.archiveFile
copyAllOutputs.from task.archiveFile
}

def artifactGroupId = 'org.photonvision'
Expand All @@ -49,7 +49,7 @@ def javaBaseName = "_GROUP_org_photonvision_photonlib_ID_${baseArtifactId}-java_
task cppHeadersZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "headers"
archiveClassifier = "headers"

from(licenseFile) {
into '/'
Expand All @@ -67,7 +67,7 @@ task cppHeadersZip(type: Zip) {
task cppSourcesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "sources"
archiveClassifier = "sources"

from(licenseFile) {
into '/'
Expand All @@ -84,12 +84,12 @@ build.dependsOn cppSourcesZip
addTaskToCopyAllOutputs(cppSourcesZip)

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

Expand All @@ -102,14 +102,14 @@ task outputJar(type: Jar, dependsOn: classes) {
task outputSourcesJar(type: Jar, dependsOn: classes) {
archiveBaseName = javaBaseName
destinationDirectory = outputsFolder
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

task outputJavadocJar(type: Jar, dependsOn: javadoc) {
archiveBaseName = javaBaseName
destinationDirectory = outputsFolder
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

Expand Down Expand Up @@ -198,5 +198,10 @@ model {
}
}

// So I don't actually know the _right_ way to tell gradle that the vendordep json publish requires generation first, so we're doing this
getTasksByName("publishVendorjsonPublicationToMavenLocal", false).each {
it.mustRunAfter generateVendorJson
}

publishToMavenLocal.dependsOn libraryBuild
publish.dependsOn libraryBuild
3 changes: 2 additions & 1 deletion photon-lib/src/generate/photonlib.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"fileName": "photonlib.json",
"name": "photonlib",
"version": "${photon_version}",
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004 ",
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004",
"frcYear": "${frc_year}",
"mavenUrls": [
"https://maven.photonvision.org/repository/internal",
"https://maven.photonvision.org/repository/snapshots"
Expand Down
11 changes: 4 additions & 7 deletions photon-lib/src/main/native/cpp/photonlib/PhotonPoseEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <utility>
#include <vector>

#include <Eigen/Core>
#include <frc/Errors.h>
#include <frc/geometry/Pose3d.h>
#include <frc/geometry/Rotation3d.h>
Expand Down Expand Up @@ -337,21 +338,17 @@ frc::Pose3d detail::ToPose3d(const cv::Mat& tvec, const cv::Mat& rvec) {
R = R.t(); // rotation of inverse
cv::Mat tvecI = -R * tvec; // translation of inverse

Vectord<3> tv;
Eigen::Matrix<double, 3, 1> tv;
tv[0] = +tvecI.at<double>(2, 0);
tv[1] = -tvecI.at<double>(0, 0);
tv[2] = -tvecI.at<double>(1, 0);
Vectord<3> rv;
Eigen::Matrix<double, 3, 1> rv;
rv[0] = +rvec.at<double>(2, 0);
rv[1] = -rvec.at<double>(0, 0);
rv[2] = +rvec.at<double>(1, 0);

return Pose3d(Translation3d(meter_t{tv[0]}, meter_t{tv[1]}, meter_t{tv[2]}),
Rotation3d(
// radian_t{rv[0]},
// radian_t{rv[1]},
// radian_t{rv[2]}
rv, radian_t{rv.norm()}));
Rotation3d(rv));
}

std::optional<EstimatedRobotPose> PhotonPoseEstimator::MultiTagPnpStrategy(
Expand Down
2 changes: 1 addition & 1 deletion photon-server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'edu.wpi.first.WpilibTools' version '1.0.0'
id 'edu.wpi.first.WpilibTools' version '1.1.0'
}

apply plugin: "application"
Expand Down
2 changes: 1 addition & 1 deletion photon-targeting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply from: "${rootDir}/shared/common.gradle"

dependencies {
implementation wpilibTools.deps.wpilibJava("wpimath")
implementation "org.ejml:ejml-simple:0.41"
implementation "org.ejml:ejml-simple:0.42"

// Junit
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
Expand Down
2 changes: 1 addition & 1 deletion photonlib-cpp-examples/aimandrange/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.4.2"
id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-1"

id "com.dorongold.task-tree" version "2.1.0"
}
Expand Down
3 changes: 2 additions & 1 deletion photonlib-cpp-examples/aimandrange/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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##*/}
Expand Down
2 changes: 1 addition & 1 deletion photonlib-cpp-examples/aimandrange/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginManagement {
mavenLocal()
jcenter()
gradlePluginPortal()
String frcYear = '2023'
String frcYear = '2024'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')
Expand Down
4 changes: 2 additions & 2 deletions photonlib-cpp-examples/aimandrange/src/main/include/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class Robot : public frc::TimedRobot {
// PID constants should be tuned per robot
const double LINEAR_P = 0.1;
const double LINEAR_D = 0.0;
frc2::PIDController forwardController{LINEAR_P, 0.0, LINEAR_D};
frc::PIDController forwardController{LINEAR_P, 0.0, LINEAR_D};

const double ANGULAR_P = 0.1;
const double ANGULAR_D = 0.0;
frc2::PIDController turnController{ANGULAR_P, 0.0, ANGULAR_D};
frc::PIDController turnController{ANGULAR_P, 0.0, ANGULAR_D};

// Change this to match the name of your camera
photonlib::PhotonCamera camera{"photonvision"};
Expand Down
2 changes: 1 addition & 1 deletion photonlib-cpp-examples/aimattarget/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.4.2"
id "edu.wpi.first.GradleRIO" version "2024.1.1-beta-1"

id "com.dorongold.task-tree" version "2.1.0"
}
Expand Down
Loading

0 comments on commit 9991f86

Please sign in to comment.