Skip to content

Commit

Permalink
fixes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil-datla authored Mar 8, 2022
1 parent df52761 commit 0cbdfc5
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/main/java/frc/robot/helper/SmoothVelocity.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package frc.robot.helper;

public class SmoothVelocity {

public void SmoothVelocity() {
}

public static double smoothVelocity(double currentVelocity, double targetVelocity, double acceleration, double time) {
double delta = targetVelocity - currentVelocity;
if (Math.abs(delta) < acceleration) {
return targetVelocity;
} else {
return currentVelocity + Math.signum(delta) * acceleration * time;
}
double currentAcceleration = (targetVelocity - currentVelocity)/time;
return currentVelocity + Math.signum(currentAcceleration) * Math.min(Math.abs(currentAcceleration), acceleration) * time;
}
}

0 comments on commit 0cbdfc5

Please sign in to comment.