import serial import numpy as np ser = serial.Serial('/dev/ttyACM1',9600) def fn(): while True: try: data = ser.readline().split(' ') global_down = np.array(data[0:3],dtype = np.float) mag_down = np.linalg.norm(global_down) global_down /= mag_down global_north = np.array(data[6:9],dtype = np.float) mag_north = np.linalg.norm(global_north) global_north /= mag_north print np.arccos(np.dot(global_north,global_down))*180/np.pi except Exception,e: print e
My understanding is that the vector from 3 axis compass points in the direction of the magnetic field and the vector from 3 axis accelerometer points in the direction of acceleration due to gravity. Since both these are constant, shouldn't the angle between them also be constant.
But, when you use a measurement device to measure the north/south field, the 'vector' RELATIVE to an initial reference measurement direction will certainly change if you rotate your measurement device.
In other words..... relative to your initial reference direction, a 3-d cartesian coordinate measurement of 1,0,0 is clearly different from a measurement of 0,1,0. Although, we know that your measurement device still tells you which way 'north' is.
Now, what I'm calculating is the relative position of these two bulbs. So, no matter how I tilt or move my head, the relative position of these two bulbs should not change. This is what I don't understand. Thanks.
Even after considering all these factors, I can't explain why there is so much variation in the angles I calculated. I could share the raw values and the angles calculated if that would help.They from as low as 30 to about 120. And if I hold the board at one position, the angles don't jump around much.Thanks.