Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New stuff #22

Merged
merged 8 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2025beta",
"teamNumber": 4829
}
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2025beta",
"teamNumber": 4829
}
219 changes: 88 additions & 131 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-3"
id "com.peterabeles.gversion" version "1.10"
id "com.diffplug.spotless" version "6.25.0"
id "pmd"
id "io.freefair.lombok" version "8.4"
id "com.google.protobuf" version "0.9.4"
id "pmd"
}

def grpcVersion = '1.61.0' // CURRENT_GRPC_VERSION
def protobufVersion = '3.25.1'
def protocVersion = protobufVersion

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protobufVersion}"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}

sourceSets {
main {
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
}
proto {
srcDirs "trajectory_native/proto"
}
}
}

java {
Expand All @@ -64,14 +32,25 @@ deploy {
// getTargetTypeClass is a shortcut to get the class type using a string

frcJava(getArtifactTypeClass('FRCJavaArtifact')) {
gcType = edu.wpi.first.gradlerio.deploy.roborio.GarbageCollectorType.G1_Base
// https://www.chiefdelphi.com/t/2024-wpilib-feedback/464322/141
final MAX_JAVA_HEAP_SIZE_MB = 100;
jvmArgs.add("-XX:+UnlockExperimentalVMOptions")

// Set the minimum heap size to the maximum heap size to avoid resizing
jvmArgs.add("-Xmx" + MAX_JAVA_HEAP_SIZE_MB + "M")
jvmArgs.add("-Xms" + MAX_JAVA_HEAP_SIZE_MB + "M")
jvmArgs.add("-XX:GCTimeRatio=5")
jvmArgs.add("-XX:+UseSerialGC")
jvmArgs.add("-XX:MaxGCPauseMillis=50")
}

// Static files artifact
frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
predeploy << { execute 'rm -rf /home/lvuser/deploy' }
files = project.fileTree('src/main/deploy')
directory = '/home/lvuser/deploy'
// Change to true to delete files on roboRIO that no
// longer exist in deploy directory on roboRIO
deleteOldFiles = false
}
}
}
Expand All @@ -98,62 +77,15 @@ repositories {
mavenLocal()
}

configurations.all {
exclude group: "edu.wpi.first.wpilibj"
}

task(checkAkitInstall, dependsOn: "classes", type: JavaExec) {
mainClass = "org.littletonrobotics.junction.CheckInstall"
task(replayWatch, type: JavaExec) {
mainClass = "org.littletonrobotics.junction.ReplayWatch"
classpath = sourceSets.main.runtimeClasspath
}
compileJava.finalizedBy checkAkitInstall


//Check robot type when deploying
task(checkRobot, dependsOn: "classes", type: JavaExec) {
main = "frc.robot.Constants"
classpath = sourceSets.main.runtimeClasspath
}

deployroborio.dependsOn(checkRobot)

//Create commit with working changes on event branches
task(eventDeploy) {
doLast {
if (project.gradle.startParameter.taskNames.any({ it.toLowerCase().contains("deploy") })) {

def branchPrefix = "event"
def branch = 'git branch --show-current'.execute().text.trim()
def commitMessage = "Update at '${new Date().toString()}'"

if (branch.startsWith(branchPrefix)) {
exec {
workingDir(projectDir)
executable 'git'
args 'add', '-A'
}
exec {
workingDir(projectDir)
executable 'git'
args 'commit', '-m', commitMessage
ignoreExitValue = true
}

println "Committed to branch: '$branch'"
println "Commit message: '$commitMessage'"
} else {
println "Not on an event branch, skipping commit"
}
} else {
println "Not running deploy task, skipping commit"
}
}
}
createVersionFile.dependsOn(eventDeploy)

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
dependencies {
annotationProcessor wpi.java.deps.wpilibAnnotations()
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

Expand All @@ -171,25 +103,13 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
implementation "gov.nist.math:jama:1.0.3"


// Mockito for mocking objects in unit tests
testImplementation 'org.mockito:mockito-core:4.8.1'
testImplementation 'org.mockito:mockito-junit-jupiter:4.8.1'

implementation 'gov.nist.math:jama:1.0.3'

implementation "io.grpc:grpc-protobuf:${grpcVersion}"
implementation "io.grpc:grpc-services:${grpcVersion}"
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation "javax.annotation:javax.annotation-api:1.3.2"
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
implementation "com.google.guava:guava:31.1-jre"
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version"
annotationProcessor "org.littletonrobotics.akit:akit-autolog:$akitJson.version"
}

test {
Expand All @@ -198,7 +118,12 @@ test {
}

// Simulation configuration (e.g. environment variables).
wpi.sim.addGui().defaultEnabled = true
//
// The sim GUI is *disabled* by default to support running
// AdvantageKit log replay from the command line. Set the
// value to "true" to enable the sim GUI by default (this
// is the standard WPILib behavior).
wpi.sim.addGui().defaultEnabled = false
wpi.sim.addDriverstation()

// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
Expand Down Expand Up @@ -226,22 +151,58 @@ tasks.withType(JavaCompile) {
}

// Create version file
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 = " "
}
// 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 = " "
// }

// TODO: set this shit up
// Create commit with working changes on event branches
// task(eventDeploy) {
// doLast {
// if (project.gradle.startParameter.taskNames.any({ it.toLowerCase().contains("deploy") })) {
// def branchPrefix = "event"
// def branch = 'git branch --show-current'.execute().text.trim()
// def commitMessage = "Update at '${new Date().toString()}'"

// if (branch.startsWith(branchPrefix)) {
// exec {
// workingDir(projectDir)
// executable 'git'
// args 'add', '-A'
// }
// exec {
// workingDir(projectDir)
// executable 'git'
// args 'commit', '-m', commitMessage
// ignoreExitValue = true
// }

// println "Committed to branch: '$branch'"
// println "Commit message: '$commitMessage'"
// } else {
// println "Not on an event branch, skipping commit"
// }
// } else {
// println "Not running deploy task, skipping commit"
// }
// }
// }
// createVersionFile.dependsOn(eventDeploy)

// Spotless formatting
project.compileJava.dependsOn(spotlessApply)
spotless {
enforceCheck = false
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**'
target fileTree(".") {
include "**/*.java"
exclude "**/build/**", "**/build-*/**"
}
toggleOffOn()
googleJavaFormat()
Expand All @@ -250,36 +211,32 @@ spotless {
endWithNewline()
}
groovyGradle {
target fileTree('.') {
include '**/*.gradle'
exclude '**/build/**', '**/build-*/**'
target fileTree(".") {
include "**/*.gradle"
exclude "**/build/**", "**/build-*/**"
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
format 'xml', {
target fileTree('.') {
include '**/*.xml'
exclude '**/build/**', '**/build-*/**'
json {
target fileTree(".") {
include "**/*.json"
exclude "**/build/**", "**/build-*/**"
}
eclipseWtp('xml')
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
gson().indentWithSpaces(2)
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
exclude '**/build/**', '**/build-*/**'
format "misc", {
target fileTree(".") {
include "**/*.md", "**/.gitignore"
exclude "**/build/**", "**/build-*/**"
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}

// PMD configuration
pmd {
ignoreFailures = true
Expand Down
5 changes: 5 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "Keyboard0"
}
]
}
5 changes: 4 additions & 1 deletion simgui.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo"
"/AdvantageKit/RealOutputs/Alerts": "Alerts",
"/FMSInfo": "FMSInfo",
"/SmartDashboard/Alerts": "Alerts",
"/SmartDashboard/VisionSystemSim-main/Sim Field": "Field2d"
}
},
"NetworkTables Info": {
Expand Down
Loading
Loading