Hello all!
I am gonna preface this by saying that I have very little experience with embedded systems, so bear with me, and don't be afraid to tell me I am going down an stupid rabbit hole. I am interested in learning about the theory behind what is to follow but the would lie to implement this in an efficient manner.
I am looking into learning about sensor fusion for a 6dof or maybe later 9dof imu. Before I start digging into that I though I would lay out the essentials, which I am sure I will need down the road (Bad approach? Let me know!). One big essential is going to be trig functions.
Technical details: I am using and stm32f446 with hardware fpu running at max speed.
Code size really is not limited (but I would rather not implement a lookup table, Again, stupid? Good idea? Lemme know!)
I am looking for relatively fast execution as I will try to run the sensor fusion algorithm at as many kHz as possible
( in all seriousness though, I am looking at 1khz maybe 4khz update rate if at all possible, thats what the sensor can go up to! I can of course scale that down a bit if it is unrealistic!)
My first concern is what degree of precision I will need for my trig functions. I realize this is a little hard to say without a sensor fusion algorithm set, but a ballpark would be a good place to start. I however have no idea what is a good starting point. One decimal? 2? 3? 5? 10?
Then comes the question of how this should be implemented. Should I just use the builtin c sin functions? I hear they are quite bloated. Plus I like the idea of this being a bit of a learning opportunity!
So as mentioned before the first option would be a lookup table. I would really only need to store the values corresponding from zero to pi/2 as the rest could be determined from this quite easily by inverting etc etc. And cosine and tangent are just a phase shift. However this seems to be only a good approach on small devices, while doing integer math. I think (correct me if wrong) that with hardware fpu available this is pointless and outdated.
I have done enough research to realize Taylor series are probably not the right approach (correct me!)
So it seems that with an fpu available my best option would be Chebyshev pilynomails/series (?) And the best book on the topic seems to be John Hart's "Computer Approximations".Firstly this brings me back to my point about accuracy as I will have to determine that if I want to follow that book it seems. Secondly I am more than willing to read the book, however I really don't want to waste my time. Is it worth it? Is there a better approach that is not a book?
Again, am I looking at this problem the wrong way completely and everything above is pointless? I wanna hear it all
E: Sorry for the spelling and grammar above! Typed on mobile....