We have updated to the python code in our git repo.
It now includes;
The elusive Kalman filter.
Math needed when the IMU is upside down
Automatically calculate loop period.
A lot more comments.
What is a Kalman filter? In a nutshell; A Kalman filter is, it is an algorithm which uses a series of measurements observed over time, in this context an accelerometer and a gyroscope. These measurements will contain noise that will contribute to the error of the measurement. The Kalman filter will then try to estimate the state of the system, based on the current and previous states, that tend to be more precise that than the measurements alone.
A Kalman filter is more precise than a Complementary filter. This can be seen in the image below, which is the output of a complementary filter (CFangleX) and a Kalman filter (kalmanX) from the X axis plotted in a graph.
The red line (KalmanX) is better at filtering out noisep;
The code can be found here in our Git repository here
And can be pulled down to your Raspberry Pi with;
Here is a great post by mincepi which shows how to enable VGA output on a Pi Zero for less than $5
The vga666 by Gert is already a low cost VGA output option for the Pi. But we can do better with the Zero! We’ll use 16 bit output instead of 18 bit: this frees up the SPI and I2C ports with little loss in quality. The resistors can be soldered between the Zero and the adapter, making the PCB smaller and eliminating a connector. I’ve determined that 5% resistors are good enough: no need for higher cost 1% units. By not using the middle row of pins in the HD15 connector, we can straddle-mount it on the PCB edge. Finally, the connector can be male, so the Zero will connect to the monitor ChromeCast style: no VGA cable needed. (This connector could even be scrounged from an old VGA monitor cable for free!) If you order the boards from OSHPark, it will cost $4.95 for three copies. Enough resistors and connectors to build three will cost $5.92 from Digi-Key. That works out to $10.87 to build three, or $3.62 each!