test_DOWN.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. clear all;
  2. close all;
  3. load imu_data1;
  4. gyr_data = imu_data(1:3,:);
  5. press_raw_data = imu_data(4,:);
  6. press_data = (imu_data(4,:)-9000000*ones(1,size(gyr_data,2)))*0.0000005;
  7. last_move_index = 0;
  8. zupt = zeros(1,size(gyr_data,2));
  9. press_zupt = 0;
  10. mutex_up = 0;
  11. mutex_down =0;
  12. press_index = 0;
  13. down_pass1 = 0;
  14. down_pass2 = 0;
  15. for i = 1:size(gyr_data,2)
  16. if(norm(gyr_data(:,i)) > 1.0)
  17. last_move_index = i;
  18. end
  19. if(i> 6 && press_raw_data(1, i) - min(press_raw_data(1, i-6:i-1)) > 100000 )
  20. press_zupt = 1;
  21. zupt(i) = 1;
  22. press_index = i;
  23. if(down_pass1==2)
  24. down_pass1 = 0;
  25. end
  26. if(abs(gyr_data(2,i)) > 1.5)
  27. down_pass1 = 1;
  28. end
  29. elseif(i> 6 && press_raw_data(1, i) - max(press_raw_data(1, i-6:i-1)) < -100000)
  30. zupt(i) = 2;
  31. if(down_pass2==2)
  32. down_pass2 = 0;
  33. end
  34. if(abs(gyr_data(2,i)) > 1.5)
  35. down_pass2 = 1;
  36. end
  37. elseif(i > 1 && zupt(i-1)== 2 )
  38. if(down_pass1 == 0 && down_pass2 == 0 )
  39. zupt(i) = 3;
  40. end
  41. down_pass1 = 2 ;
  42. down_pass2 = 2 ;
  43. end
  44. end
  45. index = find(zupt ==1);
  46. figure;
  47. hold on
  48. plot(gyr_data(1,:),'r-')
  49. plot(gyr_data(2,:),'g-')
  50. plot(gyr_data(3,:),'b-')
  51. plot(press_data(1,:),'m-')
  52. plot(index,press_data(1,index),'ko')
  53. index = find(zupt == 2);
  54. plot(index,press_data(1,index),'ro')
  55. index = find(zupt == 3);
  56. plot(index,press_data(1,index),'k*')
  57. grid on
  58. axis on
  59. figure
  60. hold on
  61. plot(press_data(1,:),'r-')
  62. grid on
  63. axis on