From 8095ea2bb013d7dff349a59423914e0d0db1d748 Mon Sep 17 00:00:00 2001 From: Michael Jansen Date: Thu, 26 Sep 2024 16:41:57 -0700 Subject: [PATCH] Downgrade to 2024 WPILib (#747) --- .github/workflows/build-pplib-release.yaml | 6 ++-- .github/workflows/pplib-ci.yml | 8 ++++-- pathplannerlib/build.gradle | 28 +++++++++---------- pathplannerlib/config.gradle | 4 +-- .../lib/commands/FollowPathCommand.java | 6 ++-- .../lib/trajectory/PathPlannerTrajectory.java | 6 ++-- .../PathPlannerTrajectoryState.java | 11 ++++---- .../SwerveModuleTrajectoryState.java | 4 +-- .../lib/commands/PathPlannerAuto.cpp | 14 ++++++---- .../pathplanner/lib/config/RobotConfig.cpp | 7 +++-- .../pathplanner/lib/path/PathPlannerPath.cpp | 14 ++++++---- .../lib/pathfinding/LocalADStar.cpp | 8 +++--- .../vendordeps/WPILibNewCommands.json | 4 +-- 13 files changed, 65 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-pplib-release.yaml b/.github/workflows/build-pplib-release.yaml index 30afc8f48..3af10bb3b 100644 --- a/.github/workflows/build-pplib-release.yaml +++ b/.github/workflows/build-pplib-release.yaml @@ -63,9 +63,9 @@ jobs: - os: windows-2022 artifact-name: PPLib-Win64 os-name: windows - - os: macos-14 - artifact-name: PPLib-macOS - os-name: macos + # - os: macos-14 + # artifact-name: PPLib-macOS + # os-name: macos name: "[PPLib] Build - ${{ matrix.artifact-name }}" runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/pplib-ci.yml b/.github/workflows/pplib-ci.yml index 36361dd93..03f6ec51c 100644 --- a/.github/workflows/pplib-ci.yml +++ b/.github/workflows/pplib-ci.yml @@ -160,6 +160,8 @@ jobs: path: pathplannerlib/build/allOutputs build-host: + env: + MACOSX_DEPLOYMENT_TARGET: 13.3 strategy: fail-fast: false matrix: @@ -167,9 +169,9 @@ jobs: - os: windows-2022 artifact-name: PPLib-Win64 os-name: windows - - os: macos-14 - artifact-name: PPLib-macOS - os-name: macos + # - os: macos-14 + # artifact-name: PPLib-macOS + # os-name: macos name: "[PPLib] Build - ${{ matrix.artifact-name }}" needs: [formatting, test] runs-on: ${{ matrix.os }} diff --git a/pathplannerlib/build.gradle b/pathplannerlib/build.gradle index 5a3ab5542..aea360c01 100644 --- a/pathplannerlib/build.gradle +++ b/pathplannerlib/build.gradle @@ -3,7 +3,7 @@ plugins { id 'java' id 'google-test' id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2' - id 'edu.wpi.first.NativeUtils' version '2025.1.0' + id 'edu.wpi.first.NativeUtils' version '2024.7.2' id 'edu.wpi.first.GradleJni' version '1.1.0' id 'edu.wpi.first.GradleVsCode' version '2.1.0' id 'com.diffplug.spotless' version '6.11.0' @@ -27,20 +27,20 @@ apply from: 'config.gradle' // Apply Java configuration dependencies { - implementation 'edu.wpi.first.cscore:cscore-java:2025.+' - implementation 'edu.wpi.first.cameraserver:cameraserver-java:2025.+' - implementation 'edu.wpi.first.ntcore:ntcore-java:2025.+' - implementation 'edu.wpi.first.wpilibj:wpilibj-java:2025.+' - implementation 'edu.wpi.first.wpiutil:wpiutil-java:2025.+' - implementation 'edu.wpi.first.wpimath:wpimath-java:2025.+' - implementation 'edu.wpi.first.wpilibNewCommands:wpilibNewCommands-java:2025.+' - implementation 'edu.wpi.first.wpiunits:wpiunits-java:2025.+' - implementation 'edu.wpi.first.hal:hal-java:2025.+' + implementation 'edu.wpi.first.cscore:cscore-java:2024.+' + implementation 'edu.wpi.first.cameraserver:cameraserver-java:2024.+' + implementation 'edu.wpi.first.ntcore:ntcore-java:2024.+' + implementation 'edu.wpi.first.wpilibj:wpilibj-java:2024.+' + implementation 'edu.wpi.first.wpiutil:wpiutil-java:2024.+' + implementation 'edu.wpi.first.wpimath:wpimath-java:2024.+' + implementation 'edu.wpi.first.wpilibNewCommands:wpilibNewCommands-java:2024.+' + implementation 'edu.wpi.first.wpiunits:wpiunits-java:2024.+' + implementation 'edu.wpi.first.hal:hal-java:2024.+' implementation "org.ejml:ejml-simple:0.43.1" - implementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2" - implementation "com.fasterxml.jackson.core:jackson-core:2.15.2" - implementation "com.fasterxml.jackson.core:jackson-databind:2.15.2" - implementation 'edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:4.8.0-4' + 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:4.8.0-2' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.0' diff --git a/pathplannerlib/config.gradle b/pathplannerlib/config.gradle index 148574237..6e54994c8 100644 --- a/pathplannerlib/config.gradle +++ b/pathplannerlib/config.gradle @@ -8,11 +8,11 @@ nativeUtils.withCrossLinuxArm64() nativeUtils { wpi { configureDependencies { - wpiVersion = "2025.+" + wpiVersion = "2024.+" opencvYear = "frc2024" googleTestYear = "frc2024" niLibVersion = "2024.2.1" - opencvVersion = "4.8.0-4" + opencvVersion = "4.8.0-2" googleTestVersion = "1.14.0-1" } } diff --git a/pathplannerlib/src/main/java/com/pathplanner/lib/commands/FollowPathCommand.java b/pathplannerlib/src/main/java/com/pathplanner/lib/commands/FollowPathCommand.java index be70e12c8..29f84d713 100644 --- a/pathplannerlib/src/main/java/com/pathplanner/lib/commands/FollowPathCommand.java +++ b/pathplannerlib/src/main/java/com/pathplanner/lib/commands/FollowPathCommand.java @@ -83,7 +83,7 @@ public FollowPathCommand( throw new IllegalArgumentException( "Events that are triggered during path following cannot require the drive subsystem"); } - addRequirements(eventReqs); + addRequirements(eventReqs.toArray(new Subsystem[0])); this.path = this.originalPath; // Ensure the ideal trajectory is generated @@ -207,8 +207,8 @@ public static Command warmupCommand() { new PathPlannerPath( bezierPoints, new PathConstraints(4.0, 4.0, 4.0, 4.0), - new IdealStartingState(0.0, Rotation2d.kZero), - new GoalEndState(0.0, Rotation2d.kCCW_90deg)); + new IdealStartingState(0.0, new Rotation2d()), + new GoalEndState(0.0, Rotation2d.fromDegrees(90))); return new FollowPathCommand( path, diff --git a/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectory.java b/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectory.java index 9d04bd4f6..4314b28cd 100644 --- a/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectory.java +++ b/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectory.java @@ -201,7 +201,9 @@ private static void generateStates( state.pose = new Pose2d( state.pose.getTranslation(), - path.isReversed() ? (state.heading.plus(Rotation2d.k180deg)) : state.heading); + path.isReversed() + ? (state.heading.plus(Rotation2d.fromDegrees(180))) + : state.heading); } if (i != 0) { @@ -412,7 +414,7 @@ private static void reverseAccelPass( Translation2d forceVec = new Translation2d( - forceAtCarpet, state.moduleStates[m].fieldAngle.plus(Rotation2d.k180deg)); + forceAtCarpet, state.moduleStates[m].fieldAngle.plus(Rotation2d.fromDegrees(180))); // Add the module force vector to the robot force vector linearForceVec = linearForceVec.plus(forceVec); diff --git a/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectoryState.java b/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectoryState.java index 541241186..8a2ac056a 100644 --- a/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectoryState.java +++ b/pathplannerlib/src/main/java/com/pathplanner/lib/trajectory/PathPlannerTrajectoryState.java @@ -16,7 +16,7 @@ public class PathPlannerTrajectoryState implements InterpolatableGetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); initFromJson(json); AddRequirements(m_autoCommand->GetRequirements()); @@ -40,13 +41,14 @@ std::vector> PathPlannerAuto::getPathGroupFromA const std::string filePath = frc::filesystem::GetDeployDirectory() + "/pathplanner/autos/" + autoName + ".auto"; - auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath); + std::error_code error_code; + auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath, error_code); - if (!fileBuffer) { + if (!fileBuffer || error_code) { throw std::runtime_error("Cannot open file: " + filePath); } - wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); bool choreoAuto = json.contains("choreoAuto") && json.at("choreoAuto").get(); diff --git a/pathplannerlib/src/main/native/cpp/pathplanner/lib/config/RobotConfig.cpp b/pathplannerlib/src/main/native/cpp/pathplanner/lib/config/RobotConfig.cpp index b53d47831..38b8bc3b9 100644 --- a/pathplannerlib/src/main/native/cpp/pathplanner/lib/config/RobotConfig.cpp +++ b/pathplannerlib/src/main/native/cpp/pathplanner/lib/config/RobotConfig.cpp @@ -47,14 +47,15 @@ RobotConfig RobotConfig::fromGUISettings() { const std::string filePath = frc::filesystem::GetDeployDirectory() + "/pathplanner/settings.json"; - auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath); + std::error_code error_code; + auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath, error_code); - if (!fileBuffer) { + if (!fileBuffer || error_code) { throw FRC_MakeError(frc::err::Error, "PathPlanner settings file could not be read"); } - wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); bool isHolonomic = json.at("holonomicMode").get(); units::kilogram_t mass { json.at("robotMass").get() }; diff --git a/pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cpp b/pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cpp index 0d7b3708a..2fb5cf5b2 100644 --- a/pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cpp +++ b/pathplannerlib/src/main/native/cpp/pathplanner/lib/path/PathPlannerPath.cpp @@ -130,13 +130,14 @@ std::shared_ptr PathPlannerPath::fromPathFile( const std::string filePath = frc::filesystem::GetDeployDirectory() + "/pathplanner/paths/" + pathName + ".path"; - auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath); + std::error_code error_code; + auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath, error_code); - if (!fileBuffer) { + if (!fileBuffer || error_code) { throw std::runtime_error("Cannot open file: " + filePath); } - wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); std::shared_ptr < PathPlannerPath > path = PathPlannerPath::fromJson(json); PPLibTelemetry::registerHotReloadPath(pathName, path); @@ -155,13 +156,14 @@ std::shared_ptr PathPlannerPath::fromChoreoTrajectory( const std::string filePath = frc::filesystem::GetDeployDirectory() + "/choreo/" + trajectoryName + ".traj"; - auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath); + std::error_code error_code; + auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath, error_code); - if (!fileBuffer) { + if (!fileBuffer || error_code) { throw std::runtime_error("Cannot open file: " + filePath); } - wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); std::vector < PathPlannerTrajectoryState > trajStates; for (wpi::json::const_reference s : json.at("samples")) { diff --git a/pathplannerlib/src/main/native/cpp/pathplanner/lib/pathfinding/LocalADStar.cpp b/pathplannerlib/src/main/native/cpp/pathplanner/lib/pathfinding/LocalADStar.cpp index 257340788..ea3b5370d 100644 --- a/pathplannerlib/src/main/native/cpp/pathplanner/lib/pathfinding/LocalADStar.cpp +++ b/pathplannerlib/src/main/native/cpp/pathplanner/lib/pathfinding/LocalADStar.cpp @@ -26,12 +26,12 @@ LocalADStar::LocalADStar() : fieldLength(16.54), fieldWidth(8.02), nodeSize( const std::string filePath = frc::filesystem::GetDeployDirectory() + "/pathplanner/navgrid.json"; - auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath); + std::error_code error_code; + auto fileBuffer = wpi::MemoryBuffer::GetFile(filePath, error_code); - if (fileBuffer) { + if (fileBuffer && !error_code) { try { - wpi::json json = wpi::json::parse( - fileBuffer.value()->GetCharBuffer()); + wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer()); nodeSize = json.at("nodeSizeMeters").get(); wpi::json::const_reference grid = json.at("grid"); diff --git a/pathplannerlib/vendordeps/WPILibNewCommands.json b/pathplannerlib/vendordeps/WPILibNewCommands.json index 3a89ebc38..14532443b 100644 --- a/pathplannerlib/vendordeps/WPILibNewCommands.json +++ b/pathplannerlib/vendordeps/WPILibNewCommands.json @@ -1,7 +1,7 @@ { "fileName": "WPILibNewCommands.json", "name": "WPILib-New-Commands", - "version": "2025.+", + "version": "2024.+", "uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266", "mavenUrls": [], "jsonUrl": "", @@ -17,7 +17,7 @@ { "groupId": "edu.wpi.first.wpilibNewCommands", "artifactId": "wpilibNewCommands-cpp", - "version": "2025.+", + "version": "2024.+", "libName": "wpilibNewCommands", "headerClassifier": "headers", "sourcesClassifier": "sources",