Advertisement
j0h

Xbox360Kinect_Accelorometer

j0h
Jul 8th, 2023
990
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. //xbox 360 kinect  accelorometer
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <termios.h>
  6. #include <fcntl.h>
  7. #include <libfreenect.h>
  8. #include <libfreenect_sync.h>
  9.  
  10. //gcc -Wall -g -o "%e" "%f"  -lfreenect -lfreenect_sync  
  11. double xThresh, yThersh, zThresh =0.0;
  12. void no_kinect_quit(void){
  13.     printf("Error: Kinect not connected?\n");
  14.     exit(1);
  15. }
  16.  
  17. int main(){
  18.     freenect_sync_set_led(4, 0);
  19.     while (1) {
  20.         freenect_raw_tilt_state *state = 0;
  21.         double dx, dy, dz;
  22.         // Get the raw accelerometer values and tilt data
  23.         if (freenect_sync_get_tilt_state(&state, 0)) no_kinect_quit();
  24.         // Get the processed accelerometer values (calibrated to gravity)
  25.         freenect_get_mks_accel(state, &dx, &dy, &dz);
  26.         printf("accel[%lf,%lf,%lf]\n",dx,dy,dz);
  27.         sleep(3);
  28.     }
  29.     return 0;
  30.     }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement