Package edu.wpi.first.math.system
Class NumericalIntegration
java.lang.Object
edu.wpi.first.math.system.NumericalIntegration
Numerical integration utilities.
-
Method Summary
Modifier and TypeMethodDescriptionrk4
(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds) Performs 4th order Runge-Kutta integration of dx/dt = f(x, u) for dt.rk4
(BiFunction<Double, Matrix<Rows, Cols>, Matrix<Rows, Cols>> f, double t, Matrix<Rows, Cols> y, double dtSeconds) Performs 4th order Runge-Kutta integration of dx/dt = f(t, y) for dt.static double
rk4
(DoubleBinaryOperator f, double x, double u, double dtSeconds) Performs Runge Kutta integration (4th order).static double
rk4
(DoubleUnaryOperator f, double x, double dtSeconds) Performs Runge Kutta integration (4th order).Performs 4th order Runge-Kutta integration of dx/dt = f(x) for dt.rkdp
(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds) Performs adaptive Dormand-Prince integration of dx/dt = f(x, u) for dt.rkdp
(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds, double maxError) Performs adaptive Dormand-Prince integration of dx/dt = f(x, u) for dt.rkdp
(BiFunction<Double, Matrix<Rows, Cols>, Matrix<Rows, Cols>> f, double t, Matrix<Rows, Cols> y, double dtSeconds, double maxError) Performs adaptive Dormand-Prince integration of dx/dt = f(t, y) for dt.
-
Method Details
-
rk4
Performs Runge Kutta integration (4th order).- Parameters:
f
- The function to integrate, which takes one argument x.x
- The initial value of x.dtSeconds
- The time over which to integrate.- Returns:
- the integration of dx/dt = f(x) for dt.
-
rk4
Performs Runge Kutta integration (4th order).- Parameters:
f
- The function to integrate. It must take two arguments x and u.x
- The initial value of x.u
- The value u held constant over the integration period.dtSeconds
- The time over which to integrate.- Returns:
- The result of Runge Kutta integration (4th order).
-
rk4
public static <States extends Num,Inputs extends Num> Matrix<States,N1> rk4(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds) Performs 4th order Runge-Kutta integration of dx/dt = f(x, u) for dt.- Type Parameters:
States
- A Num representing the states of the system to integrate.Inputs
- A Num representing the inputs of the system to integrate.- Parameters:
f
- The function to integrate. It must take two arguments x and u.x
- The initial value of x.u
- The value u held constant over the integration period.dtSeconds
- The time over which to integrate.- Returns:
- the integration of dx/dt = f(x, u) for dt.
-
rk4
public static <States extends Num> Matrix<States,N1> rk4(UnaryOperator<Matrix<States, N1>> f, Matrix<States, N1> x, double dtSeconds) Performs 4th order Runge-Kutta integration of dx/dt = f(x) for dt.- Type Parameters:
States
- A Num representing the states of the system.- Parameters:
f
- The function to integrate. It must take one argument x.x
- The initial value of x.dtSeconds
- The time over which to integrate.- Returns:
- 4th order Runge-Kutta integration of dx/dt = f(x) for dt.
-
rk4
public static <Rows extends Num,Cols extends Num> Matrix<Rows,Cols> rk4(BiFunction<Double, Matrix<Rows, Cols>, Matrix<Rows, Cols>> f, double t, Matrix<Rows, Cols> y, double dtSeconds) Performs 4th order Runge-Kutta integration of dx/dt = f(t, y) for dt.- Type Parameters:
Rows
- Rows in y.Cols
- Columns in y.- Parameters:
f
- The function to integrate. It must take two arguments t and y.t
- The initial value of t.y
- The initial value of y.dtSeconds
- The time over which to integrate.- Returns:
- the integration of dx/dt = f(x) for dt.
-
rkdp
public static <States extends Num,Inputs extends Num> Matrix<States,N1> rkdp(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds) Performs adaptive Dormand-Prince integration of dx/dt = f(x, u) for dt. By default, the max error is 1e-6.- Type Parameters:
States
- A Num representing the states of the system to integrate.Inputs
- A Num representing the inputs of the system to integrate.- Parameters:
f
- The function to integrate. It must take two arguments x and u.x
- The initial value of x.u
- The value u held constant over the integration period.dtSeconds
- The time over which to integrate.- Returns:
- the integration of dx/dt = f(x, u) for dt.
-
rkdp
public static <States extends Num,Inputs extends Num> Matrix<States,N1> rkdp(BiFunction<Matrix<States, N1>, Matrix<Inputs, N1>, Matrix<States, N1>> f, Matrix<States, N1> x, Matrix<Inputs, N1> u, double dtSeconds, double maxError) Performs adaptive Dormand-Prince integration of dx/dt = f(x, u) for dt.- Type Parameters:
States
- A Num representing the states of the system to integrate.Inputs
- A Num representing the inputs of the system to integrate.- Parameters:
f
- The function to integrate. It must take two arguments x and u.x
- The initial value of x.u
- The value u held constant over the integration period.dtSeconds
- The time over which to integrate.maxError
- The maximum acceptable truncation error. Usually a small number like 1e-6.- Returns:
- the integration of dx/dt = f(x, u) for dt.
-
rkdp
public static <Rows extends Num,Cols extends Num> Matrix<Rows,Cols> rkdp(BiFunction<Double, Matrix<Rows, Cols>, Matrix<Rows, Cols>> f, double t, Matrix<Rows, Cols> y, double dtSeconds, double maxError) Performs adaptive Dormand-Prince integration of dx/dt = f(t, y) for dt.- Type Parameters:
Rows
- Rows in y.Cols
- Columns in y.- Parameters:
f
- The function to integrate. It must take two arguments t and y.t
- The initial value of t.y
- The initial value of y.dtSeconds
- The time over which to integrate.maxError
- The maximum acceptable truncation error. Usually a small number like 1e-6.- Returns:
- the integration of dx/dt = f(x, u) for dt.
-