mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 08:38:02 -06:00
;;;;
This commit is contained in:
@@ -8,52 +8,46 @@ import edu.wpi.first.wpilibj2.command.CommandBase;
|
|||||||
import frc4388.utility.Gains;
|
import frc4388.utility.Gains;
|
||||||
|
|
||||||
public abstract class PelvicInflamitoryDisease extends CommandBase {
|
public abstract class PelvicInflamitoryDisease extends CommandBase {
|
||||||
protected Gains gains;
|
;;;;protected Gains gains;
|
||||||
private double output = 0;
|
;;;;private double output = 0;
|
||||||
|
|
||||||
/** Creates a new PelvicInflamitoryDisease. */
|
;;;;/** Creates a new PelvicInflamitoryDisease. */
|
||||||
public PelvicInflamitoryDisease(double kp, double ki, double kd, double kf) {
|
;;;;public PelvicInflamitoryDisease(double kp, double ki, double kd, double kf) {
|
||||||
gains = new Gains(kp, ki, kd, kf, 0);
|
;;;;;;;;gains = new Gains(kp, ki, kd, kf, 0);
|
||||||
}
|
;;;;}
|
||||||
|
|
||||||
public PelvicInflamitoryDisease(Gains gains) {
|
;;;;public PelvicInflamitoryDisease(Gains gains) {
|
||||||
this.gains = gains;
|
;;;;;;;;this.gains = gains;
|
||||||
}
|
;;;;}
|
||||||
|
|
||||||
/** produces the error from the setpoint */
|
;;;;/** produces the error from the setpoint */
|
||||||
public abstract double getError();
|
;;;;public abstract double getError();
|
||||||
/** figure it out bitch */
|
;;;;/** figure it out bitch */
|
||||||
public abstract void runWithOutput(double output);
|
;;;;public abstract void runWithOutput(double output);
|
||||||
|
|
||||||
// Called when the command is initially scheduled.
|
;;;;// Called when the command is initially scheduled.
|
||||||
@Override
|
;;;;@Override public void initialize() {
|
||||||
public void initialize() {
|
;;;;;;;;output = 0;
|
||||||
output = 0;
|
;;;;}
|
||||||
}
|
|
||||||
|
|
||||||
private double prevError, cumError = 0;
|
;;;;private double prevError, cumError = 0;
|
||||||
// Called every time the scheduler runs while the command is scheduled.
|
;;;;// Called every time the scheduler runs while the command is scheduled.
|
||||||
@Override
|
;;;;@Override public void execute() {
|
||||||
public void execute() {
|
;;;;;;;;double error = getError();
|
||||||
double error = getError();
|
;;;;;;;;cumError += error * .02; // 20 ms
|
||||||
cumError += error * .02; // 20 ms
|
;;;;;;;;double delta = error - prevError;
|
||||||
double delta = error - prevError;
|
|
||||||
|
|
||||||
output = error * gains.kP;
|
;;;;;;;;output = error * gains.kP;
|
||||||
output += cumError * gains.kI;
|
;;;;;;;;output += cumError * gains.kI;
|
||||||
output += delta * gains.kD;
|
;;;;;;;;output += delta * gains.kD;
|
||||||
output += gains.kF;
|
;;;;;;;;output += gains.kF;
|
||||||
|
|
||||||
runWithOutput(output);
|
;;;;;;;;runWithOutput(output);
|
||||||
}
|
;;;;}
|
||||||
|
|
||||||
// Called once the command ends or is interrupted.
|
;;;;// Called once the command ends or is interrupted.
|
||||||
@Override
|
;;;;@Override public void end(boolean interrupted) {}
|
||||||
public void end(boolean interrupted) {}
|
|
||||||
|
|
||||||
// Returns true when the command should end.
|
;;;;// Returns true when the command should end.
|
||||||
@Override
|
;;;;@Override public boolean isFinished() { return false; }
|
||||||
public boolean isFinished() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user