From 6de818f78bc075ca507eef23695348933f1399f0 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 11:23:49 -0400 Subject: [PATCH 1/8] Do some big buildscript updates --- build.gradle | 208 +++++++++++++++-------- bundle/build.gradle | 4 +- examples/build.gradle | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- gradle_utils/README.md | 3 + gradle_utils/mavenrepos.gradle | 2 +- gradle_utils/projectjar.gradle | 19 +-- gradle_utils/simpleunittest.gradle | 3 + settings.gradle | 3 - 9 files changed, 161 insertions(+), 89 deletions(-) create mode 100644 gradle_utils/README.md diff --git a/build.gradle b/build.gradle index bc1e85fcd..64bf733bb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,6 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This is a general purpose Gradle build. - * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/ - */ - - +// This is the main build script. This mostly contains the gradle tasks for building the library JAR files and documentation +// This injects the gradlerio version info into all projects buildscript { repositories { jcenter() @@ -14,25 +8,30 @@ buildscript { } dependencies { - classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+' - classpath "edu.wpi.first:GradleRIO:2020.+" + // Update this version number to update GradleRIO + classpath "edu.wpi.first:GradleRIO:2020.+" } } +// All plugins used by the buildscript plugins { id "com.gradle.build-scan" version "3.3.4" + id "java-library" } -apply plugin: 'nebula-aggregate-javadocs' -apply plugin: "java-library" +// Load project dependancy configurations +apply from: "gradle_utils/libversions.gradle" +apply from: "gradle_utils/mavenrepos.gradle" // LIB VERSION project.version = "1.2.1" +// Enable Java support for all projects allprojects{ apply plugin: "java" } +// This enables some fancy gradle enterprise features for us gradleEnterprise { buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service' @@ -40,94 +39,165 @@ gradleEnterprise { } } +// This will automatically pull in everything that isnt the "examples" project +dependencies{ + println "Fetching dependancies for bundle" + rootProject.subprojects.each{ + if ( it.name != "examples"){ + api it + } + } +} -// task document { -// dependsOn "aggregateJavadocs" -// doLast { -// file("$rootProject.buildDir/docs/javadoc").renameTo(file("docs")) -// } -// } - +// This gets run by our CI pipeline to generate https://frc5024.github.io/lib5k task document(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { + + // Set the jars to be generated into the build directory destinationDir = file("$buildDir/docs/javadoc") + + // Set the JavaDoc webpage title title = "$project.name $version API" + + // Set the custom CSS file containing our logo and theme options.setStylesheetFile(file("javadoc.css")) + + // These fix a JavaDoc bug options.addBooleanOption('-no-module-directories', true) options.author true + + // If you add a new dependancy to the project, add its javadoc URL to this list options.links 'http://docs.spring.io/spring/docs/4.3.x/javadoc-api/', 'http://docs.oracle.com/javase/8/docs/api/', 'http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/api/', 'http://docs.spring.io/spring-security/site/docs/4.0.4.RELEASE/apidocs/', 'https://first.wpi.edu/FRC/roborio/release/docs/java/', 'https://www.revrobotics.com/content/sw/max/sw-docs/java/', 'https://www.kauailabs.com/public_files/navx-mxp/apidocs/java/', 'https://knowm.org/javadocs/xchart/' - options.addStringOption 'Xdoclint:none', '-quiet' - println "Building recursive JavaDoc" + + // Any JavaDoc options should go here + options.addStringOption 'Xdoclint:none', '-quiet' - // source subprojects.collect { proj -> proj.sourceSets.main.allJava } + // Load the configuraation from every subproject subprojects.each { proj -> + // Don't document the "examples" project if (proj.name != "examples"){ - println 'Adding ' + proj.projectDir + "/src/main/java" + + // Read form every JavaDoc task in the subproject proj.tasks.withType(Javadoc).each { javadocTask -> - println 'Found JavaDoc task' + + // Add the task sources to the main JavaDoc source += javadocTask.source classpath += javadocTask.classpath excludes += javadocTask.excludes includes += javadocTask.includes + } + } + } - doLast { - println "Copying javadoc to docs folder" - delete "docs" - file("$rootProject.buildDir/docs/javadoc").renameTo(file("docs")) - } + doLast { + // Clear out the docs folder, and move the JavaDoc into it + delete "docs" + file("$rootProject.buildDir/docs/javadoc").renameTo(file("docs")) + } } +// This is just a compatibility thing subprojects.each { subproject -> evaluationDependsOn(subproject.path) } -task mmJar(type: Jar, dependsOn: subprojects.jar) { - subprojects.each { subproject -> - from subproject.configurations.archives.artifacts.files.collect { - zipTree(it) - } - } + + + +// task packModules(type: Zip){ +// archiveFileName = "modules.zip" +// destinationDirectory = file("_release") +// from "_release/modules" +// } + +// task buildRelease(type: Jar){ +// delete file("_release") +// delete file("$rootProject.buildDir/libs") +// dependsOn subprojects.fatJar +// dependsOn subprojects.jar +// dependsOn project(":bundle").buildBundle +// dependsOn copyPy +// dependsOn packModules +// } + +// artifacts{ +// archives project(":bundle").buildBundle +// } + +/* Build all the required JARs */ + +// This will take every JavaDoc and pack it into a single JAR +task _buildJavaDocJar(type: Jar, dependsOn: document){ + classifier = "javadoc" + from file("docs") } -task copyPyLogReader(type: Copy){ - from "scripts/logreader.py" - into "_release" +// This will create a Jar file containing all the source code. This isn't used on-robot, but is just used by IDEs to generate the 'F12' info +task _buildAllSourcesJar(type: Jar){ + classifier = "sources" + + // Iterate through each project, and add it's source code + from allprojects.collect { it.sourceSets.main.allSource } +} + +// This task bundles together all the .class files into a single JAR +task _buildAllClassesJar(type: Jar){ + classifier = "classes" + + // Needs to build the project + dependsOn build + + // Disable support for 64-bit JARs (The RoboRIO is a 32-bit system) + zip64 = false + + // Load all class files + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + +} + +// This will bundle EVERYTHING into one Jar +task _buildAllJar(type: Jar){ + classifier = "all" + + // Needs to build the project + dependsOn build + + // Load all files for the bug JAR + from file("docs"), allprojects.collect { it.sourceSets.main.allSource }, { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } +} + +// This task is used to copy all python scripts from scripts/ to _release/python/ +task _copyPy(type: Copy){ + from "scripts" + into "_release/python" + include "*.py" +} + +// This task is used to copy all jar files from build/libs/ to _release/jar/ +task _copyJar(type: Copy){ + + // Copy dependancies + dependsOn _buildJavaDocJar + dependsOn _buildAllSourcesJar + dependsOn _buildAllClassesJar + dependsOn _buildAllJar + + // Where and how to copy + from "build/libs" + into "_release/jar" + include project.name + "-" + project.version +"-*.jar" } -task copyPySim(type: Copy){ - from "scripts/simulate.py" - into "_release" +// This task is used to clean out the _release directory +task _cleanRelease(type: Delete){ + delete "_release" } +tasks.clean.dependsOn(tasks._cleanRelease) -task packModules(type: Zip){ - archiveFileName = "modules.zip" - destinationDirectory = file("_release") - from "_release/modules" +task buildRelease { + dependsOn _copyPy + dependsOn _copyJar } -task buildRelease(type: Jar){ - delete file("_release") - delete file("$rootProject.buildDir/libs") - dependsOn subprojects.fatJar - dependsOn subprojects.jar - dependsOn project(":bundle").buildBundle - dependsOn copyPyLogReader - dependsOn copyPySim - dependsOn packModules - // doLast{ - // subprojects.each { subproject -> - // from subproject.configurations.archives.artifacts.files.collect { - // zipTree(it) - // } - // } - // // fileTree("_release/modules").each { - // // from it - // // } - - // // from fileTree("_release/modules").files.collect - // println "$rootProject.buildDir/libs/lib5k-"+project.version+".jar" - // file("$rootProject.buildDir/libs/lib5k-"+project.version+".jar").renameTo(file("_release/lib5k-"+project.version+"-monolithic.jar")) - // } -} \ No newline at end of file diff --git a/bundle/build.gradle b/bundle/build.gradle index 5c1c9181f..f4d745482 100644 --- a/bundle/build.gradle +++ b/bundle/build.gradle @@ -17,10 +17,10 @@ dependencies{ } task buildBundle(type: Jar) { - baseName = "lib5k-bundle-" + rootProject.version + '-monolithic' + baseName = "lib5k-" + rootProject.version from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar - destinationDir = file("$rootDir/_release") + destinationDir = file("$rootDir/_release/jar") } // This is just to remove build errors in root script diff --git a/examples/build.gradle b/examples/build.gradle index ef17e73ba..c41af7f78 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -87,7 +87,7 @@ dependencies { implementation 'com.github.ewpratten:ewmath:master-SNAPSHOT' // All of lib5k - implementation project(":bundle") + implementation project(":") // HALSIM simulation wpi.deps.sim.gui(wpi.platforms.desktop, false) @@ -118,7 +118,7 @@ task fatJar{ jar { // Require other libraries - dependsOn ":bundle:jar" + dependsOn ":_buildAllClassesJar" // Bundle the JAR from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4d7b2bf6..ab67bfa2e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists +distributionPath=permwrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=permwrapper/dists diff --git a/gradle_utils/README.md b/gradle_utils/README.md new file mode 100644 index 000000000..89e617826 --- /dev/null +++ b/gradle_utils/README.md @@ -0,0 +1,3 @@ +# Gradle scripts + +Since this is a big project, and it is split into sub-projects, everything that is needed across projects is stored here. \ No newline at end of file diff --git a/gradle_utils/mavenrepos.gradle b/gradle_utils/mavenrepos.gradle index abdea72e7..442190abe 100644 --- a/gradle_utils/mavenrepos.gradle +++ b/gradle_utils/mavenrepos.gradle @@ -1,4 +1,4 @@ - +// This file contains the maven configurations used by everything apply plugin: "edu.wpi.first.GradleRIO" diff --git a/gradle_utils/projectjar.gradle b/gradle_utils/projectjar.gradle index 1a8748b20..f7cad9fae 100644 --- a/gradle_utils/projectjar.gradle +++ b/gradle_utils/projectjar.gradle @@ -1,12 +1,11 @@ -task fatJar(type: Jar) { - // manifest { - // attributes 'Implementation-Title': 'Gradle Jar File Example', - // 'Implementation-Version': version, - // 'Main-Class': 'com.mkyong.DateUtils' - // } - // classifier = 'all' - baseName = project.name + "-" + rootProject.version + '-module-all' +// This file contains the common tasks for building the indevidual JAR files for each subproject + +// This will build a JAR file that contains the subproject's class files, and the class files for all required dependancies / libraries +// This way, everything is technically standalone +task _buildProjectFatJar(type: Jar) { + classifier = "classes" + baseName = project.name + "-" + rootProject.version from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } with jar - destinationDir = file("$rootDir/_release/modules") -} \ No newline at end of file +} + diff --git a/gradle_utils/simpleunittest.gradle b/gradle_utils/simpleunittest.gradle index feccd94b5..edd339a84 100644 --- a/gradle_utils/simpleunittest.gradle +++ b/gradle_utils/simpleunittest.gradle @@ -1,3 +1,6 @@ +// This file contains a Gradle task that provides nicer unit test output info +// This is used by every sub-project + import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.api.tasks.testing.logging.TestLogEvent diff --git a/settings.gradle b/settings.gradle index 984a8d29d..b16329c11 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,9 +10,6 @@ rootProject.name = 'lib5k' -// Bundle build script -include ":bundle" - // Examples include ":examples" From faf9a5f2b11dd58408ea2f593ac8ab88486c3393 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 11:24:07 -0400 Subject: [PATCH 2/8] Remove the bundle project --- bundle/build.gradle | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 bundle/build.gradle diff --git a/bundle/build.gradle b/bundle/build.gradle deleted file mode 100644 index f4d745482..000000000 --- a/bundle/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -plugins{ - id "java-library" -} - -apply from: "../gradle_utils/libversions.gradle" -apply from: "../gradle_utils/simpleunittest.gradle" -apply from: "../gradle_utils/mavenrepos.gradle" - -dependencies{ - println "Fetching dependancies for bundle" - rootProject.subprojects.each{ - if (it.name != "bundle" && it.name != "examples"){ - println it.name - api it - } - } -} - -task buildBundle(type: Jar) { - baseName = "lib5k-" + rootProject.version - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - with jar - destinationDir = file("$rootDir/_release/jar") -} - -// This is just to remove build errors in root script -task fatJar{ - -} \ No newline at end of file From ad1c9f70aaa778e6067bb1bec84effe1dce1cbe3 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 11:28:40 -0400 Subject: [PATCH 3/8] Update docs script --- build.gradle | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 64bf733bb..8dbeaee04 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,6 @@ gradleEnterprise { // This will automatically pull in everything that isnt the "examples" project dependencies{ - println "Fetching dependancies for bundle" rootProject.subprojects.each{ if ( it.name != "examples"){ api it @@ -49,8 +48,8 @@ dependencies{ } } -// This gets run by our CI pipeline to generate https://frc5024.github.io/lib5k -task document(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { +// This task takes every subproject's Javadoc, and merges it into one +task combineJavadoc(type: Javadoc, description: 'Generate javadocs from all child projects as if it was a single project', group: 'Documentation') { // Set the jars to be generated into the build directory destinationDir = file("$buildDir/docs/javadoc") @@ -92,39 +91,27 @@ task document(type: Javadoc, description: 'Generate javadocs from all child proj } - doLast { - // Clear out the docs folder, and move the JavaDoc into it - delete "docs" - file("$rootProject.buildDir/docs/javadoc").renameTo(file("docs")) - } +} + +// This task is used to make the "clean" task clean out the docs directory +task _cleanDocs(type: Delete){ + delete "docs" } +tasks.clean.dependsOn(tasks._cleanDocs) // This is just a compatibility thing subprojects.each { subproject -> evaluationDependsOn(subproject.path) } - - -// task packModules(type: Zip){ -// archiveFileName = "modules.zip" -// destinationDirectory = file("_release") -// from "_release/modules" -// } - -// task buildRelease(type: Jar){ -// delete file("_release") -// delete file("$rootProject.buildDir/libs") -// dependsOn subprojects.fatJar -// dependsOn subprojects.jar -// dependsOn project(":bundle").buildBundle -// dependsOn copyPy -// dependsOn packModules -// } - -// artifacts{ -// archives project(":bundle").buildBundle -// } +// This gets run by our CI pipeline to generate https://frc5024.github.io/lib5k +task document(dependsOn: combineJavadoc){ + // Clear out the docs folder, and move the JavaDoc into it + dependsOn _cleanDocs + doLast{ + file("$rootProject.buildDir/docs/javadoc").renameTo(file("docs")) + } +} /* Build all the required JARs */ From 588f99fae17073304ec2a748ab9cf91e42fe42cd Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 12:19:02 -0400 Subject: [PATCH 4/8] update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d52dd8533..e015aa5fa 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The software libraries that power all Raider Robotics projects. ## Using -The simplest way to use lib5k is to import the entire library (warning: this is quite big). This can be done by grabbing the latest `lib5k-bundle--monolithic.jar` file from the [releases page](https://github.com/frc5024/lib5k/releases/latest), and adding it to your project (here is a [tutorial](https://medium.com/@petehouston/compile-local-jar-files-with-gradle-a078e5c7a520)). +The simplest way to use lib5k is to import the entire library (warning: this is quite big). This can be done by grabbing the latest `lib5k--all.jar` file from the [releases page](https://github.com/frc5024/lib5k/releases/latest), and adding it to your project (here is a [tutorial](https://medium.com/@petehouston/compile-local-jar-files-with-gradle-a078e5c7a520)). If you would like to pick and choose which components you want, reference the chart below, and only add the jars you want. @@ -67,7 +67,7 @@ Any folder containing a `build.gradle` file can be a module. Make sure to add th To build a new release, first update the version number at the top of `build.gradle`. -Next, run `./gradlew clean build buildRelease`. This will build all modules individually, then also build a packaged jar with everything in it. All files will be exported to the `_release` folder. Team members with permission to publish releases can then create a new GitHub release [here](https://github.com/frc5024/lib5k/releases/new). +Next, run `./gradlew clean buildRelease`. This will build all modules individually, then also build a packaged jar with everything in it. All files will be exported to the `_release` folder. Team members with permission to publish releases can then create a new GitHub release [here](https://github.com/frc5024/lib5k/releases/new). Otherwise, you can just use these files, and follow [the instructions above](#using). From 80abd32a3095792efc527e4c3c65fc73b91d3063 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 14:12:14 -0400 Subject: [PATCH 5/8] Report the language version --- .../java/io/github/frc5024/lib5k/autonomous/RobotProgram.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java b/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java index 05041ee83..5ecc06147 100644 --- a/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java +++ b/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java @@ -9,6 +9,7 @@ import io.github.frc5024.lib5k.logging.RobotLogger; import io.github.frc5024.lib5k.hardware.ni.roborio.FaultReporter; +import io.github.frc5024.lib5k.hardware.ni.roborio.fpga.RR_HAL; /** * RobotProgram is the base class for all robot programs. @@ -74,7 +75,8 @@ public RobotProgram(boolean runSchedulerInTestMode, boolean stopAutonomousInTele // Start logger logger.start(0.02); - // Start a fault reporter + // Report language + RR_HAL.reportFRCVersion("Java", RR_HAL.getLibraryVersion()); } From a0466f579860228d320ce367745c7649f8f7ca4b Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 15:07:35 -0400 Subject: [PATCH 6/8] Add portrait mode support to LimeLight --- .../ca/retrylife/frc/limelight/Limelight.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hardware/limelight/src/main/java/ca/retrylife/frc/limelight/Limelight.java b/hardware/limelight/src/main/java/ca/retrylife/frc/limelight/Limelight.java index e4fbd4dd0..8b2d5def7 100644 --- a/hardware/limelight/src/main/java/ca/retrylife/frc/limelight/Limelight.java +++ b/hardware/limelight/src/main/java/ca/retrylife/frc/limelight/Limelight.java @@ -18,6 +18,7 @@ public class Limelight { private boolean tv; private double tx, ty, ta, ts, tl, tshort, tlong, thor, tvert; private double[] camTran, cornx, corny; + private boolean portraitMode; public Limelight() { @@ -95,6 +96,13 @@ private void registerListeners() { } + /** + * Enable or disable portraitMode + */ + public void setPortrait(boolean portraitMode) { + this.portraitMode = portraitMode; + } + /** * Check if the Limelight has a target in view * @@ -124,8 +132,12 @@ public Target getTarget() { if (!hasTarget()) { return null; } - - return new Target(tx, ty, ta, ts, tshort, tlong, thor, tvert); + + if (portraitMode) { + return new Target(ty, tx, ta, ts, tshort, tlong, thor, tvert); + } else { + return new Target(tx, ty, ta, ts, tshort, tlong, thor, tvert); + } } /** From 01aafc226cd349a464a5489751b93400c97d981c Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 20:48:39 -0400 Subject: [PATCH 7/8] small cleanup things --- .../lib5k/autonomous/RobotProgram.java | 48 ++++++++++++++++++- build.gradle | 10 ++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java b/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java index 5ecc06147..2562cf824 100644 --- a/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java +++ b/autonomous/src/main/java/io/github/frc5024/lib5k/autonomous/RobotProgram.java @@ -1,5 +1,6 @@ package io.github.frc5024.lib5k.autonomous; +import edu.wpi.first.wpilibj.Sendable; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; @@ -68,9 +69,8 @@ public RobotProgram(boolean runSchedulerInTestMode, boolean stopAutonomousInTele this.stopAutonomousInTeleop = stopAutonomousInTeleop; this.dashboard = primaryDashboard; - // Send chooser to dashboard + // Create a chooser chooser = new SendableChooser<>(); - dashboard.add(chooser); // Start logger logger.start(0.02); @@ -80,6 +80,22 @@ public RobotProgram(boolean runSchedulerInTestMode, boolean stopAutonomousInTele } + /** + * For publishing the chooser (this can be overridden for custom dashboards) + * + * @param component Chooser component + */ + public void publishChooser(Sendable component) { + dashboard.add(component); + } + + /** + * This is run all the time + * + * @param init Did the robot just start? + */ + public abstract void periodic(boolean init); + /** * This is run during autonomous * @@ -108,6 +124,24 @@ public RobotProgram(boolean runSchedulerInTestMode, boolean stopAutonomousInTele */ public abstract void test(boolean init); + @Override + public void robotInit() { + + // Publish the chooser + publishChooser(chooser); + + // Call robot + periodic(true); + + } + + @Override + public void robotPeriodic() { + + // Call robot + periodic(false); + } + /** * Set the default autonomous sequence * @@ -136,6 +170,16 @@ public void addAutonomous(AutonomousSequence sequence) { chooser.addOption(sequence.getName(), sequence); } + /** + * Get the selected autonomous. If this is not called in autonomous(), it will + * return the default + * + * @return Selected autonomous sequence + */ + public AutonomousSequence getSelectedAutonomous() { + return autonomous; + } + @Override public void autonomousInit() { logger.log("Autonomous started"); diff --git a/build.gradle b/build.gradle index 8dbeaee04..67df25c08 100644 --- a/build.gradle +++ b/build.gradle @@ -150,6 +150,7 @@ task _buildAllJar(type: Jar){ // Needs to build the project dependsOn build + dependsOn document // Load all files for the bug JAR from file("docs"), allprojects.collect { it.sourceSets.main.allSource }, { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } @@ -183,8 +184,17 @@ task _cleanRelease(type: Delete){ } tasks.clean.dependsOn(tasks._cleanRelease) +// This will build everything needed for release task buildRelease { dependsOn _copyPy dependsOn _copyJar } +// This will build only a JAR file to be used for beta testing +task buildBeta(type: Copy) { + dependsOn _buildAllJar + + from "build/libs" + into "_release/jar" + include project.name + "-" + project.version +"-all.jar" +} \ No newline at end of file From 2d96dfd135ac0ac77d00156d22ffaa37f418765b Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Thu, 23 Jul 2020 21:19:44 -0400 Subject: [PATCH 8/8] Fix examples missing their periodic functions --- .../frc5024/lib5k/examples/autonomous_framework/Main.java | 5 +++++ .../lib5k/examples/autonomous_path_following/Main.java | 6 ++++++ .../frc5024/lib5k/examples/currentlimiting/Main.java | 6 +++--- .../io/github/frc5024/lib5k/examples/gyroscopes/Main.java | 4 ++++ .../github/frc5024/lib5k/examples/motorfactory/Main.java | 7 +++++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_framework/Main.java b/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_framework/Main.java index 94ddae5ab..468701346 100644 --- a/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_framework/Main.java +++ b/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_framework/Main.java @@ -30,6 +30,11 @@ public Main() { addAutonomous(new ActionB()); } + @Override + public void periodic(boolean init) { + + } + @Override public void autonomous(boolean init) { diff --git a/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_path_following/Main.java b/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_path_following/Main.java index 778007b32..3ef417f96 100644 --- a/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_path_following/Main.java +++ b/examples/src/main/java/io/github/frc5024/lib5k/examples/autonomous_path_following/Main.java @@ -27,6 +27,12 @@ public Main() { DriveTrain.getInstance().register(); } + + @Override + public void periodic(boolean init) { + + } + @Override public void autonomous(boolean init) { diff --git a/examples/src/main/java/io/github/frc5024/lib5k/examples/currentlimiting/Main.java b/examples/src/main/java/io/github/frc5024/lib5k/examples/currentlimiting/Main.java index e934ebff7..27a7832f3 100644 --- a/examples/src/main/java/io/github/frc5024/lib5k/examples/currentlimiting/Main.java +++ b/examples/src/main/java/io/github/frc5024/lib5k/examples/currentlimiting/Main.java @@ -24,7 +24,7 @@ public static void main(String[] args){ public Main() { super(false, true); - + // Creates the pdp object pdp = new PowerDistributionPanel(1); @@ -32,14 +32,14 @@ public Main() { motorSubsystem = new MotorSubsystem(); motorSubsystem.register(); - // This creates a new Current Limit Manager currentLimitManager = new CurrentLimitManager(pdp); } + @Override - public void robotPeriodic() { + public void periodic(boolean init) { // This runs the Current Limit and should be called after the motors are currentLimitManager.performCurrentLimits(); } diff --git a/examples/src/main/java/io/github/frc5024/lib5k/examples/gyroscopes/Main.java b/examples/src/main/java/io/github/frc5024/lib5k/examples/gyroscopes/Main.java index ddfc612aa..1d89d3c95 100644 --- a/examples/src/main/java/io/github/frc5024/lib5k/examples/gyroscopes/Main.java +++ b/examples/src/main/java/io/github/frc5024/lib5k/examples/gyroscopes/Main.java @@ -46,6 +46,10 @@ public Main() { // gyro = new ExtendedPigeonIMU(0); } + @Override + public void periodic(boolean init) { + } + @Override public void autonomous(boolean init) { diff --git a/examples/src/main/java/io/github/frc5024/lib5k/examples/motorfactory/Main.java b/examples/src/main/java/io/github/frc5024/lib5k/examples/motorfactory/Main.java index e9cce599c..9b3ddab9f 100644 --- a/examples/src/main/java/io/github/frc5024/lib5k/examples/motorfactory/Main.java +++ b/examples/src/main/java/io/github/frc5024/lib5k/examples/motorfactory/Main.java @@ -21,7 +21,7 @@ public static void main(String[] args){ - public Main(){ + public Main() { super(false, true); // Initializes the subsystems ctreMotorSubsystem = new CTREMotorSubsystem(); @@ -31,7 +31,10 @@ public Main(){ ctreMotorSubsystem.register(); revMotorSubsystem.register(); - + } + + @Override + public void periodic(boolean init) { } @Override