jti107
jti107

Reputation: 159

runga kutta integration with sensor data

Had a question regarding numerical integration with Runga Kutta (RK2). Suppose I have sensor data that provide me with x,y position and velocities. Based on the current vehicle state I need to find out where the vehicle will be at a certain time.

Using a simple euler method I can do something like this

x(1) = 10;
y(1) = 5;
xdot = 2;
ydot = 1;
dt = 0.1

for i = 1:100
   x(i+1) = x(i) + dt*xdot
   y(i+1) = y(i) + dt*ydot
   t(i+1) = t(i) + dt

   if(t(i+1) >= 5)
      break
end

However I've read that Euler is numerically unstable and its better to use RK based methods. So I was taking a look at a RK4 implementation but I'm confused about how the time interval is being split. So for a RK2 method I conceptually understand its trying to do this. this

So my question is this: How would I implement something like this for my application? The only thing I can think of is, if I have 10Hz data run the computation at 1 Hz and use the 1st, 5th and 10th frame to compute the RK2 coefficients. Am I going about this the right way?

Upvotes: 1

Views: 858

Answers (1)

Thomas Hardin
Thomas Hardin

Reputation: 236

RK is not suitable for this problem; the problem you described is simply integrating x'(t) over discrete samples. If your timesteps are evenly spaced and you expect the path of the vehicle to be fairly smooth relative to the sample rate, Adams-Moulton methods would work well (this is an example of the multistep methods mentioned by @LutzL; see https://en.wikipedia.org/wiki/Linear_multistep_method). If you wanted to predict the position of the vehicle at the next timestep, you would want to use an Adams-Bashforth multistep method. Alternatively, you could simply opt for the trapezoidal or Simpson's rule, both of which are higher-order than Euler's method.

Upvotes: 2

Related Questions