Skip to content

Commit

Permalink
Move vision to its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
aidnem committed Nov 8, 2024
1 parent 45bb90f commit 1260d09
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,5 @@ build

# Ignore auto-generated WPILib stuff.
wpi_interface/src/main/java/frc/robot/BuildConstants.java

**/BuildConstants.java
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ plugins {
}

rootProject.name = 'coppercore'
include('geometry', 'wpi_interface', 'math', 'controls', "parameter_tools")
include('geometry', 'wpi_interface', 'math', 'controls', "parameter_tools", 'vision')
88 changes: 88 additions & 0 deletions vision/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import java.text.SimpleDateFormat

plugins {
id "java"
id "maven-publish"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.peterabeles.gversion" version "1.10"
id "com.diffplug.spotless" version "6.24.0"
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

// Set this to true to enable desktop support.
def includeDesktopSupport = true

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
dependencies {
implementation 'edu.wpi.first.wpilibj:wpilibj-java:2024.3.2'
implementation 'edu.wpi.first.wpilibNewCommands:wpilibNewCommands-java:2024.3.2'

implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation 'com.googlecode.json-simple:json-simple:1.1.1'
}

test {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

project.compileJava.dependsOn(createVersionFile)
gversion {
srcDir = "src/main/java/"
classPackage = "frc.robot"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/New_York"
indent = " "
}

repositories {
mavenCentral()
mavenLocal()
maven {
url 'https://frcmaven.wpi.edu/artifactory/release/'
}
gradlePluginPortal()
}

spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom 'origin/main'

format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
java {
// don't need to set target, it is inferred from java
// Allow ignoring certain parts in formatting.
toggleOffOn()
// apply a specific flavor of google-java-format
googleJavaFormat('1.19.2').aosp().reflowLongStrings()
// fix formatting of type annotations
formatAnnotations()
}
}

// Automatically format code on build.
compileJava.dependsOn 'spotlessApply'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coppercore.wpilib_interface.vision;
package coppercore.vision;

import edu.wpi.first.math.geometry.Transform3d;
import org.photonvision.PhotonCamera;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coppercore.wpilib_interface.vision;
package coppercore.vision;

import org.photonvision.PhotonCamera;
import org.photonvision.PhotonPoseEstimator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package coppercore.wpilib_interface.vision;
package coppercore.vision;

import edu.wpi.first.apriltag.AprilTagFieldLayout;
import edu.wpi.first.math.VecBuilder;
Expand Down Expand Up @@ -43,7 +43,9 @@ public void periodic() {
visionMeasurementConsumer.accept(
// TODO: Actual standard deviations (not zero)
new VisionMeasurement(
pose.get().estimatedPose.toPose2d(), result.getTimestampSeconds(), VecBuilder.fill(0.0, 0.0, Double.MAX_VALUE)));
pose.get().estimatedPose.toPose2d(),
result.getTimestampSeconds(),
VecBuilder.fill(0.0, 0.0, Double.MAX_VALUE)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package coppercore.wpilib_interface.vision;
package coppercore.vision;

import edu.wpi.first.math.Matrix;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.numbers.N1;
import edu.wpi.first.math.numbers.N3;

/**
* A vision measurement so that the consumer can be typed as a Consumer<VisionMeasurement>
* This is only necessary because java has no class for a consumer with 3 arguments.
* A vision measurement so that the consumer can be typed as a Consumer<VisionMeasurement> This is
* only necessary because java has no class for a consumer with 3 arguments.
*/
public record VisionMeasurement(Pose2d pose, double timestamp, Matrix<N3, N1> stdDevs) {}
38 changes: 38 additions & 0 deletions vision/vendordeps/WPILibNewCommands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"fileName": "WPILibNewCommands.json",
"name": "WPILib-New-Commands",
"version": "1.0.0",
"uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
"frcYear": "2024",
"mavenUrls": [],
"jsonUrl": "",
"javaDependencies": [
{
"groupId": "edu.wpi.first.wpilibNewCommands",
"artifactId": "wpilibNewCommands-java",
"version": "wpilib"
}
],
"jniDependencies": [],
"cppDependencies": [
{
"groupId": "edu.wpi.first.wpilibNewCommands",
"artifactId": "wpilibNewCommands-cpp",
"version": "wpilib",
"libName": "wpilibNewCommands",
"headerClassifier": "headers",
"sourcesClassifier": "sources",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena",
"linuxarm32",
"linuxarm64",
"windowsx86-64",
"windowsx86",
"linuxx86-64",
"osxuniversal"
]
}
]
}
File renamed without changes.

0 comments on commit 1260d09

Please sign in to comment.