mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Fix potential divide-by-zero in RKDP (#5242)
If f(x, u) has no dynamics, the truncation error can be zero.
This commit is contained in:
@@ -238,7 +238,11 @@ public final class NumericalIntegration {
|
||||
.times(h))
|
||||
.normF();
|
||||
|
||||
h *= 0.9 * Math.pow(maxError / truncationError, 1.0 / 5.0);
|
||||
if (truncationError == 0.0) {
|
||||
h = dtSeconds - dtElapsed;
|
||||
} else {
|
||||
h *= 0.9 * Math.pow(maxError / truncationError, 1.0 / 5.0);
|
||||
}
|
||||
} while (truncationError > maxError);
|
||||
|
||||
dtElapsed += h;
|
||||
|
||||
Reference in New Issue
Block a user