shiffman/libfreenect — Issue #19: Accelerometer access
Author: orgicus
Created: 2011-11-26 04:08:41+00:00
State: open

Hello Daniel,

Thanks for sharing the source.
I've noticed that there is an interface to the accelerometer already, but no access to it, so I've tried to change the Kinect class to fix that.

I've created a PVector instance to store x,y,z values into, implemented the Acceleration interface, and made a getter for the PVector instance. Couldn't use the .jar in eclipse:

```
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: /Users/george/Documents/eclipse/KinectTest/lib/user/openkinect/libKinect.jnilib: no suitable image found. Did find: /Users/george/Documents/eclipse/KinectTest/lib/user/openkinect/libKinect.jnilib: mach-o, but wrong architecture
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1742)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.openkinect.Context.(Context.java:43)
at org.openkinect.processing.Kinect.start(Kinect.java:43)
at kinecttest.KinectTest.setup(KinectTest.java:26)
at processing.core.PApplet.handleDraw(PApplet.java:1866)
at processing.core.PApplet.run(PApplet.java:1788)
at java.lang.Thread.run(Thread.java:680)
quitting
java.lang.NullPointerException
at org.openkinect.processing.Kinect.quit(Kinect.java:152)
at kinecttest.KinectTest.stop(KinectTest.java:81)
at sun.applet.AppletPanel.run(AppletPanel.java:525)
at java.lang.Thread.run(Thread.java:680)
```
but it did run in Processing though. I've was printing the PVector values via the getAcceleration() method I added, but it was always [0.0,0.0,0.0]. I've added a trace in the direction() method itself(from Acceleration interface) to check, and it wasn't called. I thought I did the implementation wrong and did this basic test:
```
device.acceleration(new Acceleration()
{
public void direction(float x, float y, float z)
{
System.out.printf("Acceleration: %f %f %f\n", x ,y ,z);
}
});
```
Still no joy. The think that puzzles me is why doesn't the onAcceleration() method get called, because I've added print statements there too:
```
void onAcceleration(float x, float y, float z)
{
System.out.printf("Device onAcceleration: %f %f %f\n", x ,y ,z);
if (acceleration != null)
{
acceleration.direction(x, y, z);
}
}
```

Any tips/clues would be very helpful. Thank you for your time !

Have a brilliant day,
George