I am trying to compute the angle of a leg instantaneously regarding an initial position using accelerometer readings.
As I approached this, I decided I needed to record an averaged gravity vector and compute some angle between my current reading and that.
Theoretically it seems plausible: the reading of gravity is different on each position of the leg, so in stationary positions the readings should converge to a vector I can use to find the angular displacement of the leg, with respect to the reading at the start.
However, I have tried several combinations: the angle between both vectors using only the Z and Y components (using this); compute the difference vector between both gravity and current, and do atan2(dY,SQRT(dX^2+dZ^2)); compute atan2(dY,dz)... (where dY and dZ are the subtraction of the current and gravity vector for the Y and Z components, respectively)
None of these solutions seem to be working, so I am wondering if I can even do this.
Does anyone have a solution for this?