Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
do stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGamer1002 committed Apr 17, 2023
1 parent df96957 commit c48214c
Show file tree
Hide file tree
Showing 9 changed files with 1,061 additions and 73 deletions.
91 changes: 91 additions & 0 deletions src/main/java/frc/robot/Interfaces/CANSparkMax.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package frc.robot.interfaces;

import com.revrobotics.REVLibError;
import com.revrobotics.SparkMaxAbsoluteEncoder.Type;

import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.util.sendable.SendableBuilder;

Expand Down Expand Up @@ -316,6 +318,21 @@ public void initSendable(SendableBuilder builder) {

// current limits
builder.addIntegerProperty("Current Limit", null, this::setSmartCurrentLimit);


// pid stuff
builder.addDoubleProperty("P", this::getP, this::setP);
builder.addDoubleProperty("I", this::getI, this::setI);
builder.addDoubleProperty("D", this::getD, this::setD);
builder.addDoubleProperty("F", this::getF, this::setF);
builder.addDoubleProperty("IZone", this::getIZone, this::setIZone);
builder.addDoubleProperty("Min Output Range", this::getMinOutputRange, this::setMinOutputRange);
builder.addDoubleProperty("Max Output Range", this::getMaxOutputRange, this::setMaxOutputRange);

// encoder stuff
builder.addDoubleProperty("Encoder Position", this::getAbsoluteEncoderPosition, null);
builder.addDoubleProperty("Encoder Velocity", this::getAbsoluteEncoderVelocity, null);

}

/**
Expand Down Expand Up @@ -380,4 +397,78 @@ public REVLibError setSmartCurrentLimit(Long limit) {
throwIfClosed();
return setSmartCurrentLimit(limit.intValue(), 0, 20000);
}


// pid stuff
public void setP(double p) {
throwIfClosed();
getPIDController().setP(p);
}
public void setI(double i) {
throwIfClosed();
getPIDController().setI(i);
}
public void setD(double d) {
throwIfClosed();
getPIDController().setD(d);
}
public void setF(double f) {
throwIfClosed();
getPIDController().setFF(f);
}
public void setIZone(double iZone) {
throwIfClosed();
getPIDController().setIZone(iZone);
}
public void setMinOutputRange(double minOutputRange) {
throwIfClosed();
getPIDController().setOutputRange(minOutputRange, getMaxOutputRange());
}
public void setMaxOutputRange(double maxOutputRange) {
throwIfClosed();
getPIDController().setOutputRange(getMinOutputRange(), maxOutputRange);
}

public double getP() {
throwIfClosed();
return getPIDController().getP();
}
public double getI() {
throwIfClosed();
return getPIDController().getI();
}
public double getD() {
throwIfClosed();
return getPIDController().getD();
}
public double getF() {
throwIfClosed();
return getPIDController().getFF();
}
public double getIZone() {
throwIfClosed();
return getPIDController().getIZone();
}
public double getMinOutputRange() {
throwIfClosed();
return getPIDController().getOutputMin();
}
public double getMaxOutputRange() {
throwIfClosed();
return getPIDController().getOutputMax();
}


// absolute encoder stuff
public double getAbsoluteEncoderPosition() {
throwIfClosed();
return getAlternateEncoder(4096).getPosition();
}
public double getAbsoluteEncoderVelocity() {
throwIfClosed();
return getAlternateEncoder(4096).getVelocity();
}



}
Loading

0 comments on commit c48214c

Please sign in to comment.