Adding the beginning of CommonPIDFConfig
This commit is contained in:
@@ -1,28 +1,79 @@
|
||||
package com.team2648.iocore.commons;
|
||||
|
||||
import com.revrobotics.spark.config.SparkMaxConfig;
|
||||
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
|
||||
import com.team2648.iocore.enums.MotorIdleMode;
|
||||
|
||||
public class CommonMotorControllerConfig {
|
||||
private boolean isInverted;
|
||||
|
||||
public CommonMotorControllerConfig() {
|
||||
private int supplyCurrentLimit;
|
||||
private int followCANID;
|
||||
|
||||
private MotorIdleMode mode;
|
||||
|
||||
|
||||
public CommonMotorControllerConfig() {
|
||||
isInverted = false;
|
||||
supplyCurrentLimit = -1;
|
||||
followCANID = -1;
|
||||
mode = MotorIdleMode.kCoast;
|
||||
}
|
||||
|
||||
public boolean isInverted() {
|
||||
return isInverted;
|
||||
}
|
||||
|
||||
public int getSupplyCurrentLimit() {
|
||||
return supplyCurrentLimit;
|
||||
}
|
||||
|
||||
public int getFollowCANID() {
|
||||
return followCANID;
|
||||
}
|
||||
|
||||
public MotorIdleMode getIdleMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public CommonMotorControllerConfig setInverted(boolean inverted) {
|
||||
this.isInverted = inverted;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonMotorControllerConfig setSupplyCurrentLimit(int supplyCurrentLimit) {
|
||||
this.supplyCurrentLimit = supplyCurrentLimit;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonMotorControllerConfig setFollowCANID(int followCANID) {
|
||||
this.followCANID = followCANID;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonMotorControllerConfig setIdleMode(MotorIdleMode mode) {
|
||||
this.mode = mode;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public SparkMaxConfig getAsSparkMaxConfig() {
|
||||
// TODO More config
|
||||
SparkMaxConfig config = new SparkMaxConfig();
|
||||
config.inverted(isInverted);
|
||||
config.inverted(isInverted)
|
||||
.idleMode(mode == MotorIdleMode.kCoast ? IdleMode.kCoast : IdleMode.kBrake);
|
||||
|
||||
if(supplyCurrentLimit > 0) {
|
||||
config.smartCurrentLimit(supplyCurrentLimit);
|
||||
}
|
||||
|
||||
if(followCANID >= 0) {
|
||||
config.follow(followCANID);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
123
src/main/java/com/team2648/iocore/commons/CommonPIDFConfig.java
Normal file
123
src/main/java/com/team2648/iocore/commons/CommonPIDFConfig.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package com.team2648.iocore.commons;
|
||||
|
||||
public class CommonPIDFConfig {
|
||||
private double p;
|
||||
private double i;
|
||||
private double d;
|
||||
private double s;
|
||||
private double v;
|
||||
private double a;
|
||||
private double cos;
|
||||
|
||||
public CommonPIDFConfig() {
|
||||
this(0, 0, 0);
|
||||
}
|
||||
|
||||
public CommonPIDFConfig(double p, double i, double d) {
|
||||
this(p, i, d, 0);
|
||||
}
|
||||
|
||||
public CommonPIDFConfig(double p, double i, double d, double v) {
|
||||
this(p, i, d, 0, v, 0);
|
||||
}
|
||||
|
||||
public CommonPIDFConfig(double p, double i, double d, double s, double v, double a) {
|
||||
this(p, i, d, s, v, a, 0);
|
||||
}
|
||||
|
||||
public CommonPIDFConfig(double p, double i, double d, double s, double v, double a, double cos) {
|
||||
this.p = p;
|
||||
this.i = i;
|
||||
this.d = d;
|
||||
this.s = s;
|
||||
this.v = v;
|
||||
this.a = a;
|
||||
this.cos = cos;
|
||||
}
|
||||
|
||||
public double getP() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public double getI() {
|
||||
return i;
|
||||
}
|
||||
|
||||
public double getD() {
|
||||
return d;
|
||||
}
|
||||
|
||||
public double getS() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public double getV() {
|
||||
return v;
|
||||
}
|
||||
|
||||
public double getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public double getCos() {
|
||||
return cos;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setP(double p) {
|
||||
this.p = p;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setI(double i) {
|
||||
this.i = i;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setD(double d) {
|
||||
this.d = d;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setS(double s) {
|
||||
this.s = s;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setV(double v) {
|
||||
this.v = v;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setA(double a) {
|
||||
this.a = a;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setCos(double cos) {
|
||||
this.cos = cos;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setPID(double p, double i, double d) {
|
||||
this.p = p;
|
||||
this.i = i;
|
||||
this.d = d;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommonPIDFConfig setSVA(double s, double v, double a) {
|
||||
this.s = s;
|
||||
this.v = v;
|
||||
this.a = a;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.team2648.iocore.enums;
|
||||
|
||||
public enum MotorIdleMode {
|
||||
kCoast,
|
||||
kBrake;
|
||||
}
|
||||
Reference in New Issue
Block a user