From 99b6ae61fa468e367c042dec321f61e3a8f96cba Mon Sep 17 00:00:00 2001 From: BuildTools Date: Sat, 11 Feb 2023 15:01:09 -0500 Subject: [PATCH 1/5] Added functions for sending serial information to the arduino --- .../lighting/ArduinoLightingController.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lib/src/main/java/com/fairportrobotics/frc/poe/controllers/lighting/ArduinoLightingController.java diff --git a/lib/src/main/java/com/fairportrobotics/frc/poe/controllers/lighting/ArduinoLightingController.java b/lib/src/main/java/com/fairportrobotics/frc/poe/controllers/lighting/ArduinoLightingController.java new file mode 100644 index 0000000..d42bfcc --- /dev/null +++ b/lib/src/main/java/com/fairportrobotics/frc/poe/controllers/lighting/ArduinoLightingController.java @@ -0,0 +1,62 @@ +package com.fairportrobotics.frc.poe.controllers.lighting; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import edu.wpi.first.wpilibj.SerialPort; + + +public class ArduinoLightingController { + + final SerialPort bus; + final Pattern colorPattern = Pattern.compile("\\d{9}"); + private final String NULL_COLOR = "000000000"; + private final String RAINBOW_VALUE = NULL_COLOR + "254"; + private final String SHIFT_VALUE = NULL_COLOR + "251"; + private final String SHIFT_WRAP_VALUE = NULL_COLOR + "250"; + + public ArduinoLightingController(int baudRate, SerialPort.Port port) { + this.bus = new SerialPort(baudRate, port); + } + + private boolean validateColor(String colorValue) { + Matcher m = colorPattern.matcher(colorValue); + return m.find(); + } + private int executeColor(String colorValue, String command) { + if ( validateColor(colorValue) ) { + return bus.writeString( colorValue + command ); + } + return 0; + } + + public int fillAll(String colorValue) { + return executeColor(colorValue, "255"); + } + + public int fillRainbow() { + return bus.writeString(RAINBOW_VALUE); + } + + public int switchGradient(String colorValue) { + return executeColor(colorValue, "253"); + } + + public int fillShift(String colorValue) { + return executeColor(colorValue, "252"); + } + + public int shift() { + return bus.writeString(SHIFT_VALUE); + } + + public int shiftWrap() { + return bus.writeString(SHIFT_WRAP_VALUE); + } + + public int flash(String colorValue) { + return executeColor(colorValue, "249"); + } + + +} From ac81af87296e01d17a2f02825e0140d5c153a238 Mon Sep 17 00:00:00 2001 From: Tyler Wilcox Date: Tue, 28 Feb 2023 11:02:33 -0500 Subject: [PATCH 2/5] April tag changes --- lib/publish.gradle | 2 +- .../CameraTracking/RobotFieldPosition.java | 44 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/lib/publish.gradle b/lib/publish.gradle index bd49a07..94f7526 100644 --- a/lib/publish.gradle +++ b/lib/publish.gradle @@ -4,7 +4,7 @@ apply plugin: 'maven-publish' ext.licenseFile = files("$rootDir/LICENSE.txt") -def pubVersion = '2023.1.0' +def pubVersion = '2023.1.1-SNAPSHOT' def outputsFolder = file("$buildDir/allOutputs") diff --git a/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java b/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java index 2c62ef5..7ce0ffc 100644 --- a/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java +++ b/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java @@ -9,30 +9,52 @@ import org.photonvision.PhotonPoseEstimator.PoseStrategy; import org.photonvision.EstimatedRobotPose; import edu.wpi.first.apriltag.AprilTagFieldLayout; +import edu.wpi.first.apriltag.AprilTagFields; import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Transform3d; -public class RobotFieldPosition { +public class RobotFieldPosition { AprilTagFieldLayout layout; PhotonPoseEstimator photonPoseEstimator; /* - Example of Transform3d: - - Transform3d robotToCam = new Transform3d(new Translation3d(0.5, 0.0, 0.5), new Rotation3d(0,0,0)); - Cam mounted facing forward, half a meter forward of center, half a meter up from center. - */ + * Example of Transform3d: + * + * Transform3d robotToCam = new Transform3d(new Translation3d(0.5, 0.0, 0.5), + * new Rotation3d(0,0,0)); + * Cam mounted facing forward, half a meter forward of center, half a meter up + * from center. + */ public RobotFieldPosition(String camera, Transform3d robotToCam, String layoutResourceFile) throws IOException { - layout = AprilTagFieldLayout.loadFromResource(layoutResourceFile); - + PhotonCamera cam = new PhotonCamera(camera); photonPoseEstimator = new PhotonPoseEstimator(layout, PoseStrategy.LOWEST_AMBIGUITY, cam, robotToCam); - } + } + + public RobotFieldPosition(String camera, Transform3d robotToCam, String layoutResourceFile, PoseStrategy strategy) throws IOException { + layout = AprilTagFieldLayout.loadFromResource(layoutResourceFile); + + PhotonCamera cam = new PhotonCamera(camera); + photonPoseEstimator = new PhotonPoseEstimator(layout, PoseStrategy.LOWEST_AMBIGUITY, cam, robotToCam); + } + + public RobotFieldPosition(String camera, Transform3d robotToCam, AprilTagFields fields) throws IOException { + layout = AprilTagFieldLayout.loadFromResource(fields.m_resourceFile); + + PhotonCamera cam = new PhotonCamera(camera); + photonPoseEstimator = new PhotonPoseEstimator(layout, PoseStrategy.LOWEST_AMBIGUITY, cam, robotToCam); + } + + public RobotFieldPosition(String camera, Transform3d robotToCam, AprilTagFields fields, PoseStrategy strategy) throws IOException { + layout = AprilTagFieldLayout.loadFromResource(fields.m_resourceFile); + + PhotonCamera cam = new PhotonCamera(camera); + photonPoseEstimator = new PhotonPoseEstimator(layout, PoseStrategy.LOWEST_AMBIGUITY, cam, robotToCam); + } public Optional getEstimatedGlobalPose() { return photonPoseEstimator.update(); } - -} \ No newline at end of file +} \ No newline at end of file From da4f21ffbb5adf65c0bb03c3c664ccff4a9f3fcb Mon Sep 17 00:00:00 2001 From: Tyler Wilcox Date: Thu, 2 Mar 2023 18:06:11 -0500 Subject: [PATCH 3/5] more constructors for field position --- .../CameraTracking/RobotFieldPosition.java | 1 - vendordeps/AdvantageKit.json | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 vendordeps/AdvantageKit.json diff --git a/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java b/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java index 7ce0ffc..5f09614 100644 --- a/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java +++ b/lib/src/main/java/com/fairportrobotics/frc/poe/CameraTracking/RobotFieldPosition.java @@ -10,7 +10,6 @@ import org.photonvision.EstimatedRobotPose; import edu.wpi.first.apriltag.AprilTagFieldLayout; import edu.wpi.first.apriltag.AprilTagFields; -import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Transform3d; public class RobotFieldPosition { diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json new file mode 100644 index 0000000..b5c210c --- /dev/null +++ b/vendordeps/AdvantageKit.json @@ -0,0 +1,41 @@ +{ + "fileName": "AdvantageKit.json", + "name": "AdvantageKit", + "version": "2.2.1", + "uuid": "d820cc26-74e3-11ec-90d6-0242ac120003", + "mavenUrls": [], + "jsonUrl": "https://github.com/Mechanical-Advantage/AdvantageKit/releases/latest/download/AdvantageKit.json", + "javaDependencies": [ + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "wpilib-shim", + "version": "2.2.1" + }, + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "junction-core", + "version": "2.2.1" + }, + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-api", + "version": "2.2.1" + } + ], + "jniDependencies": [ + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-wpilibio", + "version": "2.2.1", + "skipInvalidPlatforms": false, + "isJar": false, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64", + "osxuniversal" + ] + } + ], + "cppDependencies": [] +} \ No newline at end of file From 16196bc980e524c2dd3744ae26e83169a17aa1ac Mon Sep 17 00:00:00 2001 From: Tyler Wilcox Date: Thu, 2 Mar 2023 22:46:26 -0500 Subject: [PATCH 4/5] Some minor vision changes and auto package for main builds --- .github/workflows/gradle-publish.yml | 6 ++++-- lib/publish.gradle | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 8ec3ee3..3feef94 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -10,6 +10,8 @@ name: Gradle Package on: release: types: [created] + push: + branches: ["main"] jobs: build: @@ -22,10 +24,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml settings-path: ${{ github.workspace }} # location for the settings.xml file diff --git a/lib/publish.gradle b/lib/publish.gradle index 94f7526..58b7f22 100644 --- a/lib/publish.gradle +++ b/lib/publish.gradle @@ -4,7 +4,7 @@ apply plugin: 'maven-publish' ext.licenseFile = files("$rootDir/LICENSE.txt") -def pubVersion = '2023.1.1-SNAPSHOT' +def pubVersion = '2023.1.2' def outputsFolder = file("$buildDir/allOutputs") From 42c00e2cdd00af02aac404927c10356f2ff3687f Mon Sep 17 00:00:00 2001 From: Tyler Wilcox Date: Thu, 2 Mar 2023 22:48:21 -0500 Subject: [PATCH 5/5] Remove vendordeps --- vendordeps/AdvantageKit.json | 41 ------------------------------------ 1 file changed, 41 deletions(-) delete mode 100644 vendordeps/AdvantageKit.json diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json deleted file mode 100644 index b5c210c..0000000 --- a/vendordeps/AdvantageKit.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "fileName": "AdvantageKit.json", - "name": "AdvantageKit", - "version": "2.2.1", - "uuid": "d820cc26-74e3-11ec-90d6-0242ac120003", - "mavenUrls": [], - "jsonUrl": "https://github.com/Mechanical-Advantage/AdvantageKit/releases/latest/download/AdvantageKit.json", - "javaDependencies": [ - { - "groupId": "org.littletonrobotics.akit.junction", - "artifactId": "wpilib-shim", - "version": "2.2.1" - }, - { - "groupId": "org.littletonrobotics.akit.junction", - "artifactId": "junction-core", - "version": "2.2.1" - }, - { - "groupId": "org.littletonrobotics.akit.conduit", - "artifactId": "conduit-api", - "version": "2.2.1" - } - ], - "jniDependencies": [ - { - "groupId": "org.littletonrobotics.akit.conduit", - "artifactId": "conduit-wpilibio", - "version": "2.2.1", - "skipInvalidPlatforms": false, - "isJar": false, - "validPlatforms": [ - "linuxathena", - "windowsx86-64", - "linuxx86-64", - "osxuniversal" - ] - } - ], - "cppDependencies": [] -} \ No newline at end of file