Merge pull request #4 from FairportRobotics/tyler
Auto publish when merge to main
This commit is contained in:
commit
6d67207cf2
|
|
@ -10,6 +10,8 @@ name: Gradle Package
|
||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -22,10 +24,10 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '17'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
||||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ apply plugin: 'maven-publish'
|
||||||
|
|
||||||
ext.licenseFile = files("$rootDir/LICENSE.txt")
|
ext.licenseFile = files("$rootDir/LICENSE.txt")
|
||||||
|
|
||||||
def pubVersion = '2023.1.0'
|
def pubVersion = '2023.1.2'
|
||||||
|
|
||||||
def outputsFolder = file("$buildDir/allOutputs")
|
def outputsFolder = file("$buildDir/allOutputs")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import org.photonvision.PhotonPoseEstimator.PoseStrategy;
|
||||||
import org.photonvision.EstimatedRobotPose;
|
import org.photonvision.EstimatedRobotPose;
|
||||||
|
|
||||||
import edu.wpi.first.apriltag.AprilTagFieldLayout;
|
import edu.wpi.first.apriltag.AprilTagFieldLayout;
|
||||||
import edu.wpi.first.math.geometry.Pose2d;
|
import edu.wpi.first.apriltag.AprilTagFields;
|
||||||
import edu.wpi.first.math.geometry.Transform3d;
|
import edu.wpi.first.math.geometry.Transform3d;
|
||||||
|
|
||||||
public class RobotFieldPosition {
|
public class RobotFieldPosition {
|
||||||
|
|
@ -17,22 +17,43 @@ public class RobotFieldPosition {
|
||||||
PhotonPoseEstimator photonPoseEstimator;
|
PhotonPoseEstimator photonPoseEstimator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Example of Transform3d:
|
* Example of Transform3d:
|
||||||
|
*
|
||||||
Transform3d robotToCam = new Transform3d(new Translation3d(0.5, 0.0, 0.5), new Rotation3d(0,0,0));
|
* Transform3d robotToCam = new Transform3d(new Translation3d(0.5, 0.0, 0.5),
|
||||||
Cam mounted facing forward, half a meter forward of center, half a meter up from center.
|
* 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 {
|
public RobotFieldPosition(String camera, Transform3d robotToCam, String layoutResourceFile) throws IOException {
|
||||||
|
|
||||||
layout = AprilTagFieldLayout.loadFromResource(layoutResourceFile);
|
layout = AprilTagFieldLayout.loadFromResource(layoutResourceFile);
|
||||||
|
|
||||||
PhotonCamera cam = new PhotonCamera(camera);
|
PhotonCamera cam = new PhotonCamera(camera);
|
||||||
photonPoseEstimator = new PhotonPoseEstimator(layout, PoseStrategy.LOWEST_AMBIGUITY, cam, robotToCam);
|
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<EstimatedRobotPose> getEstimatedGlobalPose() {
|
public Optional<EstimatedRobotPose> getEstimatedGlobalPose() {
|
||||||
return photonPoseEstimator.update();
|
return photonPoseEstimator.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue