Bump to WPILib 2025 Beta 1 & remove C++ protobuf (#1484)

Remove C++ protobuf support until
https://github.com/wpilibsuite/allwpilib/issues/7250 is addressed.
Developers should upgrade to wpilib vscode 2025 beta 1.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
Cameron (3539)
2024-10-31 02:59:39 -04:00
committed by GitHub
parent 3d18ded3f6
commit 937bafa8e2
67 changed files with 185 additions and 824 deletions

View File

@@ -48,13 +48,13 @@ jobs:
fetch-depth: 0
- name: Fetch tags
run: git fetch --tags --force
- name: Install RoboRIO Toolchain
run: ./gradlew installRoboRioToolchain
- name: Install Java 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Install RoboRIO Toolchain
run: ./gradlew installRoboRioToolchain
# Need to publish to maven local first, so that C++ sim can pick it up
# Still haven't figured out how to make the vendordep file be copied before trying to build examples
- name: Publish photonlib to maven local
@@ -85,7 +85,7 @@ jobs:
- name: Fetch tags
run: git fetch --tags --force
- name: Install Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
@@ -344,7 +344,7 @@ jobs:
- run: |
sudo apt-get update
sudo apt-get install --yes libcholmod3 liblapack3 libsuitesparseconfig5
if: ${{ (matrix.os) == 'ubuntu-latest' }}
if: ${{ (matrix.os) == 'ubuntu-22.04' }}
# and actually run the jar
- run: java -jar ${{ matrix.extraOpts }} *.jar --smoketest
if: ${{ (matrix.os) != 'windows-latest' }}
@@ -439,7 +439,7 @@ jobs:
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.0-beta-6/photonvision_opi5pro.img.xz
cpu: cortex-a8
image_additional_mb: 1024
- os: ubuntu-latest
- os: ubuntu-22.04
artifact-name: LinuxArm64
image_suffix: orangepi5max
image_url: https://github.com/PhotonVision/photon-image-modifier/releases/download/v2025.0.0-beta-6/photonvision_opi5max.img.xz

View File

@@ -57,7 +57,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

View File

@@ -59,7 +59,7 @@ jobs:
- name: Fetch tags
run: git fetch --tags --force
- name: Install Java 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

View File

@@ -21,7 +21,7 @@ on:
jobs:
buildAndDeploy:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout code

View File

@@ -5,9 +5,9 @@ plugins {
id "cpp"
id "com.diffplug.spotless" version "6.24.0"
id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
id 'edu.wpi.first.WpilibTools' version '1.3.0'
id 'com.google.protobuf' version '0.9.4' apply false
id 'com.google.protobuf' version '0.9.3' apply false
id 'edu.wpi.first.GradleJni' version '1.1.0'
}
@@ -30,14 +30,15 @@ ext.allOutputsFolder = file("$project.buildDir/outputs")
apply from: "versioningHelper.gradle"
ext {
wpilibVersion = "2024.3.2"
wpilibVersion = "2025.1.1-beta-1"
wpimathVersion = wpilibVersion
openCVversion = "4.8.0-2"
openCVYear = "2024"
openCVversion = "4.8.0-4"
joglVersion = "2.4.0"
javalinVersion = "5.6.2"
libcameraDriverVersion = "dev-v2023.1.0-14-g787ab59"
rknnVersion = "dev-v2024.0.1-4-g0db16ac"
frcYear = "2024"
frcYear = "2025"
mrcalVersion = "dev-v2024.0.0-24-gc1efcf0";

View File

@@ -17,10 +17,10 @@ const resetTempSettingsStruct = () => {
const settingsValid = ref(true);
const isValidNetworkTablesIP = (v: string | undefined): boolean => {
// Check if it is a valid team number between 1-9999
const teamNumberRegex = /^[1-9][0-9]{0,3}$/;
// Check if it is a valid team number between 1-99999 (5 digits)
const teamNumberRegex = /^[1-9][0-9]{0,4}$/;
// Check if it is a team number longer than 5 digits
const badTeamNumberRegex = /^[0-9]{5,}$/;
const badTeamNumberRegex = /^[0-9]{6,}$/;
if (v === undefined) return false;
if (teamNumberRegex.test(v)) return true;

View File

@@ -24,7 +24,7 @@ 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())
nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + openCVYear, wpi.versions.opencvVersion.get())
dependencies {
// JOGL stuff (currently we only distribute for aarch64, which is Pi 4)

View File

@@ -19,11 +19,17 @@ package org.photonvision.common.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.wpi.first.apriltag.jni.AprilTagJNI;
import edu.wpi.first.cscore.CameraServerCvJNI;
import edu.wpi.first.cscore.CameraServerJNI;
import edu.wpi.first.cscore.OpenCvLoader;
import edu.wpi.first.hal.JNIWrapper;
import edu.wpi.first.math.WPIMathJNI;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.jni.ArmFeedforwardJNI;
import edu.wpi.first.math.jni.DAREJNI;
import edu.wpi.first.math.jni.EigenJNI;
import edu.wpi.first.math.jni.Ellipse2dJNI;
import edu.wpi.first.math.jni.Pose3dJNI;
import edu.wpi.first.math.jni.StateSpaceUtilJNI;
import edu.wpi.first.math.jni.TrajectoryUtilJNI;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.net.WPINetJNI;
import edu.wpi.first.networktables.NetworkTablesJNI;
@@ -46,23 +52,21 @@ public class TestUtils {
NetworkTablesJNI.Helper.setExtractOnStaticLoad(false);
WPIUtilJNI.Helper.setExtractOnStaticLoad(false);
WPIMathJNI.Helper.setExtractOnStaticLoad(false);
CameraServerJNI.Helper.setExtractOnStaticLoad(false);
CameraServerCvJNI.Helper.setExtractOnStaticLoad(false);
// OpenCvLoader.Helper.setExtractOnStaticLoad(false);
OpenCvLoader.Helper.setExtractOnStaticLoad(false);
JNIWrapper.Helper.setExtractOnStaticLoad(false);
WPINetJNI.Helper.setExtractOnStaticLoad(false);
AprilTagJNI.Helper.setExtractOnStaticLoad(false);
// wpimathjni is a bit odd, it's all in the wpimathjni shared lib, but the java side stuff has
// been split.
// ArmFeedforwardJNI.Helper.setExtractOnStaticLoad(false);
// DAREJNI.Helper.setExtractOnStaticLoad(false);
// EigenJNI.Helper.setExtractOnStaticLoad(false);
// Ellipse2dJNI.Helper.setExtractOnStaticLoad(false);
// Pose3dJNI.Helper.setExtractOnStaticLoad(false);
// StateSpaceUtilJNI.Helper.setExtractOnStaticLoad(false);
// TrajectoryUtilJNI.Helper.setExtractOnStaticLoad(false);
ArmFeedforwardJNI.Helper.setExtractOnStaticLoad(false);
DAREJNI.Helper.setExtractOnStaticLoad(false);
EigenJNI.Helper.setExtractOnStaticLoad(false);
Ellipse2dJNI.Helper.setExtractOnStaticLoad(false);
Pose3dJNI.Helper.setExtractOnStaticLoad(false);
StateSpaceUtilJNI.Helper.setExtractOnStaticLoad(false);
TrajectoryUtilJNI.Helper.setExtractOnStaticLoad(false);
try {
CombinedRuntimeLoader.loadLibraries(
@@ -72,10 +76,11 @@ public class TestUtils {
"ntcorejni",
"wpinetjni",
"wpiHaljni",
Core.NATIVE_LIBRARY_NAME,
"cscorejni",
"apriltagjni");
CombinedRuntimeLoader.loadLibraries(TestUtils.class, Core.NATIVE_LIBRARY_NAME);
has_loaded = true;
} catch (IOException e) {
e.printStackTrace();

View File

@@ -338,4 +338,4 @@ 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())
nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + openCVYear, wpi.versions.opencvVersion.get())

View File

@@ -26,7 +26,6 @@ package org.photonvision;
import static org.junit.jupiter.api.Assertions.*;
import edu.wpi.first.cscore.CameraServerCvJNI;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.math.geometry.Rotation2d;
@@ -34,10 +33,12 @@ import edu.wpi.first.math.geometry.Rotation3d;
import edu.wpi.first.math.geometry.Transform3d;
import edu.wpi.first.math.geometry.Translation3d;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.util.CombinedRuntimeLoader;
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opencv.core.Core;
import org.photonvision.estimation.CameraTargetRelation;
import org.photonvision.estimation.OpenCVHelp;
import org.photonvision.estimation.RotTrlTransform3d;
@@ -77,7 +78,7 @@ public class OpenCVTest {
@BeforeAll
public static void setUp() throws IOException {
CameraServerCvJNI.forceLoad();
CombinedRuntimeLoader.loadLibraries(OpenCVTest.class, Core.NATIVE_LIBRARY_NAME);
// NT live for debug purposes
NetworkTableInstance.getDefault().startServer();

View File

@@ -37,11 +37,6 @@ public class MultiTargetPNPResultProto
return ProtobufMultiTargetPNPResult.getDescriptor();
}
@Override
public Protobuf<?, ?>[] getNested() {
return new Protobuf<?, ?>[] {PnpResult.proto};
}
@Override
public ProtobufMultiTargetPNPResult createMessage() {
return ProtobufMultiTargetPNPResult.newInstance();

View File

@@ -34,11 +34,6 @@ public class PNPResultProto implements Protobuf<PnpResult, ProtobufPNPResult> {
return ProtobufPNPResult.getDescriptor();
}
@Override
public Protobuf<?, ?>[] getNested() {
return new Protobuf<?, ?>[] {Transform3d.proto};
}
@Override
public ProtobufPNPResult createMessage() {
return ProtobufPNPResult.newInstance();

View File

@@ -37,11 +37,6 @@ public class PhotonPipelineResultProto
return ProtobufPhotonPipelineResult.getDescriptor();
}
@Override
public Protobuf<?, ?>[] getNested() {
return new Protobuf<?, ?>[] {PhotonTrackedTarget.proto, MultiTargetPNPResult.proto};
}
@Override
public ProtobufPhotonPipelineResult createMessage() {
return ProtobufPhotonPipelineResult.newInstance();

View File

@@ -39,11 +39,6 @@ public class PhotonTrackedTargetProto
return ProtobufPhotonTrackedTarget.getDescriptor();
}
@Override
public Protobuf<?, ?>[] getNested() {
return new Protobuf<?, ?>[] {Transform3d.proto, TargetCorner.proto};
}
@Override
public ProtobufPhotonTrackedTarget createMessage() {
return ProtobufPhotonTrackedTarget.newInstance();

View File

@@ -1,60 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "photon/targeting/proto/MultiTargetPNPResultProto.h"
#include <vector>
#include "photon.pb.h"
#include "photon/targeting/proto/PNPResultProto.h"
google::protobuf::Message* wpi::Protobuf<photon::MultiTargetPNPResult>::New(
google::protobuf::Arena* arena) {
return google::protobuf::Arena::CreateMessage<
photonvision::proto::ProtobufMultiTargetPNPResult>(arena);
}
photon::MultiTargetPNPResult
wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(
const google::protobuf::Message& msg) {
auto m =
static_cast<const photonvision::proto::ProtobufMultiTargetPNPResult*>(
&msg);
std::vector<int16_t> fiducialIdsUsed;
fiducialIdsUsed.reserve(32);
for (int i = 0; i < m->fiducial_ids_used_size(); i++) {
fiducialIdsUsed.push_back(m->fiducial_ids_used(i));
}
return photon::MultiTargetPNPResult{photon::MultiTargetPNPResult_PhotonStruct{
wpi::UnpackProtobuf<photon::PnpResult>(m->estimated_pose()),
fiducialIdsUsed}};
}
void wpi::Protobuf<photon::MultiTargetPNPResult>::Pack(
google::protobuf::Message* msg, const photon::MultiTargetPNPResult& value) {
auto m = static_cast<photonvision::proto::ProtobufMultiTargetPNPResult*>(msg);
wpi::PackProtobuf(m->mutable_estimated_pose(), value.estimatedPose);
m->clear_fiducial_ids_used();
for (const auto& t : value.fiducialIDsUsed) {
m->add_fiducial_ids_used(t);
}
}

View File

@@ -1,48 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "photon/targeting/proto/PNPResultProto.h"
#include "photon.pb.h"
google::protobuf::Message* wpi::Protobuf<photon::PnpResult>::New(
google::protobuf::Arena* arena) {
return google::protobuf::Arena::CreateMessage<
photonvision::proto::ProtobufPNPResult>(arena);
}
photon::PnpResult wpi::Protobuf<photon::PnpResult>::Unpack(
const google::protobuf::Message& msg) {
auto m = static_cast<const photonvision::proto::ProtobufPNPResult*>(&msg);
return photon::PnpResult{photon::PnpResult_PhotonStruct{
wpi::UnpackProtobuf<frc::Transform3d>(m->best()),
wpi::UnpackProtobuf<frc::Transform3d>(m->alt()), m->best_reproj_err(),
m->alt_reproj_err(), m->ambiguity()}};
}
void wpi::Protobuf<photon::PnpResult>::Pack(google::protobuf::Message* msg,
const photon::PnpResult& value) {
auto m = static_cast<photonvision::proto::ProtobufPNPResult*>(msg);
// m->set_is_present(value.isPresent);
wpi::PackProtobuf(m->mutable_best(), value.best);
m->set_best_reproj_err(value.bestReprojErr);
wpi::PackProtobuf(m->mutable_alt(), value.alt);
m->set_alt_reproj_err(value.altReprojErr);
m->set_ambiguity(value.ambiguity);
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "photon/targeting/proto/PhotonPipelineResultProto.h"
#include <vector>
#include "photon.pb.h"
#include "photon/targeting/proto/MultiTargetPNPResultProto.h"
#include "photon/targeting/proto/PhotonTrackedTargetProto.h"
google::protobuf::Message* wpi::Protobuf<photon::PhotonPipelineResult>::New(
google::protobuf::Arena* arena) {
return google::protobuf::Arena::CreateMessage<
photonvision::proto::ProtobufPhotonPipelineResult>(arena);
}
photon::PhotonPipelineResult
wpi::Protobuf<photon::PhotonPipelineResult>::Unpack(
const google::protobuf::Message& msg) {
auto m =
static_cast<const photonvision::proto::ProtobufPhotonPipelineResult*>(
&msg);
std::vector<photon::PhotonTrackedTarget> targets;
targets.reserve(m->targets_size());
for (const auto& t : m->targets()) {
targets.emplace_back(wpi::UnpackProtobuf<photon::PhotonTrackedTarget>(t));
}
return photon::PhotonPipelineResult{photon::PhotonPipelineResult_PhotonStruct{
photon::PhotonPipelineMetadata{
photon::PhotonPipelineMetadata_PhotonStruct{
m->sequence_id(),
m->capture_timestamp_micros(),
m->nt_publish_timestamp_micros(),
}},
targets,
// TODO need to pull this into an optional
m->has_multi_target_result()
? std::optional<photon::MultiTargetPNPResult>{wpi::UnpackProtobuf<
photon::MultiTargetPNPResult>(m->multi_target_result())}
: std::nullopt,
}};
}
void wpi::Protobuf<photon::PhotonPipelineResult>::Pack(
google::protobuf::Message* msg, const photon::PhotonPipelineResult& value) {
auto m = static_cast<photonvision::proto::ProtobufPhotonPipelineResult*>(msg);
m->set_sequence_id(value.metadata.sequenceID);
m->set_capture_timestamp_micros(value.metadata.captureTimestampMicros);
m->set_nt_publish_timestamp_micros(value.metadata.publishTimestampMicros);
m->clear_targets();
for (const auto& t : value.GetTargets()) {
wpi::PackProtobuf(m->add_targets(), t);
}
// TODO this is dumb and bad
if (value.multitagResult) {
wpi::PackProtobuf(m->mutable_multi_target_result(), *value.multitagResult);
} else {
m->clear_multi_target_result();
}
}

View File

@@ -1,90 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "photon/targeting/proto/PhotonTrackedTargetProto.h"
#include <utility>
#include <vector>
#include "photon.pb.h"
using photon::TargetCorner;
using photon::TargetCorner_PhotonStruct;
google::protobuf::Message* wpi::Protobuf<photon::PhotonTrackedTarget>::New(
google::protobuf::Arena* arena) {
return google::protobuf::Arena::CreateMessage<
photonvision::proto::ProtobufPhotonTrackedTarget>(arena);
}
photon::PhotonTrackedTarget wpi::Protobuf<photon::PhotonTrackedTarget>::Unpack(
const google::protobuf::Message& msg) {
auto m = static_cast<const photonvision::proto::ProtobufPhotonTrackedTarget*>(
&msg);
std::vector<photon::TargetCorner> minAreaRectCorners;
minAreaRectCorners.reserve(4);
for (const auto& t : m->min_area_rect_corners()) {
minAreaRectCorners.emplace_back(
TargetCorner{TargetCorner_PhotonStruct{t.x(), t.y()}});
}
std::vector<photon::TargetCorner> detectedCorners;
detectedCorners.reserve(m->detected_corners_size());
for (const auto& t : m->detected_corners()) {
minAreaRectCorners.emplace_back(
TargetCorner{TargetCorner_PhotonStruct{t.x(), t.y()}});
}
return photon::PhotonTrackedTarget{photon::PhotonTrackedTarget_PhotonStruct{
m->yaw(), m->pitch(), m->area(), m->skew(), m->fiducial_id(),
m->obj_detection_id(), m->obj_detection_conf(),
wpi::UnpackProtobuf<frc::Transform3d>(m->best_camera_to_target()),
wpi::UnpackProtobuf<frc::Transform3d>(m->alt_camera_to_target()),
m->pose_ambiguity(), minAreaRectCorners, detectedCorners}};
}
void wpi::Protobuf<photon::PhotonTrackedTarget>::Pack(
google::protobuf::Message* msg, const photon::PhotonTrackedTarget& value) {
auto m = static_cast<photonvision::proto::ProtobufPhotonTrackedTarget*>(msg);
m->set_yaw(value.yaw);
m->set_pitch(value.pitch);
m->set_area(value.area);
m->set_skew(value.skew);
m->set_fiducial_id(value.fiducialId);
m->set_obj_detection_id(value.objDetectId);
m->set_obj_detection_conf(value.objDetectConf);
wpi::PackProtobuf(m->mutable_best_camera_to_target(),
value.bestCameraToTarget);
wpi::PackProtobuf(m->mutable_alt_camera_to_target(), value.altCameraToTarget);
m->set_pose_ambiguity(value.poseAmbiguity);
m->clear_min_area_rect_corners();
for (const auto& t : value.GetMinAreaRectCorners()) {
auto* corner = m->add_min_area_rect_corners();
corner->set_x(t.x);
corner->set_y(t.y);
}
m->clear_detected_corners();
for (const auto& t : value.GetDetectedCorners()) {
auto* corner = m->add_detected_corners();
corner->set_x(t.x);
corner->set_y(t.y);
}
}

View File

@@ -1,31 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <wpi/protobuf/Protobuf.h>
#include "photon/targeting/MultiTargetPNPResult.h"
template <>
struct wpi::Protobuf<photon::MultiTargetPNPResult> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static photon::MultiTargetPNPResult Unpack(
const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const photon::MultiTargetPNPResult& value);
};

View File

@@ -1,30 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <wpi/protobuf/Protobuf.h>
#include "photon/targeting/PnpResult.h"
template <>
struct wpi::Protobuf<photon::PnpResult> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static photon::PnpResult Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const photon::PnpResult& value);
};

View File

@@ -1,31 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <wpi/protobuf/Protobuf.h>
#include "photon/targeting/PhotonPipelineResult.h"
template <>
struct wpi::Protobuf<photon::PhotonPipelineResult> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static photon::PhotonPipelineResult Unpack(
const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const photon::PhotonPipelineResult& value);
};

View File

@@ -1,31 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <wpi/protobuf/Protobuf.h>
#include "photon/targeting/PhotonTrackedTarget.h"
template <>
struct wpi::Protobuf<photon::PhotonTrackedTarget> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static photon::PhotonTrackedTarget Unpack(
const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const photon::PhotonTrackedTarget& value);
};

View File

@@ -1,55 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gtest/gtest.h"
#include "photon.pb.h"
#include "photon/targeting/MultiTargetPNPResult.h"
#include "photon/targeting/proto/MultiTargetPNPResultProto.h"
// TEST(MultiTargetPNPResultTest, Roundtrip) {
// photon::MultiTargetPNPResult result;
// google::protobuf::Arena arena;
// google::protobuf::Message* proto =
// wpi::Protobuf<photon::MultiTargetPNPResult>::New(&arena);
// wpi::Protobuf<photon::MultiTargetPNPResult>::Pack(proto, result);
// photon::MultiTargetPNPResult unpacked_data =
// wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(*proto);
// EXPECT_EQ(result, unpacked_data);
// photon::PnpResult pnpRes{
// true,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// 0};
// photon::MultiTargetPNPResult result1{pnpRes, {1, 2, 3, 4}};
// proto = wpi::Protobuf<photon::MultiTargetPNPResult>::New(&arena);
// wpi::Protobuf<photon::MultiTargetPNPResult>::Pack(proto, result1);
// photon::MultiTargetPNPResult unpacked_data1 =
// wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(*proto);
// EXPECT_EQ(result1, unpacked_data1);
// }

View File

@@ -1,53 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gtest/gtest.h"
#include "photon.pb.h"
#include "photon/targeting/PnpResult.h"
#include "photon/targeting/proto/PNPResultProto.h"
// TEST(PnpResultTest, Roundtrip) {
// photon::PnpResult result;
// google::protobuf::Arena arena;
// google::protobuf::Message* proto =
// wpi::Protobuf<photon::PnpResult>::New(&arena);
// wpi::Protobuf<photon::PnpResult>::Pack(proto, result);
// photon::PnpResult unpacked_data =
// wpi::Protobuf<photon::PnpResult>::Unpack(*proto);
// EXPECT_EQ(result, unpacked_data);
// photon::PnpResult result1{
// true,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// 0};
// proto = wpi::Protobuf<photon::PnpResult>::New(&arena);
// wpi::Protobuf<photon::PnpResult>::Pack(proto, result1);
// photon::PnpResult unpacked_data2 =
// wpi::Protobuf<photon::PnpResult>::Unpack(*proto);
// EXPECT_EQ(result1, unpacked_data2);
// }

View File

@@ -1,101 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gtest/gtest.h"
#include "photon.pb.h"
#include "photon/targeting/PhotonPipelineResult.h"
#include "photon/targeting/proto/PhotonPipelineResultProto.h"
// TEST(PhotonPipelineResultTest, Roundtrip) {
// photon::PhotonPipelineResult result{0, 0_s, 12_ms, {}};
// google::protobuf::Arena arena;
// google::protobuf::Message* proto =
// wpi::Protobuf<photon::PhotonPipelineResult>::New(&arena);
// wpi::Protobuf<photon::PhotonPipelineResult>::Pack(proto, result);
// photon::PhotonPipelineResult unpacked_data =
// wpi::Protobuf<photon::PhotonPipelineResult>::Unpack(*proto);
// EXPECT_EQ(result, unpacked_data);
// wpi::SmallVector<photon::PhotonTrackedTarget, 2> targets{
// photon::PhotonTrackedTarget{
// 3.0,
// -4.0,
// 9.0,
// 4.0,
// 1,
// -1,
// -1.0,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// -1,
// {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6}, std::pair{7,
// 8}}, {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6},
// std::pair{7, 8}}},
// photon::PhotonTrackedTarget{
// 3.0,
// -4.0,
// 9.1,
// 6.7,
// -1,
// -1,
// -1.0,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// -1,
// {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6}, std::pair{7,
// 8}}, {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6},
// std::pair{7, 8}}}};
// photon::PhotonPipelineResult result2{0, 0_s, 12_ms, targets};
// proto = wpi::Protobuf<photon::PhotonPipelineResult>::New(&arena);
// wpi::Protobuf<photon::PhotonPipelineResult>::Pack(proto, result2);
// photon::PhotonPipelineResult unpacked_data2 =
// wpi::Protobuf<photon::PhotonPipelineResult>::Unpack(*proto);
// EXPECT_EQ(result2, unpacked_data2);
// photon::PnpResult pnpRes{
// true,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// 0.1,
// 0};
// photon::MultiTargetPNPResult multitagRes{pnpRes, {1, 2, 3, 4}};
// photon::PhotonPipelineResult result3{0, 0_s, 12_ms, targets, multitagRes};
// proto = wpi::Protobuf<photon::PhotonPipelineResult>::New(&arena);
// wpi::Protobuf<photon::PhotonPipelineResult>::Pack(proto, result3);
// photon::PhotonPipelineResult unpacked_data3 =
// wpi::Protobuf<photon::PhotonPipelineResult>::Unpack(*proto);
// EXPECT_EQ(result3, unpacked_data3);
// }

View File

@@ -1,49 +0,0 @@
/*
* Copyright (C) Photon Vision.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "gtest/gtest.h"
#include "photon.pb.h"
#include "photon/targeting/PhotonTrackedTarget.h"
#include "photon/targeting/proto/PhotonTrackedTargetProto.h"
// TEST(PhotonTrackedTargetTest, Roundtrip) {
// photon::PhotonTrackedTarget target{
// 3.0,
// 4.0,
// 9.0,
// -5.0,
// -1,
// -1,
// -1.0,
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
// frc::Rotation3d(1_rad, 2_rad, 3_rad)),
// -1,
// {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6}, std::pair{7, 8}},
// {std::pair{1, 2}, std::pair{3, 4}, std::pair{5, 6}, std::pair{7, 8}}};
// google::protobuf::Arena arena;
// google::protobuf::Message* proto =
// wpi::Protobuf<photon::PhotonTrackedTarget>::New(&arena);
// wpi::Protobuf<photon::PhotonTrackedTarget>::Pack(proto, target);
// photon::PhotonTrackedTarget unpacked_data =
// wpi::Protobuf<photon::PhotonTrackedTarget>::Unpack(*proto);
// EXPECT_EQ(target, unpacked_data);
// }

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": true,
"currentLanguage": "cpp",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 5
}

View File

@@ -1,9 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.dorongold.task-tree" version "2.1.0"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
repositories {
@@ -11,9 +9,10 @@ repositories {
jcenter()
}
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
apply from: "${rootDir}/../shared/examples_common.gradle"

View File

@@ -1,13 +1,13 @@
import org.gradle.internal.os.OperatingSystem
rootProject.name = 'aimattarget'
rootProject.name = 'aimandrange'
pluginManagement {
repositories {
mavenLocal()
jcenter()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -44,20 +44,22 @@ SwerveDriveSim::SwerveDriveSim(
: SwerveDriveSim(
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-driveFF.kV.to<double>() / driveFF.kA.to<double>())
-driveFF.GetKv().to<double>() / driveFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / driveFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / driveFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
driveFF.kS, driveMotor, driveGearing, driveWheelRadius,
driveFF.GetKs(), driveMotor, driveGearing, driveWheelRadius,
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-steerFF.kV.to<double>() / steerFF.kA.to<double>())
-steerFF.GetKv().to<double>() / steerFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / steerFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / steerFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
steerFF.kS, steerMotor, steerGearing, kinematics) {}
steerFF.GetKs(), steerMotor, steerGearing, kinematics) {}
SwerveDriveSim::SwerveDriveSim(
const frc::LinearSystem<2, 1, 2>& drivePlant, units::volt_t driveKs,

View File

@@ -64,12 +64,11 @@ void SwerveModule::Periodic() {
driveMotor.SetVoltage(driveFF + drivePID);
}
void SwerveModule::SetDesiredState(const frc::SwerveModuleState& newState,
void SwerveModule::SetDesiredState(frc::SwerveModuleState newState,
bool shouldBeOpenLoop, bool steerInPlace) {
frc::Rotation2d currentRotation = GetAbsoluteHeading();
frc::SwerveModuleState optimizedState =
frc::SwerveModuleState::Optimize(newState, currentRotation);
desiredState = optimizedState;
newState.Optimize(currentRotation);
desiredState = newState;
}
frc::Rotation2d SwerveModule::GetAbsoluteHeading() const {

View File

@@ -31,7 +31,11 @@
#include <frc/controller/SimpleMotorFeedforward.h>
#include <frc/geometry/Transform3d.h>
#include <frc/geometry/Translation2d.h>
#include <units/acceleration.h>
#include <units/angular_acceleration.h>
#include <units/angular_velocity.h>
#include <units/length.h>
#include <units/velocity.h>
namespace constants {
namespace Vision {
@@ -40,12 +44,13 @@ inline const frc::Transform3d kRobotToCam{
frc::Translation3d{0.5_m, 0.0_m, 0.5_m},
frc::Rotation3d{0_rad, -30_deg, 0_rad}};
inline const frc::AprilTagFieldLayout kTagLayout{
frc::LoadAprilTagLayoutField(frc::AprilTagField::k2024Crescendo)};
frc::AprilTagFieldLayout::LoadField(frc::AprilTagField::k2024Crescendo)};
inline const Eigen::Matrix<double, 3, 1> kSingleTagStdDevs{4, 4, 8};
inline const Eigen::Matrix<double, 3, 1> kMultiTagStdDevs{0.5, 0.5, 1};
} // namespace Vision
namespace Swerve {
using namespace units;
inline constexpr units::meter_t kTrackWidth{18.5_in};
inline constexpr units::meter_t kTrackLength{18.5_in};
@@ -73,6 +78,8 @@ inline constexpr double kSteerKP = 20.0;
inline constexpr double kSteerKI = 0.0;
inline constexpr double kSteerKD = 0.25;
using namespace units;
inline const frc::SimpleMotorFeedforward<units::meters> kDriveFF{
0.25_V, 2.5_V / 1_mps, 0.3_V / 1_mps_sq};

View File

@@ -38,8 +38,8 @@ class SwerveModule {
public:
explicit SwerveModule(const constants::Swerve::ModuleConstants& consts);
void Periodic();
void SetDesiredState(const frc::SwerveModuleState& newState,
bool shouldBeOpenLoop, bool steerInPlace);
void SetDesiredState(frc::SwerveModuleState newState, bool shouldBeOpenLoop,
bool steerInPlace);
frc::Rotation2d GetAbsoluteHeading() const;
frc::SwerveModuleState GetState() const;
frc::SwerveModulePosition GetPosition() const;

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": true,
"currentLanguage": "cpp",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 5
}

View File

@@ -1,9 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.dorongold.task-tree" version "2.1.0"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
repositories {
@@ -11,9 +9,10 @@ repositories {
jcenter()
}
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
apply from: "${rootDir}/../shared/examples_common.gradle"

View File

@@ -7,7 +7,7 @@ pluginManagement {
mavenLocal()
jcenter()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -44,20 +44,22 @@ SwerveDriveSim::SwerveDriveSim(
: SwerveDriveSim(
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-driveFF.kV.to<double>() / driveFF.kA.to<double>())
-driveFF.GetKv().to<double>() / driveFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / driveFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / driveFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
driveFF.kS, driveMotor, driveGearing, driveWheelRadius,
driveFF.GetKs(), driveMotor, driveGearing, driveWheelRadius,
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-steerFF.kV.to<double>() / steerFF.kA.to<double>())
-steerFF.GetKv().to<double>() / steerFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / steerFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / steerFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
steerFF.kS, steerMotor, steerGearing, kinematics) {}
steerFF.GetKs(), steerMotor, steerGearing, kinematics) {}
SwerveDriveSim::SwerveDriveSim(
const frc::LinearSystem<2, 1, 2>& drivePlant, units::volt_t driveKs,

View File

@@ -64,12 +64,11 @@ void SwerveModule::Periodic() {
driveMotor.SetVoltage(driveFF + drivePID);
}
void SwerveModule::SetDesiredState(const frc::SwerveModuleState& newState,
void SwerveModule::SetDesiredState(frc::SwerveModuleState newState,
bool shouldBeOpenLoop, bool steerInPlace) {
frc::Rotation2d currentRotation = GetAbsoluteHeading();
frc::SwerveModuleState optimizedState =
frc::SwerveModuleState::Optimize(newState, currentRotation);
desiredState = optimizedState;
newState.Optimize(currentRotation);
desiredState = newState;
}
frc::Rotation2d SwerveModule::GetAbsoluteHeading() const {

View File

@@ -31,7 +31,11 @@
#include <frc/controller/SimpleMotorFeedforward.h>
#include <frc/geometry/Transform3d.h>
#include <frc/geometry/Translation2d.h>
#include <units/acceleration.h>
#include <units/angular_acceleration.h>
#include <units/angular_velocity.h>
#include <units/length.h>
#include <units/velocity.h>
namespace constants {
namespace Vision {
@@ -40,12 +44,13 @@ inline const frc::Transform3d kRobotToCam{
frc::Translation3d{0.5_m, 0.0_m, 0.5_m},
frc::Rotation3d{0_rad, -30_deg, 0_rad}};
inline const frc::AprilTagFieldLayout kTagLayout{
frc::LoadAprilTagLayoutField(frc::AprilTagField::k2024Crescendo)};
frc::AprilTagFieldLayout::LoadField(frc::AprilTagField::k2024Crescendo)};
inline const Eigen::Matrix<double, 3, 1> kSingleTagStdDevs{4, 4, 8};
inline const Eigen::Matrix<double, 3, 1> kMultiTagStdDevs{0.5, 0.5, 1};
} // namespace Vision
namespace Swerve {
using namespace units;
inline constexpr units::meter_t kTrackWidth{18.5_in};
inline constexpr units::meter_t kTrackLength{18.5_in};
@@ -73,6 +78,8 @@ inline constexpr double kSteerKP = 20.0;
inline constexpr double kSteerKI = 0.0;
inline constexpr double kSteerKD = 0.25;
using namespace units;
inline const frc::SimpleMotorFeedforward<units::meters> kDriveFF{
0.25_V, 2.5_V / 1_mps, 0.3_V / 1_mps_sq};

View File

@@ -38,8 +38,8 @@ class SwerveModule {
public:
explicit SwerveModule(const constants::Swerve::ModuleConstants& consts);
void Periodic();
void SetDesiredState(const frc::SwerveModuleState& newState,
bool shouldBeOpenLoop, bool steerInPlace);
void SetDesiredState(frc::SwerveModuleState newState, bool shouldBeOpenLoop,
bool steerInPlace);
frc::Rotation2d GetAbsoluteHeading() const;
frc::SwerveModuleState GetState() const;
frc::SwerveModulePosition GetPosition() const;

View File

@@ -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

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": true,
"currentLanguage": "cpp",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 5
}

View File

@@ -1,9 +1,7 @@
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.dorongold.task-tree" version "2.1.0"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
repositories {
@@ -11,9 +9,10 @@ repositories {
jcenter()
}
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.maven.useLocal = false
wpi.maven.useDevelopment = false
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
apply from: "${rootDir}/../shared/examples_common.gradle"

View File

@@ -1,13 +1,13 @@
import org.gradle.internal.os.OperatingSystem
rootProject.name = 'aimattarget'
rootProject.name = 'poseest'
pluginManagement {
repositories {
mavenLocal()
jcenter()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -44,20 +44,22 @@ SwerveDriveSim::SwerveDriveSim(
: SwerveDriveSim(
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-driveFF.kV.to<double>() / driveFF.kA.to<double>())
-driveFF.GetKv().to<double>() / driveFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / driveFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / driveFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
driveFF.kS, driveMotor, driveGearing, driveWheelRadius,
driveFF.GetKs(), driveMotor, driveGearing, driveWheelRadius,
frc::LinearSystem<2, 1, 2>{
(Eigen::MatrixXd(2, 2) << 0.0, 1.0, 0.0,
-steerFF.kV.to<double>() / steerFF.kA.to<double>())
-steerFF.GetKv().to<double>() / steerFF.GetKa().to<double>())
.finished(),
Eigen::Matrix<double, 2, 1>{0.0, 1.0 / steerFF.kA.to<double>()},
Eigen::Matrix<double, 2, 1>{0.0,
1.0 / steerFF.GetKa().to<double>()},
(Eigen::MatrixXd(2, 2) << 1.0, 0.0, 0.0, 1.0).finished(),
Eigen::Matrix<double, 2, 1>{0.0, 0.0}},
steerFF.kS, steerMotor, steerGearing, kinematics) {}
steerFF.GetKs(), steerMotor, steerGearing, kinematics) {}
SwerveDriveSim::SwerveDriveSim(
const frc::LinearSystem<2, 1, 2>& drivePlant, units::volt_t driveKs,

View File

@@ -64,12 +64,11 @@ void SwerveModule::Periodic() {
driveMotor.SetVoltage(driveFF + drivePID);
}
void SwerveModule::SetDesiredState(const frc::SwerveModuleState& newState,
void SwerveModule::SetDesiredState(frc::SwerveModuleState newState,
bool shouldBeOpenLoop, bool steerInPlace) {
frc::Rotation2d currentRotation = GetAbsoluteHeading();
frc::SwerveModuleState optimizedState =
frc::SwerveModuleState::Optimize(newState, currentRotation);
desiredState = optimizedState;
newState.Optimize(currentRotation);
desiredState = newState;
}
frc::Rotation2d SwerveModule::GetAbsoluteHeading() const {

View File

@@ -31,21 +31,26 @@
#include <frc/controller/SimpleMotorFeedforward.h>
#include <frc/geometry/Transform3d.h>
#include <frc/geometry/Translation2d.h>
#include <units/acceleration.h>
#include <units/angular_acceleration.h>
#include <units/angular_velocity.h>
#include <units/length.h>
#include <units/velocity.h>
namespace constants {
namespace Vision {
inline constexpr std::string_view kCameraName{"YOUR CAMERA NAME"};
inline const frc::Transform3d kRobotToCam{
frc::Translation3d{0.5_m, 0.0_m, 0.5_m},
frc::Rotation3d{0_rad, 0_rad, 0_rad}};
frc::Rotation3d{0_rad, -30_deg, 0_rad}};
inline const frc::AprilTagFieldLayout kTagLayout{
frc::LoadAprilTagLayoutField(frc::AprilTagField::k2024Crescendo)};
frc::AprilTagFieldLayout::LoadField(frc::AprilTagField::k2024Crescendo)};
inline const Eigen::Matrix<double, 3, 1> kSingleTagStdDevs{4, 4, 8};
inline const Eigen::Matrix<double, 3, 1> kMultiTagStdDevs{0.5, 0.5, 1};
} // namespace Vision
namespace Swerve {
using namespace units;
inline constexpr units::meter_t kTrackWidth{18.5_in};
inline constexpr units::meter_t kTrackLength{18.5_in};
@@ -73,6 +78,8 @@ inline constexpr double kSteerKP = 20.0;
inline constexpr double kSteerKI = 0.0;
inline constexpr double kSteerKD = 0.25;
using namespace units;
inline const frc::SimpleMotorFeedforward<units::meters> kDriveFF{
0.25_V, 2.5_V / 1_mps, 0.3_V / 1_mps_sq};

View File

@@ -58,7 +58,7 @@ class GamepieceLauncher {
frc::LinearSystem<1, 1, 1> m_plant{frc::LinearSystemId::FlywheelSystem(
m_gearbox, kFlywheelMomentOfInertia, 1.0)};
frc::sim::FlywheelSim launcherSim{m_plant, m_gearbox, 1.0};
frc::sim::FlywheelSim launcherSim{m_plant, m_gearbox};
void simulationInit(); // Method to initialize simulation components
};

View File

@@ -38,8 +38,8 @@ class SwerveModule {
public:
explicit SwerveModule(const constants::Swerve::ModuleConstants& consts);
void Periodic();
void SetDesiredState(const frc::SwerveModuleState& newState,
bool shouldBeOpenLoop, bool steerInPlace);
void SetDesiredState(frc::SwerveModuleState newState, bool shouldBeOpenLoop,
bool steerInPlace);
frc::Rotation2d GetAbsoluteHeading() const;
frc::SwerveModuleState GetState() const;
frc::SwerveModulePosition GetPosition() const;

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 4512
}

View File

@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
sourceCompatibility = JavaVersion.VERSION_11
@@ -15,8 +15,8 @@ repositories {
}
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
// Define my targets (RoboRIO) and artifacts (deployable files)

View File

@@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -115,20 +115,20 @@ public class SwerveDriveSim {
SwerveDriveKinematics kinematics) {
this(
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.kv / driveFF.ka),
VecBuilder.fill(0.0, 1.0 / driveFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.getKv() / driveFF.getKa()),
VecBuilder.fill(0.0, 1.0 / driveFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
driveFF.ks,
driveFF.getKs(),
driveMotor,
driveGearing,
driveWheelRadius,
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.kv / steerFF.ka),
VecBuilder.fill(0.0, 1.0 / steerFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.getKv() / steerFF.getKa()),
VecBuilder.fill(0.0, 1.0 / steerFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
steerFF.ks,
steerFF.getKs(),
steerMotor,
steerGearing,
kinematics);

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 4512
}

View File

@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
sourceCompatibility = JavaVersion.VERSION_11
@@ -11,8 +11,8 @@ apply from: "${rootDir}/../shared/examples_common.gradle"
def ROBOT_MAIN_CLASS = "frc.robot.Main"
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
// Define my targets (RoboRIO) and artifacts (deployable files)

View File

@@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -115,20 +115,20 @@ public class SwerveDriveSim {
SwerveDriveKinematics kinematics) {
this(
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.kv / driveFF.ka),
VecBuilder.fill(0.0, 1.0 / driveFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.getKv() / driveFF.getKa()),
VecBuilder.fill(0.0, 1.0 / driveFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
driveFF.ks,
driveFF.getKs(),
driveMotor,
driveGearing,
driveWheelRadius,
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.kv / steerFF.ka),
VecBuilder.fill(0.0, 1.0 / steerFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.getKv() / steerFF.getKa()),
VecBuilder.fill(0.0, 1.0 / steerFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
steerFF.ks,
steerFF.getKs(),
steerMotor,
steerGearing,
kinematics);

View File

@@ -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

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"projectYear": "2025",
"teamNumber": 4512
}

View File

@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
sourceCompatibility = JavaVersion.VERSION_11
@@ -11,8 +11,8 @@ apply from: "${rootDir}/../shared/examples_common.gradle"
def ROBOT_MAIN_CLASS = "frc.robot.Main"
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = "2024.3.2"
wpi.versions.wpimathVersion = "2024.3.2"
wpi.versions.wpilibVersion = "2025.1.1-beta-1"
wpi.versions.wpimathVersion = "2025.1.1-beta-1"
// Define my targets (RoboRIO) and artifacts (deployable files)

View File

@@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')

View File

@@ -26,6 +26,7 @@ package frc.robot.subsystems;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.math.system.plant.LinearSystemId;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax;
@@ -61,10 +62,15 @@ public class GamepieceLauncher {
// -- SIMULATION SUPPORT
private DCMotor motorSim;
private FlywheelSim launcherSim;
private final double flywheelMoiKgM2 = 0.002;
private final double flywheelGearRatio = 1.0;
private void simulationInit() {
motorSim = DCMotor.getFalcon500(1);
launcherSim = new FlywheelSim(motorSim, 1.0, 0.002);
launcherSim =
new FlywheelSim(
LinearSystemId.createFlywheelSystem(motorSim, flywheelMoiKgM2, flywheelGearRatio),
motorSim);
}
public void simulationPeriodic() {

View File

@@ -115,20 +115,20 @@ public class SwerveDriveSim {
SwerveDriveKinematics kinematics) {
this(
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.kv / driveFF.ka),
VecBuilder.fill(0.0, 1.0 / driveFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -driveFF.getKv() / driveFF.getKa()),
VecBuilder.fill(0.0, 1.0 / driveFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
driveFF.ks,
driveFF.getKs(),
driveMotor,
driveGearing,
driveWheelRadius,
new LinearSystem<N2, N1, N2>(
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.kv / steerFF.ka),
VecBuilder.fill(0.0, 1.0 / steerFF.ka),
MatBuilder.fill(Nat.N2(), Nat.N2(), 0.0, 1.0, 0.0, -steerFF.getKv() / steerFF.getKa()),
VecBuilder.fill(0.0, 1.0 / steerFF.getKa()),
MatBuilder.fill(Nat.N2(), Nat.N2(), 1.0, 0.0, 0.0, 1.0),
VecBuilder.fill(0.0, 0.0)),
steerFF.ks,
steerFF.getKs(),
steerMotor,
steerGearing,
kinematics);

View File

@@ -33,7 +33,7 @@ dependencies {
implementation wpilibTools.deps.wpilibJava("wpilibj")
implementation wpilibTools.deps.wpilibJava("apriltag")
implementation wpilibTools.deps.wpilibJava("wpiunits")
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + openCVYear, wpi.versions.opencvVersion.get())
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()

View File

@@ -8,7 +8,7 @@ nativeUtils.withCrossLinuxArm64()
nativeUtils.wpi.configureDependencies {
wpiVersion = wpilibVersion
wpimathVersion = wpimathVersion
opencvYear = 'frc2024'
opencvYear = 'frc'+openCVYear
opencvVersion = openCVversion
googleTestYear = "frc2024"
googleTestVersion = "1.14.0-1"

View File

@@ -124,7 +124,7 @@ dependencies {
implementation wpilibTools.deps.wpilibJava("wpilibj")
implementation wpilibTools.deps.wpilibJava("apriltag")
implementation wpilibTools.deps.wpilibJava("wpiunits")
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + wpi.frcYear.get(), wpi.versions.opencvVersion.get())
implementation wpilibTools.deps.wpilibOpenCvJava("frc" + openCVYear, wpi.versions.opencvVersion.get())
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()
@@ -149,6 +149,7 @@ jacocoTestReport {
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.12'
@@ -161,7 +162,8 @@ protobuf {
generateProtoTasks {
all().configureEach { task ->
task.builtins {
cpp {}
// cpp {}
// The protobuf-java code is bad -- use quickbuf
remove java
}
task.plugins {

View File

@@ -22,7 +22,7 @@ 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())
nativeConfig.dependencies.add wpilibTools.deps.wpilibOpenCv("frc" + openCVYear, wpi.versions.opencvVersion.get())
// Windows specific functionality to export all symbols from a binary automatically
nativeUtils {