From c8dc0962027380dd8ae4890346b5dceae1865efd Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 14:24:05 -0400 Subject: [PATCH 1/7] Update README.md --- README.md | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 141 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff51ec7..6499b06 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # GRRBase -A template repository for Java-based robots in the FIRST Robotics Competition. -### Code Styling -All Java code follows the styling guide of [Prettier](https://prettier.io/). You can apply these rules via [Spotless](https://github.com/diffplug/spotless/tree/main) using the command `./gradlew spotlessApply`. +A template repository for Java-based robots in the FIRST Robotics Competition. -### Highlights +## Highlights - [Swerve API](https://github.com/Greater-Rochester-Robotics/GRRBase/blob/main/src/main/java/org/team340/lib/swerve/SwerveAPI.java) @@ -12,6 +10,144 @@ All Java code follows the styling guide of [Prettier](https://prettier.io/). You - [Pre-defined Loggers](https://github.com/Greater-Rochester-Robotics/GRRBase/tree/main/src/main/java/org/team340/lib/logging) - Utilizing Epilogue, an annotation-based logging framework, custom loggers for vendor and WPILib APIs are pre-defined to transparently log relevant data from the robot's hardware, without any extra setup required. + Utilizing Epilogue, an annotation-based logging framework, custom loggers for vendor and WPILib APIs are pre-defined to transparently log relevant data from the robot's hardware. - [Various other utilities](https://github.com/Greater-Rochester-Robotics/GRRBase/tree/main/src/main/java/org/team340/lib/util) + +## Getting Started + +### Creating your repository + +1. On GitHub, navigate to the main page of this repository. +2. Above the file list, click *Use this template*. +3. Select *Create a new repository*. + +![Creating a new repository](https://github.com/user-attachments/assets/fe88cfe9-6326-4723-8733-fb116ad809fb) + +### Prerequisites + +- [WPILib](https://github.com/wpilibsuite/allwpilib/releases) 2025.x +- [Node.js](https://nodejs.org/en/download) (v22 LTS Recommended) + +Node.js is required to support linting via [Spotless](https://github.com/diffplug/spotless), using the [Prettier](https://prettier.io) style guide. You can apply these rules by building, or by running `./gradlew spotlessApply`. Alternatively, if you wish to disable code formatting, you can do so with the following modifications to [build.gradle](build.gradle): + +
+ +Expand + +```diff +diff --git a/build.gradle b/build.gradle +index 155f017..7670ad8 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -1,7 +1,6 @@ + plugins { + id "java" + id "edu.wpi.first.GradleRIO" version "2025.3.2" +- id "com.diffplug.spotless" version "7.0.2" + } + + java { +@@ -83,30 +82,6 @@ dependencies { + implementation 'com.google.code.gson:gson:2.11.0' + } + +-// Code formatting via spotless +-spotless { +- java { +- target fileTree('.') { +- include '**/*.java' +- exclude '**/build/**', '**/build-*/**' +- } +- +- toggleOffOn() +- endWithNewline() +- removeUnusedImports() +- trimTrailingWhitespace() +- prettier(['prettier': '3.4.2', 'prettier-plugin-java': '2.6.7']) +- .config([ +- 'parser': 'java', +- 'plugins': ['prettier-plugin-java'], +- printWidth: 120, +- tabWidth: 4, +- useTabs: false, +- trailingComma: "none" +- ]) +- } +-} +- + test { + useJUnitPlatform() + systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' +@@ -134,5 +109,4 @@ wpi.java.configureTestTasks(test) + // Configure string concat to always inline compile + tasks.withType(JavaCompile) { + options.compilerArgs.add '-XDstringConcat=inline' +- dependsOn 'spotlessApply' + } +``` + +*You may also want to modify [robot-code.yml](.github/workflows/robot-code.yml) to remove the formatting check from CI:* + +```diff +diff --git a/.github/workflows/robot-code.yml b/.github/workflows/robot-code.yml +index 313b56e..4e26616 100644 +--- a/.github/workflows/robot-code.yml ++++ b/.github/workflows/robot-code.yml +@@ -5,32 +5,6 @@ env: + NODE_VERSION: 20 + + jobs: +- format: +- name: Check Format +- runs-on: ubuntu-latest +- container: wpilib/ubuntu-base:22.04 +- +- steps: +- - name: Checkout Repository +- uses: actions/checkout@v4 +- with: +- fetch-depth: 0 +- +- - name: Add repository to git safe directories +- run: git config --global --add safe.directory $GITHUB_WORKSPACE +- +- - name: Setup Node +- uses: actions/setup-node@v4 +- with: +- node-version: ${{ env.NODE_VERSION }} +- registry-url: https://registry.npmjs.org/ +- +- - name: Grant execute permission for gradlew +- run: chmod +x gradlew +- +- - name: Check robot code formatting +- run: ./gradlew spotlessCheck +- + build: + name: Build + runs-on: ubuntu-latest +``` + +
+ +### Configuring the project for your team + +First, ensure [wpilib_preferences.json](.wpilib/wpilib_preferences.json) is configured for your team number: + +```json +{ + ... + "teamNumber": 340 +} +``` + +*(Optional)* If you decide to modify the package name for your robot code (by default, `org.team340.robot`), you must update your [build.gradle](build.gradle) to reflect the new location of the project's `Main` class: + +```groovy +def ROBOT_MAIN_CLASS = "com.example.robot.Main" +``` + +## Project Layout + +This template adheres to the typical layout of a command-based robot project. The [subsystems](src/main/java/org/team340/robot/subsystems) directory From d68eaba4b0bbb398324882a3dd0dc80999592c74 Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 14:34:17 -0400 Subject: [PATCH 2/7] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 6499b06..768e0a8 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ A template repository for Java-based robots in the FIRST Robotics Competition. 2. Above the file list, click *Use this template*. 3. Select *Create a new repository*. -![Creating a new repository](https://github.com/user-attachments/assets/fe88cfe9-6326-4723-8733-fb116ad809fb) - ### Prerequisites - [WPILib](https://github.com/wpilibsuite/allwpilib/releases) 2025.x @@ -137,7 +135,6 @@ First, ensure [wpilib_preferences.json](.wpilib/wpilib_preferences.json) is conf ```json { - ... "teamNumber": 340 } ``` From 6da3e700707dff260ab0cd3e7c90c4b8a3f0dc9c Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 14:41:14 -0400 Subject: [PATCH 3/7] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 768e0a8..17ce2f9 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ A template repository for Java-based robots in the FIRST Robotics Competition. 2. Above the file list, click *Use this template*. 3. Select *Create a new repository*. +*See also: [GitHub Docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template)* + ### Prerequisites - [WPILib](https://github.com/wpilibsuite/allwpilib/releases) 2025.x @@ -33,6 +35,8 @@ Node.js is required to support linting via [Spotless](https://github.com/diffplu Expand +
+ ```diff diff --git a/build.gradle b/build.gradle index 155f017..7670ad8 100644 From f593753257fed68d97379196436a3da82877e8ca Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 14:43:23 -0400 Subject: [PATCH 4/7] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17ce2f9..1aa872b 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ A template repository for Java-based robots in the FIRST Robotics Competition. ## Highlights -- [Swerve API](https://github.com/Greater-Rochester-Robotics/GRRBase/blob/main/src/main/java/org/team340/lib/swerve/SwerveAPI.java) +- [Swerve API](src/main/java/org/team340/lib/swerve/SwerveAPI.java) Supports various hardware configurations, from vendors such as CTRE, REV, and Redux Robotics, with features such as high frequency odometry, a custom ratelimiter to improve driver control while also reducing wheel scrub, and built-in support for tuning the drivetrain's configuration live via NetworkTables. -- [Pre-defined Loggers](https://github.com/Greater-Rochester-Robotics/GRRBase/tree/main/src/main/java/org/team340/lib/logging) +- [Pre-defined Loggers](src/main/java/org/team340/lib/logging) Utilizing Epilogue, an annotation-based logging framework, custom loggers for vendor and WPILib APIs are pre-defined to transparently log relevant data from the robot's hardware. -- [Various other utilities](https://github.com/Greater-Rochester-Robotics/GRRBase/tree/main/src/main/java/org/team340/lib/util) +- [Various other utilities](src/main/java/org/team340/lib/util) ## Getting Started From 6c2bfbcfb091b90f07ce05b2cdf5a686f37e9605 Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 22:41:30 -0400 Subject: [PATCH 5/7] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1aa872b..307092a 100644 --- a/README.md +++ b/README.md @@ -151,4 +151,7 @@ def ROBOT_MAIN_CLASS = "com.example.robot.Main" ## Project Layout -This template adheres to the typical layout of a command-based robot project. The [subsystems](src/main/java/org/team340/robot/subsystems) directory +This template resembles the typical layout of a command-based robot project, with a [robot/subsystems](src/main/java/org/team340/robot/subsystems) directory containing user-defined subsystem classes, and a [robot/commands](src/main/java/org/team340/robot/commands) directory containing user-defined commands. An additional [lib](src/main/java/org/team340/lib) folder is included, containing library code that under normal usage should not require modification in-season. We intentionally do not supply this code as a [vendordep](https://docs.wpilib.org/en/stable/docs/software/vscode-overview/3rd-party-libraries.html) in the rare occasion it does need to be modified, with the primary concern being the potential need for at-competition patches. + +> [!NOTE] +> [RobotContainer.java](https://docs.wpilib.org/en/stable/docs/software/commandbased/structuring-command-based-project.html#robotcontainer) is notably omitted, and it is expected for subsystems and command bindings to instead be declared in [Robot.java](src/main/java/org/team340/robot/Robot.java). This is done for several reasons, however the user is still free to reinstate `RobotContainer` at their discretion. From 89efdb57fca40900b24599de85a06949d219a61c Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Sun, 27 Apr 2025 22:49:10 -0400 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 307092a..97e7fe1 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ def ROBOT_MAIN_CLASS = "com.example.robot.Main" ## Project Layout -This template resembles the typical layout of a command-based robot project, with a [robot/subsystems](src/main/java/org/team340/robot/subsystems) directory containing user-defined subsystem classes, and a [robot/commands](src/main/java/org/team340/robot/commands) directory containing user-defined commands. An additional [lib](src/main/java/org/team340/lib) folder is included, containing library code that under normal usage should not require modification in-season. We intentionally do not supply this code as a [vendordep](https://docs.wpilib.org/en/stable/docs/software/vscode-overview/3rd-party-libraries.html) in the rare occasion it does need to be modified, with the primary concern being the potential need for at-competition patches. +This template resembles the typical layout of a command-based robot project, with a [robot/subsystems](src/main/java/org/team340/robot/subsystems) directory containing user-defined subsystem classes, and a [robot/commands](src/main/java/org/team340/robot/commands) directory containing user-defined commands. An additional [lib](src/main/java/org/team340/lib) folder is included, containing library code that under normal usage should not require modification in-season. We intentionally do not supply this code as a vendordep in the rare occasion it does need to be modified. > [!NOTE] > [RobotContainer.java](https://docs.wpilib.org/en/stable/docs/software/commandbased/structuring-command-based-project.html#robotcontainer) is notably omitted, and it is expected for subsystems and command bindings to instead be declared in [Robot.java](src/main/java/org/team340/robot/Robot.java). This is done for several reasons, however the user is still free to reinstate `RobotContainer` at their discretion. From c7d3591f36ce33ce4ded5d4cad3509445964d1c5 Mon Sep 17 00:00:00 2001 From: Bryce Roethel Date: Tue, 29 Apr 2025 20:06:03 -0400 Subject: [PATCH 7/7] Update README.md --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 97e7fe1..32fc374 100644 --- a/README.md +++ b/README.md @@ -148,10 +148,3 @@ First, ensure [wpilib_preferences.json](.wpilib/wpilib_preferences.json) is conf ```groovy def ROBOT_MAIN_CLASS = "com.example.robot.Main" ``` - -## Project Layout - -This template resembles the typical layout of a command-based robot project, with a [robot/subsystems](src/main/java/org/team340/robot/subsystems) directory containing user-defined subsystem classes, and a [robot/commands](src/main/java/org/team340/robot/commands) directory containing user-defined commands. An additional [lib](src/main/java/org/team340/lib) folder is included, containing library code that under normal usage should not require modification in-season. We intentionally do not supply this code as a vendordep in the rare occasion it does need to be modified. - -> [!NOTE] -> [RobotContainer.java](https://docs.wpilib.org/en/stable/docs/software/commandbased/structuring-command-based-project.html#robotcontainer) is notably omitted, and it is expected for subsystems and command bindings to instead be declared in [Robot.java](src/main/java/org/team340/robot/Robot.java). This is done for several reasons, however the user is still free to reinstate `RobotContainer` at their discretion.