00001 /* 00002 * This file is part of the OpenKinect Project. http://www.openkinect.org 00003 * 00004 * Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file 00005 * for details. 00006 * 00007 * This code is licensed to you under the terms of the Apache License, version 00008 * 2.0, or, at your option, the terms of the GNU General Public License, 00009 * version 2.0. See the APACHE20 and GPL2 files for the text of the licenses, 00010 * or the following URLs: 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * http://www.gnu.org/licenses/gpl-2.0.txt 00013 * 00014 * If you redistribute this file in source form, modified or unmodified, you 00015 * may: 00016 * 1) Leave this header intact and distribute it under the same terms, 00017 * accompanying it with the APACHE20 and GPL20 files, or 00018 * 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or 00019 * 3) Delete the GPL v2 clause and accompany it with the APACHE20 file 00020 * In all cases you must keep the copyright notice intact and include a copy 00021 * of the CONTRIB file. 00022 * 00023 * Binary distributions must follow the binary distribution requirements of 00024 * either License. 00025 */ 00026 00027 #include <stdio.h> 00028 #include <stdlib.h> 00029 #include <string.h> 00030 #include <unistd.h> 00031 #include <math.h> 00032 00033 #include "freenect_internal.h" 00034 00035 #define GRAVITY 9.80665 00036 00037 void freenect_get_mks_accel(freenect_raw_device_state *state, double* x, double* y, double* z) 00038 { 00039 //the documentation for the accelerometer (http://www.kionix.com/Product%20Sheets/KXSD9%20Product%20Brief.pdf) 00040 //states there are 819 counts/g 00041 *x = (double)state->accelerometer_x/FREENECT_COUNTS_PER_G*GRAVITY; 00042 *y = (double)state->accelerometer_y/FREENECT_COUNTS_PER_G*GRAVITY; 00043 *z = (double)state->accelerometer_z/FREENECT_COUNTS_PER_G*GRAVITY; 00044 }