func_count6.m 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. function [step,up_flag] = func_count6(front,back,up_flag,acc)
  2. global front_flag;
  3. global back_flag;
  4. global FrontLiftPoint;
  5. global BackLiftPoint;
  6. global FrontDownPoint;
  7. global BackDownPoint;
  8. global counter;
  9. %global FrontHighPoint;
  10. %global FrontLowPoint;
  11. %global BackHighPoint;
  12. %global BackLowPoint;
  13. global SD;
  14. global accl;
  15. k = length(front);
  16. queue_front(2) = front(k);
  17. queue_front(1) = front(k-1);
  18. queue_back(2) = back(k);
  19. queue_back(1) = back(k-1);
  20. if queue_front(2)-queue_front(1)>=0
  21. FrontDownPoint = queue_front(2);
  22. else
  23. FrontLiftPoint = queue_front(2);
  24. end
  25. if queue_back(2)-queue_back(1)>=0
  26. BackDownPoint = queue_back(2);
  27. else
  28. BackLiftPoint = queue_back(2);
  29. end
  30. acc_flag = 0;
  31. for i=1:1:2
  32. if abs(acc(i)-2000)>100
  33. acc_flag = acc_flag+1;
  34. end
  35. end
  36. %¼ÆËã¼ÓËٶȷ½²î
  37. MV = (acc(1)+acc(2))/2;
  38. D = 0;
  39. for i=1:1:2
  40. D = D + (acc(i) - MV)^2;
  41. end
  42. D = D/2;
  43. SD = sqrt(D);
  44. %%%%%%%%%%%%%%%%%
  45. if (queue_front(2)-FrontLiftPoint>2500)
  46. front_flag = 1;
  47. end
  48. if (queue_front(2)-FrontDownPoint<-1000)
  49. front_flag = 0;
  50. end
  51. if (queue_back(2)-BackLiftPoint>2500)
  52. back_flag = 1;
  53. end
  54. if queue_back(2)-BackDownPoint<-1000
  55. back_flag = 0;
  56. end
  57. if up_flag == 0
  58. if (front_flag==1||back_flag==1)
  59. step=1;
  60. up_flag = 1;
  61. accl = 100000;
  62. counter = 0;
  63. else
  64. step = 0;
  65. up_flag = 0;
  66. end
  67. else
  68. counter = counter+1;
  69. step = 0;
  70. if (abs(acc(3)-2000)<350)
  71. accl = acc(3);
  72. end
  73. if counter>2
  74. if (acc(3)-accl>1000)&&(accl~=100000)
  75. up_flag = 0;
  76. else
  77. up_flag = 1;
  78. end
  79. end
  80. end
  81. end