Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
158 changes: 78 additions & 80 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
id "com.peterabeles.gversion" version "1.10"
// id "com.diffplug.spotless" version "6.12.0"
id 'com.diffplug.spotless' version '6.12.0'
}

java {
Expand Down Expand Up @@ -49,30 +49,8 @@ wpi.java.debugJni = false
// Set this to true to enable desktop support.
def includeDesktopSupport = true

// Configuration for AdvantageKit
repositories {
maven {
url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit")
credentials {
username = "Mechanical-Advantage-Bot"
password = "\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051"
}
}
mavenLocal()
}

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

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

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
// Also defines JUnit 5.
dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
Expand All @@ -91,24 +69,33 @@ 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'

implementation 'gov.nist.math:jama:1.0.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

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

implementation("com.google.guava:guava:33.0.0-jre")
}

project.compileJava.dependsOn(createVersionFile)
gversion {
srcDir = "src/main/java/"
classPackage = "frc.robot"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/Los_Angeles" // Use preferred time zone
indent = " "
}

test {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

// Simulation configuration (e.g. environment variables).
wpi.sim.addGui()
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')
Expand All @@ -131,56 +118,67 @@ tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

// 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 = " "
repositories {
maven {
url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit")
credentials {
username = "Mechanical-Advantage-Bot"
password = "\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051"
}
}
mavenLocal()
}

// Spotless formatting
// project.compileJava.dependsOn(spotlessApply)
// spotless {
// enforceCheck false
// java {
// target fileTree(".") {
// include "**/*.java"
// exclude "**/build/**", "**/build-*/**"
// }
// toggleOffOn()
// googleJavaFormat()
// removeUnusedImports()
// trimTrailingWhitespace()
// endWithNewline()
// }
// groovyGradle {
// target fileTree(".") {
// include "**/*.gradle"
// exclude "**/build/**", "**/build-*/**"
// }
// greclipse()
// indentWithSpaces(4)
// trimTrailingWhitespace()
// endWithNewline()
// }
// json {
// target fileTree(".") {
// include "**/*.json"
// exclude "**/build/**", "**/build-*/**"
// }
// gson().indentWithSpaces(2)
// }
// format "misc", {
// target fileTree(".") {
// include "**/*.md", "**/.gitignore"
// exclude "**/build/**", "**/build-*/**"
// }
// trimTrailingWhitespace()
// indentWithSpaces(2)
// endWithNewline()
// }
// }
configurations.all {
exclude group: "edu.wpi.first.wpilibj"
}

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

spotless {
enforceCheck false
java {
target fileTree('.') {
include '**/*.java'
exclude '**/build/**', '**/build-*/**', '**/BuildConstants.java'
}
toggleOffOn()
googleJavaFormat()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target fileTree('.') {
include '**/*.gradle'
exclude '**/build/**', '**/build-*/**'
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
format 'xml', {
target fileTree('.') {
include '**/*.xml'
exclude '**/build/**', '**/build-*/**'
}
eclipseWtp('xml')
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
format 'misc', {
target fileTree('.') {
include '**/*.md', '**/.gitignore'
exclude '**/build/**', '**/build-*/**'
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package frc.robot;

public class Constants {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not need this file, if you added it because of the errors on the import statements in other files you can remove those imports


}
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/subsystems/kicker/KickerIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

import org.littletonrobotics.junction.AutoLog;

import edu.wpi.first.math.geometry.Rotation2d;

/** Add your docs here. */
public interface KickerIO {
@AutoLog
public class KickerIOInputs {

// Motor values
public double velocityRPM;
public double velocityRPS;
public double currentDrawAmps;
public double temperatureCelsius;
public double motorOutputVolts;
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/frc/robot/subsystems/kicker/KickerIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,45 @@
import edu.wpi.first.math.util.Units;

public class KickerIOReal implements KickerIO {

public static final int KICKER_MOTOR_ID = 12;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to either use this on line 13 below or not have it


private TalonFX kickerMotor = new TalonFX(12);
private PositionVoltage motorRequest = new PositionVoltage(0.0);

private StatusSignal<Double> supplyVoltageSignal = kickerMotor.getDutyCycle();
private StatusSignal<Double> supplyVoltageSignal = kickerMotor.getMotorVoltage();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not technically supply voltage, maybe name outputVoltageSignal or motorVoltageSignal

private StatusSignal<Double> position = kickerMotor.getRotorPosition();
private StatusSignal<Double> velocity = kickerMotor.getRotorVelocity();
private StatusSignal<Double> currentDraw = kickerMotor.getStatorCurrent();

public KickerIOReal (){
TalonFXConfiguration kickerConfig = new TalonFXConfiguration();
kickerConfig.Feedback.SensorToMechanismRatio = 125/1;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also on line 30

kickerConfig.Slot0.kP = 10.0;
kickerConfig.Slot0.kD = 0.0;
kickerConfig.Slot0.kI = 0.0;

kickerConfig.CurrentLimits.StatorCurrentLimit = 20.0;
kickerConfig.CurrentLimits.StatorCurrentLimitEnable = true;
kickerConfig.Feedback.SensorToMechanismRatio = 125.0;
kickerMotor.getConfigurator().apply(kickerConfig);
}

public void setPosition(double degrees) {
kickerMotor.setControl(motorRequest.withPosition(Units.degreesToRotations(degrees)));
kickerMotor.setControl(motorRequest.withPosition(Units.degreesToRotations(degrees)));
}

public void reset(double degrees){
kickerMotor.setPosition((Units.degreesToRotations(degrees)));
}

public KickerIOInputsAutoLogged updateInputs() {
KickerIOInputsAutoLogged current = new KickerIOInputsAutoLogged();
KickerIOInputsAutoLogged updated = new KickerIOInputsAutoLogged(); //new values

current.currentDrawAmps = currentDraw.refresh().getValue();
current.positionRotations = position.refresh().getValue();
current.velocityRPM = velocity.refresh().getValue();
current.motorOutputVolts = 12 * supplyVoltageSignal.getValue();
updated.currentDrawAmps = currentDraw.getValue();
updated.positionRotations = position.getValue();
updated.velocityRPS = velocity.getValue();
updated.motorOutputVolts = 12 * supplyVoltageSignal.getValue();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need to multiply by 12 anymore


return(current);
return(updated);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.littletonrobotics.junction.Logger;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand All @@ -23,8 +24,8 @@ public KickerSubsystem(KickerIO io) {
));
}

public InstantCommand reset (){
return new InstantCommand(
public Command reset (){
return this.runOnce(
()->{io.reset(0);}
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/pivot/PivotIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface PivotIO {
public class PivotIOInputs {

// Motor values
public double velocityRPM;
public double velocityRPS;
public double currentDrawAmps;
public double temperatureCelsius;
public double motorOutputVolts;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/frc/robot/subsystems/pivot/PivotIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@

public class PivotIOReal implements PivotIO{

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same feedback as with kicker


public static final int PIVOT_MOTOR_ID = 10;
public static final double PIVOT_GEAR_RATIO = (27.0 / 1) * (48.0 / 22); //check if this is the correct gear ratio

private TalonFX pivotMotor = new TalonFX(10);
private PositionVoltage motorRequest = new PositionVoltage(0.0);

private StatusSignal<Double> supplyVoltageSignal = pivotMotor.getDutyCycle();
private StatusSignal<Double> supplyVoltageSignal = pivotMotor.getMotorVoltage();
private StatusSignal<Double> position = pivotMotor.getRotorPosition();
private StatusSignal<Double> velocity = pivotMotor.getRotorVelocity();
private StatusSignal<Double> currentDraw = pivotMotor.getStatorCurrent();


public PivotIOReal (){
TalonFXConfiguration pivotConfig = new TalonFXConfiguration();
pivotConfig.Slot0.kP = 120;
Expand Down Expand Up @@ -51,13 +53,13 @@ public void reset(double degrees){

@Override
public PivotIOInputsAutoLogged updateInputs() {
PivotIOInputsAutoLogged current = new PivotIOInputsAutoLogged();
PivotIOInputsAutoLogged updated = new PivotIOInputsAutoLogged();

current.currentDrawAmps = currentDraw.refresh().getValue();
current.positionRotations = position.refresh().getValue();
current.velocityRPM = velocity.refresh().getValue();
current.motorOutputVolts = 12 * supplyVoltageSignal.getValue();
updated.currentDrawAmps = currentDraw.getValue();
updated.positionRotations = position.getValue();
updated.velocityRPS = velocity.getValue();
updated.motorOutputVolts = 12 * supplyVoltageSignal.getValue();

return(current);
return(updated);
}
}
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/pivot/PivotIOSim.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PivotIOInputsAutoLogged updateInputs() {

// var motorSimState = motor.getSimState();

input.velocityRPM = arm.getVelocityRadPerSec() * 60;
input.velocityRPS = arm.getVelocityRadPerSec() * 60;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check units here

input.currentDrawAmps = arm.getCurrentDrawAmps();
input.temperatureCelsius = 0;
input.motorOutputVolts = arm.getOutput(0);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/pivot/PivotSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public PivotSubsystem(PivotIO io) {
));
}

public InstantCommand reset (){
return new InstantCommand(
public Command reset (){
return this.runOnce(
()->{io.reset(0);}
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public interface ShooterIO {
public class ShooterIOInputs {

// Motor values
public double velocityRPM;
public double velocityRPS;
public double currentDrawAmps;
public double temperatureCelsius;
public double motorOutputVolts; }

public abstract void setVelocity(double velocity);
public abstract void setVelocity(double rotationsPerSecond);

public abstract ShooterIOInputsAutoLogged updateInputs();
}
Loading