I'm simulating a simple cart-pendulum system for purposes of testing different control strategies and data-driven approaches. I need to simulate the dynamical system one time-step at a time.
I'm trying to make the simulation as realistic as possible (non-linear, with disturbances and noise etc.)
At the moment I'm just using the Euler method:
y_dot = cartpend_dydt(t, y) # Simple state update (Euler method) y += tau*y_dot
y_dot is the time-derivative of y, the state-vector (length 4) and tau is the time-step.
Since it's a very fast calculation I can run at 50 steps/second and so I'm sure Euler method is accurate enough.
But what if I want to reduce the sample efficiency to say 10 steps/second (more typical real-world scenario)?
Then I assume I should do something more accurate (and a bit more computationally expensive) each time step. But what's 'the next step up' from Euler?
I tried using a numerical integrator (in Python):
from scipy.integrate import solve_ivp sol = solve_ivp(cartpend_dydt, [t, t + tau], y) y = sol.y[:, 1]
cartpend_dydt(t, y) is a function that returns the time derivative of y.
scipy.integrate.solve_ivp is an "explicit Runge-Kutta method of order 5(4)" by default.
But is this over-kill for a relatively short time-step? Is there a simpler method that would be better than Euler but not too computationally intensive?