wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.08k stars 611 forks source link

Implement Tsitouras 5th order numerical integrator #7123

Open calcmogul opened 1 month ago

calcmogul commented 1 month ago

This issue is a spin-off of https://github.com/wpilibsuite/allwpilib/issues/4373.

The Tsitouras 5th order integration method is 3x more accurate than Dormand-Prince (RKDP). It uses the exact same algorithm with different coefficients.

Section 7.9 of Controls Engineering in FRC has an introduction to the notation of Runge-Kutta methods.

Here's the paper to implement: http://users.uoa.gr/~tsitourasc/RK54_new_v2.pdf

Here's the implementation steps:

  1. Copy-paste the RKDP function(s) to make a new function Tsit5
  2. Update the coefficients of A, b1, and b2 to reflect those in section 3, table 1 of the paper above (A maps to a, b1 maps to b, and b2 maps to b̂)
  3. Update the source location comment in the function
  4. Copy-paste and modify the tests
  5. Replace usages of RKDP with Tsit5
Advay17 commented 3 days ago

If RKDP usages are replaced, should it be deprecated, or are there any other use cases for it?

calcmogul commented 3 days ago

RKDP should be deprecated since Tsit5 is superior in every way.