mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpimath] Make feedforward classes throw exceptions for negative Kv or Ka (#6084)
This commit is contained in:
@@ -28,12 +28,20 @@ public class ArmFeedforward {
|
||||
* @param kg The gravity gain.
|
||||
* @param kv The velocity gain.
|
||||
* @param ka The acceleration gain.
|
||||
* @throws IllegalArgumentException for kv < zero.
|
||||
* @throws IllegalArgumentException for ka < zero.
|
||||
*/
|
||||
public ArmFeedforward(double ks, double kg, double kv, double ka) {
|
||||
this.ks = ks;
|
||||
this.kg = kg;
|
||||
this.kv = kv;
|
||||
this.ka = ka;
|
||||
if (kv < 0.0) {
|
||||
throw new IllegalArgumentException("kv must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
if (ka < 0.0) {
|
||||
throw new IllegalArgumentException("ka must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,12 +31,20 @@ public class ElevatorFeedforward {
|
||||
* @param kg The gravity gain.
|
||||
* @param kv The velocity gain.
|
||||
* @param ka The acceleration gain.
|
||||
* @throws IllegalArgumentException for kv < zero.
|
||||
* @throws IllegalArgumentException for ka < zero.
|
||||
*/
|
||||
public ElevatorFeedforward(double ks, double kg, double kv, double ka) {
|
||||
this.ks = ks;
|
||||
this.kg = kg;
|
||||
this.kv = kv;
|
||||
this.ka = ka;
|
||||
if (kv < 0.0) {
|
||||
throw new IllegalArgumentException("kv must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
if (ka < 0.0) {
|
||||
throw new IllegalArgumentException("ka must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,11 +21,19 @@ public class SimpleMotorFeedforward {
|
||||
* @param ks The static gain.
|
||||
* @param kv The velocity gain.
|
||||
* @param ka The acceleration gain.
|
||||
* @throws IllegalArgumentException for kv < zero.
|
||||
* @throws IllegalArgumentException for ka < zero.
|
||||
*/
|
||||
public SimpleMotorFeedforward(double ks, double kv, double ka) {
|
||||
this.ks = ks;
|
||||
this.kv = kv;
|
||||
this.ka = ka;
|
||||
if (kv < 0.0) {
|
||||
throw new IllegalArgumentException("kv must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
if (ka < 0.0) {
|
||||
throw new IllegalArgumentException("ka must be a non-negative number, got " + kv + "!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user