wpimath.system functions

wpimath.system.RK4(*args, **kwargs)

Overloaded function.

  1. RK4(f: collections.abc.Callable[[typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”]], typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]], x: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], dt: wpimath.units.seconds) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]

Performs 4th order Runge-Kutta integration of dx/dt = f(x) for dt.

Parameters:
  • f – The function to integrate. It must take one argument x.

  • x – The initial value of x.

  • dt – The time over which to integrate.

  1. RK4(f: collections.abc.Callable[[typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”]], typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]], x: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], u: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], dt: wpimath.units.seconds) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]

Performs 4th order Runge-Kutta integration of dx/dt = f(x, u) for dt.

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.

  • dt – The time over which to integrate.

  1. RK4(f: collections.abc.Callable[[wpimath.units.seconds, typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”]], typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]], t: wpimath.units.seconds, y: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], dt: wpimath.units.seconds) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]

Performs 4th order Runge-Kutta integration of dy/dt = f(t, y) for dt.

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.

  • dt – The time over which to integrate.

wpimath.system.RKDP(*args, **kwargs)

Overloaded function.

  1. RKDP(f: collections.abc.Callable[[typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”]], typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]], x: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], u: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], dt: wpimath.units.seconds, maxError: typing.SupportsFloat | typing.SupportsIndex = 1e-06) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]

Performs adaptive Dormand-Prince integration of dx/dt = f(x, u) for dt.

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.

  • dt – The time over which to integrate.

  • maxError – The maximum acceptable truncation error. Usually a small number like 1e-6.

  1. RKDP(f: collections.abc.Callable[[wpimath.units.seconds, typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”]], typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]], t: wpimath.units.seconds, y: typing.Annotated[numpy.typing.ArrayLike, numpy.float64, “[m, n]”], dt: wpimath.units.seconds, maxError: typing.SupportsFloat | typing.SupportsIndex = 1e-06) -> typing.Annotated[numpy.typing.NDArray[numpy.float64], “[m, n]”]

Performs adaptive Dormand-Prince integration of dy/dt = f(t, y) for dt.

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.

  • dt – The time over which to integrate.

  • maxError – The maximum acceptable truncation error. Usually a small number like 1e-6.

wpimath.system.numericalJacobian(f: collections.abc.Callable[[Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]']], Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']], x: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]']) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']
wpimath.system.numericalJacobianU(f: collections.abc.Callable[[Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], *args], Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']], x: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], u: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], *args) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Returns numerical Jacobian with respect to u for f(x, u, …).

@tparam F Function object type. @tparam Args… Types of remaining arguments to f(x, u, …).

Parameters:
  • f – Vector-valued function from which to compute Jacobian.

  • x – State vector.

  • u – Input vector.

  • args – Remaining arguments to f(x, u, …).

wpimath.system.numericalJacobianX(f: collections.abc.Callable[[Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], *args], Annotated[numpy.typing.NDArray[numpy.float64], '[m, 1]']], x: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], u: Annotated[numpy.typing.ArrayLike, numpy.float64, '[m, 1]'], *args) Annotated[numpy.typing.NDArray[numpy.float64], '[m, n]']

Returns numerical Jacobian with respect to x for f(x, u, …).

@tparam F Function object type. @tparam Args… Types of remaining arguments to f(x, u, …).

Parameters:
  • f – Vector-valued function from which to compute Jacobian.

  • x – State vector.

  • u – Input vector.

  • args – Remaining arguments to f(x, u, …).