Today I was programming my IMU (again, IMU means Inertial Measurement Unit) so that I can poorly estimate the attitude (attitude is a fancy name for orientation, or which direction the IMU is pointing at) using only the gyros. I said poorly because the signal is full of noise and there is something called bias, which is kind of an almost constant value that pollutes the signal, therefore is common to use different sensors together with the gyros and complicated algorithms to solve the problem. But anyway, as I was saying, I was programming my IMU in python (the programming language, not the snake!) using my Raspberry pi (before you ask what is a Raspberry pi, google it (no, I’m not calling you a moron this time, although you deserve it!)) and I figure out I must have screwed up somewhere in the algorithm, cause the resulting attitude quaternion is showing nonsensical values! I know what you are thinking right now: “What the fuck is a quaternion?” I’m going to dedicate a whole paragraph for those who mentally asked that question. If you already know what a quaternion is, you may skip the following paragraph, I don’t fucking care!
It was in 1843 that the Irish mathematician William Rowan Hamilton decided that it was too easy to operate with complex numbers possessing only one imaginary term, so he decided to add two more imaginary terms, creating the quaternion and fucking with my life! So a quaternion is a hipercomplex number with one real term and three imaginary terms. Before someone asks why the hell would someone create such an abomination (besides to screw me up), quaternions are used to mathematically rotate vectors in 3D space. They are an alternative to the well known (and equally fucked up) rotation matrices, having the advantage of not possessing singularity configurations, also called gimbal lock configurations (wikipedia is there for you!).
As I was saying, my attitude quaternion is behaving badly in the tests I’ve made. By my calculations, if I rotate the IMU 180º around one of the three basic axis (x, y or z), the real part of the quaternion must go from 1 to 0, approximately. What is happening is that, after the 180º rotation, the real part is reduced only by about 0.2. So either there is some stupid mistake fucking up my code, or my calculations are wrong. Either way, I’m too tired to find the mistake, so I will leave it for another day. See you next log.
No comments:
Post a Comment