Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
g4c's avatar
g4c
Explorer
10 years ago

Can anyone help with Kalman filter setup?

Hey All,

I'm devving a multiplayer online shooter for GearVR.

It uses a custom UDP client server system for the online play. Which is all but finished and works well.

At the moment it is running with simple IIR filters to do smoothing/prediction, which is OK but suffers the usual surging etc.

I'm struggling to add Kalman filtering. I've included KFilter in my C++ code:
http://kalman.sourceforge.net/doc/index.html

I have this data in ~10Hz RX packets:


millisecond timestamp of sending client
X position
Y position
Z position
X rotation
Y rotation
Z rotation


The data describes the state of 1 client ship in the match. The ships physics is a rigid body in fluid with low friction with:
Z force applied for thrust.
Z torque applied for roll.
X torque applied for pitch.

I understand how to pre-condition this data stream: make it linear in time of the receiver by interpolation.

But setting up the kalman makes me feel dumb :oops: I would actually find it easier to build and train a small neural net to process the UDP data, but before I try that path... anyone familiar with Kalman that could maybe provide some info or a working example for tracking a body in 3D space?

1 Reply

  • I'm curious why you think you need a Kalman filter? Typically Kalman filters are used to deal with noisy data. There are plenty of resources on the web on the subject, but it is a pretty heavy topic. I would recommend viewing Cyrill Stachniss's online course material on SLAM if you want a somewhat lay-person friendly introduction to the subject, but it is still pretty intense. Here's the playlist: https://www.youtube.com/playlist?list=P ... l3b1JHimN_

    I don't think you need or want a Kalman filter in your network code for your game. If you use an authoritative server (like most games), you should have exact data from the server, so there is nothing for the Kalman filter to estimate. I would recommend interpolation for all entities except the ship under your control for optimal smoothness of rendering, and do prediction / smoothing for your own ship for responsiveness. Of course you may need / want to predict other entities during packet loss / latency spikes as well. You wouldn't want / need a Kalman filter to smooth your ship, as you will still know exactly where to smooth to as soon as you are notified of a mis-prediction. Once that happens, you want to re-predict where you should be this frame (this is completely dependent on your game logic, but it usually involves an exact or approximate re-wind and re-playing of game logic / physics based on control history), and then optionally smooth out the discrepancies over a few frames using a method of choice.