I need to find the angle of rotation (please see the picture) when the round plate is turning. I actually need only one angle of rotation, but with data obtained through Sensors2OSC from Samsung Galaxy S4. This app enables me to receive Accelerometer and Gyroscope float data to processing over OSC. The phone is mounted on the back of plate..
https://github.com/SensorApps/Sensors2OSC
Which method provides the most accurate result, which sensors I have to use for sensor fusion??
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
LowPass lp;
float number1 = 0.0;
void setup() {
size(1200, 600, P3D);
oscP5 = new OscP5(this, 9000);
lp = new LowPass(10); //The argument is the FIFO queue length
}
void draw() {
background(0);
lights();
pushMatrix();
translate(300, height/2, -100);
rotateZ(-number1);
box(330, 200, 40);
popMatrix();
pushMatrix();
translate(900, height/2, -100);
lp.input(number1);
rotateZ(lp.output);
box(330, 200, 40);
popMatrix();
}
/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
if ( theOscMessage.addrPattern().equals("/rotationvector/z") );
number1 = theOscMessage.get(0).floatValue();
}
class LowPass {
ArrayList buffer;
int len;
float output;
LowPass(int len) {
this.len = len;
buffer = new ArrayList(len);
for (int i = 0; i < len; i++) {
buffer.add(new Float(0.0));
}
}
void input(float v) {
buffer.add(new Float(v));
buffer.remove(0);
float sum = 0;
for (int i=0; i<buffer.size (); i++) {
Float fv = (Float)buffer.get(i);
sum += fv.floatValue();
}
output = sum / buffer.size();
}
}