33 #include "freenect_internal.h"
34 #define GRAVITY 9.80665
36 int freenect_get_raw_accelerometers(
freenect_device *dev, int16_t* x, int16_t* y, int16_t* z)
38 unsigned char buf[10];
40 int ret = fnusb_control(&dev->usb_motor, 0xC0, 0x32, 0x0, 0x0, buf, 10);
42 printf(
"Error in accelerometer reading, libusb_control_transfer returned %d\n", ret);
44 ux = ((uint16_t)buf[2] << 8) | buf[3];
45 uy = ((uint16_t)buf[4] << 8) | buf[5];
46 uz = ((uint16_t)buf[6] << 8) | buf[7];
54 int freenect_get_mks_accelerometers(
freenect_device *dev,
double* x,
double* y,
double* z)
59 int ret = freenect_get_raw_accelerometers(dev,&ix,&iy,&iz);
61 *x = (double)ix/FREENECT_COUNTS_PER_G*GRAVITY;
62 *y = (double)iy/FREENECT_COUNTS_PER_G*GRAVITY;
63 *z = (double)iz/FREENECT_COUNTS_PER_G*GRAVITY;