diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 24584ee..353fa55 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -2,10 +2,10 @@ name: "Validate Gradle Wrapper" on: push: branches: - - master + - main pull_request: branches: - - master + - main jobs: validation: diff --git a/ThePinkAlliance.json b/ThePinkAlliance.json index a0bed09..88cdbb8 100644 --- a/ThePinkAlliance.json +++ b/ThePinkAlliance.json @@ -1,7 +1,7 @@ { "fileName": "ThePinkAlliance.json", "name": "ThePinkAlliance", - "version": "2.0.8", + "version": "2.0.9", "uuid": "9619F7EA-7F96-4236-9D94-02338DFED572", "mavenUrls": ["https://jitpack.io"], "jsonUrl": "https://raw.githubusercontent.com/ThePinkAlliance/core/main/ThePinkAlliance.json", @@ -9,7 +9,7 @@ { "groupId": "com.github.ThePinkAlliance", "artifactId": "core", - "version": "2.0.8" + "version": "2.0.9" } ], "jniDependencies": [], diff --git a/build.gradle b/build.gradle index 6c07efb..071c5ad 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'java-library' apply plugin: 'maven-publish' group = 'com.ThePinkAlliance.core' -version = '2.0.8' +version = '2.0.9' sourceCompatibility = JavaVersion.VERSION_11 // java 11 targetCompatibility = JavaVersion.VERSION_11 @@ -12,10 +12,13 @@ repositories { maven { url = uri('https://frcmaven.wpi.edu/artifactory/release/') } + maven { url = uri('https://maven.revrobotics.com/') } + maven { url = uri('https://devsite.ctr-electronics.com/maven/release/') } } dependencies { implementation 'com.google.guava:guava:29.0-jre' + implementation 'edu.wpi.first.wpilibj:wpilibj-java:2022.4.1' implementation 'edu.wpi.first.shuffleboard:shuffleboard:2022.4.1' implementation 'edu.wpi.first.wpilibNewCommands:wpilibNewCommands-java:2022.4.1' @@ -23,6 +26,8 @@ dependencies { implementation 'edu.wpi.first.cscore:cscore-java:2022.4.1' implementation 'edu.wpi.first.ntcore:ntcore-java:2022.4.1' implementation 'edu.wpi.first.wpimath:wpimath-java:2022.4.1' + + implementation 'com.revrobotics.frc:REVLib-java:2022.1.0' } java { diff --git a/src/main/java/com/ThePinkAlliance/core/logger/CommandLogger.java b/src/main/java/com/ThePinkAlliance/core/logger/CommandLogger.java new file mode 100644 index 0000000..6ec4c44 --- /dev/null +++ b/src/main/java/com/ThePinkAlliance/core/logger/CommandLogger.java @@ -0,0 +1,37 @@ +package com.ThePinkAlliance.core.logger; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.Date; + +public class CommandLogger { + + private String commandName; + private String filename; + private String directory = "/home/lvuser/pink/logger/"; + + public CommandLogger(String commandName) { + this.commandName = commandName; + this.filename = commandName + ".command.csv"; + } + + public void recordWithTime(String[] rows, Object... objects) { + String timestamp = new Timestamp(new Date().getTime()).toString(); + File file = new File( + directory + commandName + "-" + timestamp + ".command.csv" + ); + FileWriter writer; + + try { + writer = new FileWriter(file); + + if (!file.exists()) { + file.createNewFile(); + } + } catch (IOException err) { + err.printStackTrace(); + } + } +} diff --git a/src/main/java/com/ThePinkAlliance/core/rev/RevNeo550.java b/src/main/java/com/ThePinkAlliance/core/rev/RevNeo550.java new file mode 100644 index 0000000..ca7bf32 --- /dev/null +++ b/src/main/java/com/ThePinkAlliance/core/rev/RevNeo550.java @@ -0,0 +1,16 @@ +package com.ThePinkAlliance.core.rev; + +import com.revrobotics.CANSparkMax; +import com.revrobotics.CANSparkMaxLowLevel; + +public class RevNeo550 extends CANSparkMax { + + /** + * This will configure a rev neo with amperage limit's by default. + * @param channel + */ + public RevNeo550(final int channel) { + super(channel, CANSparkMaxLowLevel.MotorType.kBrushless); + this.setSmartCurrentLimit(20); + } +} diff --git a/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackage.java b/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackage.java index 69ae8d6..19089d1 100644 --- a/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackage.java +++ b/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackage.java @@ -1,8 +1,11 @@ package com.ThePinkAlliance.core.shooter; public interface TargetPackage { - public double kP = 0; - public double kFF = 0; - public double rpm = 0; - public double hoodPosition = 0; + public double getKP(); + + public double getKFF(); + + public double getRpm(); + + public double getHoodPosition(); } diff --git a/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageFactory.java b/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageFactory.java deleted file mode 100644 index 065e885..0000000 --- a/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.ThePinkAlliance.core.shooter; - -public class TargetPackageFactory implements TargetPackage { - - double kP; - double kFF; - double rpm; - double hoodPosition; - - public TargetPackageFactory( - double kP, - double kFF, - double rpm, - double hoodPosition - ) { - this.kFF = kFF; - this.kP = kP; - this.hoodPosition = hoodPosition; - this.rpm = rpm; - } - - public TargetPackage build() { - return this; - } -} diff --git a/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageHelper.java b/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageHelper.java new file mode 100644 index 0000000..b319588 --- /dev/null +++ b/src/main/java/com/ThePinkAlliance/core/shooter/TargetPackageHelper.java @@ -0,0 +1,33 @@ +package com.ThePinkAlliance.core.shooter; + +public class TargetPackageHelper { + + public TargetPackage create( + double ff, + double kP, + double rpm, + double hoodPosition + ) { + return new TargetPackage() { + @Override + public double getKFF() { + return ff; + } + + @Override + public double getKP() { + return kP; + } + + @Override + public double getRpm() { + return rpm; + } + + @Override + public double getHoodPosition() { + return hoodPosition; + } + }; + } +} diff --git a/src/main/java/com/ThePinkAlliance/core/util/JoystickUtils.java b/src/main/java/com/ThePinkAlliance/core/util/JoystickUtils.java new file mode 100644 index 0000000..88c0d20 --- /dev/null +++ b/src/main/java/com/ThePinkAlliance/core/util/JoystickUtils.java @@ -0,0 +1,47 @@ +package com.ThePinkAlliance.core.util; + +public class JoystickUtils { + + public static double deadband(double value, double deadband) { + if (Math.abs(value) > deadband) { + if (value > 0.0) { + return (value - deadband) / (1.0 - deadband); + } else { + return (value + deadband) / (1.0 - deadband); + } + } else { + return 0.0; + } + } + + /** + * Apply deadband to the joystick input and Cube the output + * @param value is the raw joystick input + * @return the filtered joystick input + */ + public static double modifyAxisCubed(double value) { + // Deadband + value = deadband(value, 0.05); + + // Cubing due to raw power until robot reaches competition weight. + value = Math.copySign(value * value * value, value); + + return value; + } + + /** + * Apply deadband to the joystick input and Cube the output + * @param value is the raw joystick input + * @param deadband is the wanted deadband applied + * @return the filtered joystick input + */ + public static double modifyAxisCubed(double value, double deadband) { + // Deadband + value = deadband(value, deadband); + + // Cubing due to raw power until robot reaches competition weight. + value = Math.copySign(value * value * value, value); + + return value; + } +}