Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit af72c09

Browse files
improve velocity pid move
We still have some things to do, but it should mostly be tuning PID in consideration with the feed forward
1 parent 0532b7a commit af72c09

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • Robot2018/src/org/usfirst/frc/team199/Robot2018/commands

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDMove.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,28 @@ public PIDMove(double target, double[] point, DrivetrainInterface dt, SmartDashb
5959
requires(Robot.dt);
6060
}
6161
double kf = 1 / (dt.getCurrentMaxSpeed() * sd.getConst("Default PID Update Time", 0.05));
62+
63+
System.out.println("proposed p = " + (dt.getPIDMoveConstant() / dt.getCurrentMaxSpeed()));
64+
6265
moveController = new PIDController(sd.getConst("MovekP", 0.1), sd.getConst("MovekI", 0),
6366
sd.getConst("MovekD", 0), kf, avg, this) {
6467
/**
6568
* Move Velocity: V = sqrt(8TGd) / (R*m) where T = max torque of wheels G = gear
6669
* ratio d = distance remaining R = radius of wheels m = mass
6770
*/
71+
// @Override
72+
// protected double calculateFeedForward() {
73+
// double originalFF = super.calculateFeedForward();
74+
// double feedForwardConst = dt.getPIDMoveConstant();
75+
// double error = getError();
76+
// return (Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) +
77+
// originalFF)
78+
// / dt.getCurrentMaxSpeed();
79+
// }
80+
6881
@Override
69-
protected double calculateFeedForward() {
70-
double originalFF = super.calculateFeedForward();
71-
double feedForwardConst = dt.getPIDMoveConstant();
72-
double error = getError();
73-
return (Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) + originalFF)
74-
/ dt.getCurrentMaxSpeed();
82+
protected double getContinuousError(double error) {
83+
return Math.signum(error) * Math.sqrt(Math.abs(super.getContinuousError(error)));
7584
}
7685
};
7786
sd.putData("Move PID", moveController);

0 commit comments

Comments
 (0)