From 2e451a6445bf296d05d64b11cfce86786f8db1e4 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 07:32:37 -0700 Subject: [PATCH 1/8] Add comment about needing to require review from code owners. --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a6a097a6..e7015ac4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,4 +2,6 @@ # Note that for this to work, the repository's access settings (https://github.com/DeepBlueRobotics/RobotCode2024/settings/access) # need to be configured to allow the reviewers team (or a parent team like devs) to explicitly have write (or higher) access. # It isn't sufficient for all org members to have write access. +# Also, the branch protection rules (https://github.com/DeepBlueRobotics/RobotCode2024/settings/branches) +# for the master branch need to have "Require review from Code Owners" enabled. * @DeepBlueRobotics/reviewers From 9f4b00a40f3f1b1e2c298478546219e7a7b5cd03 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 07:55:53 -0700 Subject: [PATCH 2/8] Normalize line endings and keep them normalized. This is Windows and non-Windows users can work on the same file without introducing unneeded changes related to line endings. --- WPILib-License.md | 48 ++--- build.gradle | 224 +++++++++++------------ gradle/wrapper/gradle-wrapper.properties | 14 +- gradlew.bat | 184 +++++++++---------- settings.gradle | 70 +++---- 5 files changed, 270 insertions(+), 270 deletions(-) diff --git a/WPILib-License.md b/WPILib-License.md index 84349440..43b62ec2 100644 --- a/WPILib-License.md +++ b/WPILib-License.md @@ -1,24 +1,24 @@ -Copyright (c) 2009-2023 FIRST and other WPILib contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of FIRST, WPILib, nor the names of other WPILib - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2009-2023 FIRST and other WPILib contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of FIRST, WPILib, nor the names of other WPILib + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/build.gradle b/build.gradle index a3cab5c4..272e5dc9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,112 +1,112 @@ -plugins { - id "java" - id "edu.wpi.first.GradleRIO" version "2024.3.2" -} - -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -def ROBOT_MAIN_CLASS = "org.carlmontrobotics.Main" - -// Define my targets (RoboRIO) and artifacts (deployable files) -// This is added by GradleRIO's backing project DeployUtils. -deploy { - targets { - roborio(getTargetTypeClass('RoboRIO')) { - // Team number is loaded either from the .wpilib/wpilib_preferences.json - // or from command line. If not found an exception will be thrown. - // You can use getTeamOrDefault(team) instead of getTeamNumber if you - // want to store a team number in this file. - team = project.frc.getTeamNumber() - debug = project.frc.getDebugOrDefault(false) - - artifacts { - // First part is artifact name, 2nd is artifact type - // getTargetTypeClass is a shortcut to get the class type using a string - - frcJava(getArtifactTypeClass('FRCJavaArtifact')) { - } - - // Static files artifact - frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { - files = project.fileTree('src/main/deploy') - directory = '/home/lvuser/deploy' - } - } - } - } -} - -def deployArtifact = deploy.targets.roborio.artifacts.frcJava - -// Set to true to use debug for JNI. -wpi.java.debugJni = false - -// Set this to true to enable desktop support. -def includeDesktopSupport = true - -allprojects { - repositories { - maven { url 'https://jitpack.io' }//for lib199 - } -} - -// Don't cache changing modules -configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' -} - -// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. -// Also defines JUnit 5. -dependencies { - implementation wpi.java.deps.wpilib() - implementation wpi.java.vendor.java() - - roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio) - roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio) - - roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio) - roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio) - - nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop) - nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop) - simulationDebug wpi.sim.enableDebug() - - nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop) - nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) - simulationRelease wpi.sim.enableRelease() - - testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' - implementation "com.github.deepbluerobotics:lib199:0ce129844b9b918dad0207c0e1020fc26588f461" -} - -test { - useJUnitPlatform() - systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' -} - -// Simulation configuration (e.g. environment variables). -wpi.sim.addGui().defaultEnabled = true -wpi.sim.addDriverstation() - -// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') -// in order to make them all available at runtime. Also adding the manifest so WPILib -// knows where to look for our Robot Class. -jar { - from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - from sourceSets.main.allSource - manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) - duplicatesStrategy = DuplicatesStrategy.INCLUDE -} - -// Configure jar and deploy tasks -deployArtifact.jarTask = jar -wpi.java.configureExecutableTasks(jar) -wpi.java.configureTestTasks(test) - -// Configure string concat to always inline compile -tasks.withType(JavaCompile) { - options.compilerArgs.add '-XDstringConcat=inline' -} +plugins { + id "java" + id "edu.wpi.first.GradleRIO" version "2024.3.2" +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +def ROBOT_MAIN_CLASS = "org.carlmontrobotics.Main" + +// Define my targets (RoboRIO) and artifacts (deployable files) +// This is added by GradleRIO's backing project DeployUtils. +deploy { + targets { + roborio(getTargetTypeClass('RoboRIO')) { + // Team number is loaded either from the .wpilib/wpilib_preferences.json + // or from command line. If not found an exception will be thrown. + // You can use getTeamOrDefault(team) instead of getTeamNumber if you + // want to store a team number in this file. + team = project.frc.getTeamNumber() + debug = project.frc.getDebugOrDefault(false) + + artifacts { + // First part is artifact name, 2nd is artifact type + // getTargetTypeClass is a shortcut to get the class type using a string + + frcJava(getArtifactTypeClass('FRCJavaArtifact')) { + } + + // Static files artifact + frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { + files = project.fileTree('src/main/deploy') + directory = '/home/lvuser/deploy' + } + } + } + } +} + +def deployArtifact = deploy.targets.roborio.artifacts.frcJava + +// Set to true to use debug for JNI. +wpi.java.debugJni = false + +// Set this to true to enable desktop support. +def includeDesktopSupport = true + +allprojects { + repositories { + maven { url 'https://jitpack.io' }//for lib199 + } +} + +// Don't cache changing modules +configurations.all { + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' +} + +// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. +// Also defines JUnit 5. +dependencies { + implementation wpi.java.deps.wpilib() + implementation wpi.java.vendor.java() + + roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio) + roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio) + + roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio) + roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio) + + nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop) + nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop) + simulationDebug wpi.sim.enableDebug() + + nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop) + nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) + simulationRelease wpi.sim.enableRelease() + + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' + implementation "com.github.deepbluerobotics:lib199:0ce129844b9b918dad0207c0e1020fc26588f461" +} + +test { + useJUnitPlatform() + systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true' +} + +// Simulation configuration (e.g. environment variables). +wpi.sim.addGui().defaultEnabled = true +wpi.sim.addDriverstation() + +// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') +// in order to make them all available at runtime. Also adding the manifest so WPILib +// knows where to look for our Robot Class. +jar { + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + from sourceSets.main.allSource + manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS) + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + +// Configure jar and deploy tasks +deployArtifact.jarTask = jar +wpi.java.configureExecutableTasks(jar) +wpi.java.configureTestTasks(test) + +// Configure string concat to always inline compile +tasks.withType(JavaCompile) { + options.compilerArgs.add '-XDstringConcat=inline' +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7015f6be..5e82d67b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=permwrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=permwrapper/dists +distributionBase=GRADLE_USER_HOME +distributionPath=permwrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=permwrapper/dists diff --git a/gradlew.bat b/gradlew.bat index 6689b85b..93e3f59f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle index 0ae5a869..56bf6135 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,35 +1,35 @@ -import org.gradle.internal.os.OperatingSystem - -pluginManagement { - repositories { - mavenLocal() - gradlePluginPortal() - String frcYear = '2024' - File frcHome - if (OperatingSystem.current().isWindows()) { - String publicFolder = System.getenv('PUBLIC') - if (publicFolder == null) { - publicFolder = "C:\\Users\\Public" - } - def homeRoot = new File(publicFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } else { - def userFolder = System.getProperty("user.home") - def homeRoot = new File(userFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } - def frcHomeMaven = new File(frcHome, 'maven') - maven { - name 'frcHome' - url frcHomeMaven - } - sourceControl { - gitRepository("https://github.com/DeepBlueRobotics/lib199.git") { - producesModule("org.carlmontrobotics:lib199") - } - } - } -} - -Properties props = System.getProperties(); -props.setProperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true"); +import org.gradle.internal.os.OperatingSystem + +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + String frcYear = '2024' + File frcHome + if (OperatingSystem.current().isWindows()) { + String publicFolder = System.getenv('PUBLIC') + if (publicFolder == null) { + publicFolder = "C:\\Users\\Public" + } + def homeRoot = new File(publicFolder, "wpilib") + frcHome = new File(homeRoot, frcYear) + } else { + def userFolder = System.getProperty("user.home") + def homeRoot = new File(userFolder, "wpilib") + frcHome = new File(homeRoot, frcYear) + } + def frcHomeMaven = new File(frcHome, 'maven') + maven { + name 'frcHome' + url frcHomeMaven + } + sourceControl { + gitRepository("https://github.com/DeepBlueRobotics/lib199.git") { + producesModule("org.carlmontrobotics:lib199") + } + } + } +} + +Properties props = System.getProperties(); +props.setProperty("org.gradle.internal.native.headers.unresolved.dependencies.ignore", "true"); From 912e8d0abac19293c20e8d86ab940177dc5ab9f6 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 07:56:06 -0700 Subject: [PATCH 3/8] Keep line endings fixed. --- .github/.gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/.gitattributes diff --git a/.github/.gitattributes b/.github/.gitattributes new file mode 100644 index 00000000..9a839990 --- /dev/null +++ b/.github/.gitattributes @@ -0,0 +1,2 @@ + # Ensure end-of-line normalization for new files + * text=auto From 480e4f5e6280626bd2815b8e5717b00e7e8d8ae2 Mon Sep 17 00:00:00 2001 From: stwiggy <144397102+stwiggy@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:49:19 -0700 Subject: [PATCH 4/8] deleted unwanted files --- .../commands/AimAtSpeaker.java | 43 -------------- .../carlmontrobotics/commands/MoveToNote.java | 59 ------------------- 2 files changed, 102 deletions(-) delete mode 100644 src/main/java/org/carlmontrobotics/commands/AimAtSpeaker.java delete mode 100644 src/main/java/org/carlmontrobotics/commands/MoveToNote.java diff --git a/src/main/java/org/carlmontrobotics/commands/AimAtSpeaker.java b/src/main/java/org/carlmontrobotics/commands/AimAtSpeaker.java deleted file mode 100644 index 1966c2c3..00000000 --- a/src/main/java/org/carlmontrobotics/commands/AimAtSpeaker.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package org.carlmontrobotics.commands; - -import org.carlmontrobotics.subsystems.Arm; -import org.carlmontrobotics.subsystems.Drivetrain; -import org.carlmontrobotics.subsystems.Limelight; - -import edu.wpi.first.wpilibj2.command.Command; - -public class AimAtSpeaker extends Command { - private Arm arm; - private Drivetrain dt; - private Limelight ll; //shooter limelight - - /** Creates a new AimAtSpeaker. */ - public AimAtSpeaker(Arm arm, Drivetrain dt, Limelight ll) { - // Use addRequirements() here to declare subsystem dependencies. - addRequirements(this.arm = arm); - addRequirements(this.dt = dt); - this.ll = ll; - } - - // Called when the command is initially scheduled. - @Override - public void initialize() {} - - // Called every time the scheduler runs while the command is scheduled. - @Override - public void execute() {} - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) {} - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return false; - } -} diff --git a/src/main/java/org/carlmontrobotics/commands/MoveToNote.java b/src/main/java/org/carlmontrobotics/commands/MoveToNote.java deleted file mode 100644 index 81a4dc7a..00000000 --- a/src/main/java/org/carlmontrobotics/commands/MoveToNote.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) FIRST and other WPILib contributors. -// Open Source Software; you can modify and/or share it under the terms of -// the WPILib BSD license file in the root directory of this project. - -package org.carlmontrobotics.commands; - -import org.carlmontrobotics.Constants.Limelightc; -import org.carlmontrobotics.subsystems.Drivetrain; -import org.carlmontrobotics.subsystems.Limelight; -import org.carlmontrobotics.subsystems.LimelightHelpers; - -import edu.wpi.first.math.util.Units; -import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; -import edu.wpi.first.wpilibj2.command.Command; - -public class MoveToNote extends Command { - private final Drivetrain dt; - private final Limelight ll; - private Timer timer = new Timer(); - private boolean originalFieldOrientation; - /** Creates a new MoveToNote. */ - public MoveToNote(Drivetrain dt, Limelight ll) { - // Use addRequirements() here to declare subsystem dependencies. - addRequirements(this.dt=dt); - this.ll = ll; - } - - // Called when the command is initially scheduled. - @Override - public void initialize() { - originalFieldOrientation = dt.getFieldOriented(); - timer.reset(); - timer.start(); - dt.setFieldOriented(false); - } - - // Called every time the scheduler runs while the command is scheduled. - @Override - public void execute() { - double radErr = Units.degreesToRadians(LimelightHelpers.getTX(Limelightc.INTAKE_LL_NAME)); - double distErr = ll.getDistanceToNoteMeters(); //meters - double forwardErr = distErr * Math.cos(radErr); - dt.drive(Math.max(forwardErr*2, .5), 0, 0); - //180deg is about 6.2 rad/sec, min is .5rad/sec - } - - // Called once the command ends or is interrupted. - @Override - public void end(boolean interrupted) { - dt.setFieldOriented(originalFieldOrientation); - } - - // Returns true when the command should end. - @Override - public boolean isFinished() { - return timer.get() >= 0.5; - } -} From 2cbad4e4b196877c4cb9865951843e8d38d0e415 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 10:50:52 -0700 Subject: [PATCH 5/8] Remove all indentation from Robot.java as a test. --- src/main/java/org/carlmontrobotics/Robot.java | 160 +++++++++--------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/src/main/java/org/carlmontrobotics/Robot.java b/src/main/java/org/carlmontrobotics/Robot.java index 09b83ebf..f5996bf6 100644 --- a/src/main/java/org/carlmontrobotics/Robot.java +++ b/src/main/java/org/carlmontrobotics/Robot.java @@ -16,84 +16,84 @@ public class Robot extends TimedRobot { - private Command m_autonomousCommand; - public static Robot robot; - - private RobotContainer m_robotContainer; - - @Override - - public void robotInit() { - robot = this; - m_robotContainer = new RobotContainer(); - // SignalLogger.start(); - - // Record both DS control and joystick data - DataLogManager.start(); - DriverStation.startDataLog(DataLogManager.getLog()); - FollowPathCommand.warmupCommand().schedule(); - } - - @Override - public void robotPeriodic() { - CommandScheduler.getInstance().run(); - } - - @Override - public void disabledInit() { - // SignalLogger.stop(); - } - - @Override - public void disabledPeriodic() { - } - - @Override - public void disabledExit() { - } - - @Override - public void autonomousInit() { - m_autonomousCommand = m_robotContainer.getAutonomousCommand(); - - if (m_autonomousCommand != null) { - m_autonomousCommand.schedule(); - } - } - - @Override - public void autonomousPeriodic() { - } - - @Override - public void autonomousExit() { - } - - @Override - public void teleopInit() { - if (m_autonomousCommand != null) { - m_autonomousCommand.cancel(); - } - } - - @Override - public void teleopPeriodic() { - } - - @Override - public void teleopExit() { - } - - @Override - public void testInit() { - CommandScheduler.getInstance().cancelAll(); - } - - @Override - public void testPeriodic() { - } - - @Override - public void testExit() { - } +private Command m_autonomousCommand; +public static Robot robot; + +private RobotContainer m_robotContainer; + +@Override + +public void robotInit() { +robot = this; +m_robotContainer = new RobotContainer(); +// SignalLogger.start(); + +// Record both DS control and joystick data +DataLogManager.start(); +DriverStation.startDataLog(DataLogManager.getLog()); +FollowPathCommand.warmupCommand().schedule(); +} + +@Override +public void robotPeriodic() { +CommandScheduler.getInstance().run(); +} + +@Override +public void disabledInit() { +// SignalLogger.stop(); +} + +@Override +public void disabledPeriodic() { +} + +@Override +public void disabledExit() { +} + +@Override +public void autonomousInit() { +m_autonomousCommand = m_robotContainer.getAutonomousCommand(); + +if (m_autonomousCommand != null) { +m_autonomousCommand.schedule(); +} +} + +@Override +public void autonomousPeriodic() { +} + +@Override +public void autonomousExit() { +} + +@Override +public void teleopInit() { +if (m_autonomousCommand != null) { +m_autonomousCommand.cancel(); +} +} + +@Override +public void teleopPeriodic() { +} + +@Override +public void teleopExit() { +} + +@Override +public void testInit() { +CommandScheduler.getInstance().cancelAll(); +} + +@Override +public void testPeriodic() { +} + +@Override +public void testExit() { +} } From 91980f885b2509ca020a8f1d5249b159441b1000 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 11:56:08 -0700 Subject: [PATCH 6/8] Auto-format modified lines when saving in vscode. Also mostly revert immediately prior commit that was made to test this functionality. --- .vscode/settings.json | 12 +- src/main/java/org/carlmontrobotics/Robot.java | 162 +++++++++--------- 2 files changed, 88 insertions(+), 86 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6004b201..56e1a4ae 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,14 +18,18 @@ { "name": "WPIlibUnitTests", "workingDirectory": "${workspaceFolder}/build/jni/release", - "vmargs": [ "-Djava.library.path=${workspaceFolder}/build/jni/release" ], + "vmargs": [ + "-Djava.library.path=${workspaceFolder}/build/jni/release" + ], "env": { - "LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" , + "LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release", "DYLD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" } }, ], "java.test.defaultConfig": "WPIlibUnitTests", "wpilib.skipTests": true, - "java.debug.settings.onBuildFailureProceed": true -} + "java.debug.settings.onBuildFailureProceed": true, + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modificationsIfAvailable" +} \ No newline at end of file diff --git a/src/main/java/org/carlmontrobotics/Robot.java b/src/main/java/org/carlmontrobotics/Robot.java index f5996bf6..75313fad 100644 --- a/src/main/java/org/carlmontrobotics/Robot.java +++ b/src/main/java/org/carlmontrobotics/Robot.java @@ -12,88 +12,86 @@ import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; - - public class Robot extends TimedRobot { -private Command m_autonomousCommand; -public static Robot robot; - -private RobotContainer m_robotContainer; - -@Override - -public void robotInit() { -robot = this; -m_robotContainer = new RobotContainer(); -// SignalLogger.start(); - -// Record both DS control and joystick data -DataLogManager.start(); -DriverStation.startDataLog(DataLogManager.getLog()); -FollowPathCommand.warmupCommand().schedule(); -} - -@Override -public void robotPeriodic() { -CommandScheduler.getInstance().run(); -} - -@Override -public void disabledInit() { -// SignalLogger.stop(); -} - -@Override -public void disabledPeriodic() { -} - -@Override -public void disabledExit() { -} - -@Override -public void autonomousInit() { -m_autonomousCommand = m_robotContainer.getAutonomousCommand(); - -if (m_autonomousCommand != null) { -m_autonomousCommand.schedule(); -} -} - -@Override -public void autonomousPeriodic() { -} - -@Override -public void autonomousExit() { -} - -@Override -public void teleopInit() { -if (m_autonomousCommand != null) { -m_autonomousCommand.cancel(); -} -} - -@Override -public void teleopPeriodic() { -} - -@Override -public void teleopExit() { -} - -@Override -public void testInit() { -CommandScheduler.getInstance().cancelAll(); -} - -@Override -public void testPeriodic() { -} - -@Override -public void testExit() { -} + private Command m_autonomousCommand; + public static Robot robot; + + private RobotContainer m_robotContainer; + + @Override + + public void robotInit() { + robot = this; + m_robotContainer = new RobotContainer(); + // SignalLogger.start(); + + // Record both DS control and joystick data + DataLogManager.start(); + DriverStation.startDataLog(DataLogManager.getLog()); + FollowPathCommand.warmupCommand().schedule(); + } + + @Override + public void robotPeriodic() { + CommandScheduler.getInstance().run(); + } + + @Override + public void disabledInit() { + // SignalLogger.stop(); + } + + @Override + public void disabledPeriodic() { + } + + @Override + public void disabledExit() { + } + + @Override + public void autonomousInit() { + m_autonomousCommand = m_robotContainer.getAutonomousCommand(); + + if (m_autonomousCommand != null) { + m_autonomousCommand.schedule(); + } + } + + @Override + public void autonomousPeriodic() { + } + + @Override + public void autonomousExit() { + } + + @Override + public void teleopInit() { + if (m_autonomousCommand != null) { + m_autonomousCommand.cancel(); + } + } + + @Override + public void teleopPeriodic() { + } + + @Override + public void teleopExit() { + } + + @Override + public void testInit() { + CommandScheduler.getInstance().cancelAll(); + } + + @Override + public void testPeriodic() { + } + + @Override + public void testExit() { + } } From 091f2ac153da0d08a068d36df85890395618c72a Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 12:23:35 -0700 Subject: [PATCH 7/8] Restore AimArmSpeaker.java removed in earlier PR. --- .../commands/AimArmSpeaker.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/org/carlmontrobotics/commands/AimArmSpeaker.java diff --git a/src/main/java/org/carlmontrobotics/commands/AimArmSpeaker.java b/src/main/java/org/carlmontrobotics/commands/AimArmSpeaker.java new file mode 100644 index 00000000..ba2fe607 --- /dev/null +++ b/src/main/java/org/carlmontrobotics/commands/AimArmSpeaker.java @@ -0,0 +1,46 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package org.carlmontrobotics.commands; + +import org.carlmontrobotics.subsystems.Arm; +import org.carlmontrobotics.subsystems.Limelight; +import edu.wpi.first.math.MathUtil; +import edu.wpi.first.math.trajectory.TrapezoidProfile; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj2.command.Command; + +public class AimArmSpeaker extends Command { + private final Arm arm; + private final Limelight ll; + + /** Creates a new AimOuttakeSpeaker. */ + public AimArmSpeaker(Arm arm, Limelight ll) { + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(this.arm = arm); + this.ll = ll; + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + double goal = ll.getArmAngleToShootSpeakerRad(); + arm.setArmTarget(goal); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { +} + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) {} + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} From b80adcd21f2073f24d445df0b9f11e178d347634 Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Tue, 23 Apr 2024 12:27:40 -0700 Subject: [PATCH 8/8] Restore MoveToNote.java removed by previous commit. --- .../carlmontrobotics/commands/MoveToNote.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/org/carlmontrobotics/commands/MoveToNote.java diff --git a/src/main/java/org/carlmontrobotics/commands/MoveToNote.java b/src/main/java/org/carlmontrobotics/commands/MoveToNote.java new file mode 100644 index 00000000..81a4dc7a --- /dev/null +++ b/src/main/java/org/carlmontrobotics/commands/MoveToNote.java @@ -0,0 +1,59 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package org.carlmontrobotics.commands; + +import org.carlmontrobotics.Constants.Limelightc; +import org.carlmontrobotics.subsystems.Drivetrain; +import org.carlmontrobotics.subsystems.Limelight; +import org.carlmontrobotics.subsystems.LimelightHelpers; + +import edu.wpi.first.math.util.Units; +import edu.wpi.first.wpilibj.Timer; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.Command; + +public class MoveToNote extends Command { + private final Drivetrain dt; + private final Limelight ll; + private Timer timer = new Timer(); + private boolean originalFieldOrientation; + /** Creates a new MoveToNote. */ + public MoveToNote(Drivetrain dt, Limelight ll) { + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(this.dt=dt); + this.ll = ll; + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + originalFieldOrientation = dt.getFieldOriented(); + timer.reset(); + timer.start(); + dt.setFieldOriented(false); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + double radErr = Units.degreesToRadians(LimelightHelpers.getTX(Limelightc.INTAKE_LL_NAME)); + double distErr = ll.getDistanceToNoteMeters(); //meters + double forwardErr = distErr * Math.cos(radErr); + dt.drive(Math.max(forwardErr*2, .5), 0, 0); + //180deg is about 6.2 rad/sec, min is .5rad/sec + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + dt.setFieldOriented(originalFieldOrientation); + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return timer.get() >= 0.5; + } +}