The filter is a multiplicative 12-state kinematic GPS-INS EKF. It supports vector observations and GPS position and velocity reports in ECEF or NED coords. I'm a little bit worried about the ability of the filter to be crammed into an STM32, mostly for speed reasons. If I force my old Pentium-M laptop down to a 600 MHz, then I get the following hot-cache timings:
- prediction (gyro and accelerometer measurement): 10 us
- vector measurement (magnetometer): 18 us
- GPS PVT: 24 us
Oddly enough, the GPS PVT runs slower when the position update is performed using rank-one updates, at about 32 us. But on x86-64, using rank-one updates for position is marginally faster. Using rank-one updates in velocity
The filter's ability to reliably converge from an initially unknown state is somewhat strongly dependent on the rate and quality of GPS velocity reports. The velocity report contains a great deal of orientation information in the cross-covariance between the velocity block and the orientation block. 4Hz is barely OK, 10Hz is much better. Likewise, the nonlinearity in the state update (particularly in the relationship between acceleration and orientation) also demands a fast update rate. 100 Hz is barely passable, 250Hz is much better. Likewise for magnetometer readings, 50Hz is good, 25Hz is marginal, and 20 Hz runs a risk of filter divergence.
So, if we assume that the STM32 can get about 1 MFLOP of dp throughput, and that my P-M is producing about 600 MFLOPs (really rough guessing here), then we estimate the following STM32 timings:
- 14 ms for GPS PVT update @ 10 Hz = 140 ms per second
- 6 ms for state prediction @ 100 Hz = 600 ms per second
- 11 ms for vector observation @ 25 Hz = 220 ms per second
That's close to 100% CPU utilization. Now, the aforementioned assumptions are really rough, so that could easily be anywhere from 50-150%, but its close enough for some discomfort. (or close enough to be excited if you're a glass-half-full kindof guy).
By "barely passable" I mean that under 5% of all initial orientations have a state estimate that is greater than 10 sigma away from the true state after six seconds of filtering, with all monte carlo test runs converging and none diverging. Much better is only 2% greater than 10 sigma away, with most less than 4 sigma.
Initial conditions are:
- Random initial orientation
- Random magnetic field orientation
- Gaussian random initial bias, with one sigma bounds of 5 deg/s
- Initial random velocity up to pi rad/s in a randomly chosen rotation axis
- Initial random angular vibration up to pi/2 rad/s at freq chosen over log domain of 10 Hz to 1/20 Hz at another random direction
- Initial random velocity up to 30 m/s in random direction
- Initial random acceleration up to 0.5 G in random direction
Worst-case convergence behavior is observed when the acceleration vector is collinear with the magnetic field. Even under the "barely passable" situations, the filter will always converge to the right orientation as long as the total acceleration vector is not colinear with the earth's magnetic field. After initial convergence, they have to be collinear for a while before the filter drifts too far off.
I hope to open up a bitbucket account this weekend to host the OS code. I think I'm going to have to handle this code very carefully for two reasons:
- The USA has tight export restrictions on this sort of technology, and I must comply with my govt's laws. I'm drawing from the experience of crypto researchers in the late 90's to come to this conclusion: Its one thing to publish generic source code for an algorithm. It's another thing entirely to directly contribute to a complete working autopilot that is principally hosted in another nation, even if that nation is considered a friend.
- In the Great State of NC, what I do on my own time with my own resources is my IP. I am fully employed as an embedded software engineer in an unrelated industry. However, we are also using FreeRTOS on an STM32, so I have to tread carefully here. Contributing to PiOS might be just a little too gray for me, even though it is something that I would like to do.
Therefore, I think that the most appropriate way for me to make this work available to the community is to host it is in the form of an external library. I'll do my best to ensure that the library is written in a way that encourages third-party linkage rather than copy-and-paste, but I don't think that I'll be able to directly submit patches to an autopilot project outside of the US. Besides, from a project management perspective, this makes good sense, since it means that any FOSS autopilot would be able to use the same interface if they so chose. The license with be GPL v3 and no other version. BSD and LGPL are out of the question.



United States
Canada
Germany







