leon 1 anno fa
parent
commit
d3d144d842
44 ha cambiato i file con 984 aggiunte e 1373 eliminazioni
  1. BIN
      .DS_Store
  2. BIN
      DanceGame/.DS_Store
  3. 1 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/UI/DebugView/DebugView.mm
  4. BIN
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/.DS_Store
  5. 7 27
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/BuildHouse.h
  6. 3 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/H5_Game.h
  7. 1 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/RunGame.h
  8. 3 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/Tricycle.h
  9. 3 0
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/online_motion.h
  10. 1 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/pub.h
  11. 32 12
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/Aerobics.cpp
  12. 152 499
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/BuildHouse.cpp
  13. 22 22
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/FootStep.cpp
  14. 23 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/H5_Game.cpp
  15. 40 21
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/RunGame.cpp
  16. 24 1
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/Tricycle.cpp
  17. 121 78
      DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/online_motion.cpp
  18. 0 2
      DanceGame/Info.plist
  19. 12 24
      DanceGame/Unity-iPhone.xcodeproj/project.pbxproj
  20. BIN
      DanceGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate
  21. BIN
      Paoku_ios_20220923/.DS_Store
  22. 3 1
      Paoku_ios_20220923/Classes/SDK/BLE/BTDataProcess.mm
  23. 1 1
      Paoku_ios_20220923/Classes/SDK/UI/DebugView/DebugView.mm
  24. BIN
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/.DS_Store
  25. 6 29
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/BuildHouse.h
  26. 1 0
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/RunGame.h
  27. 3 0
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/Tricycle.h
  28. 24 0
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/online_motion.h
  29. 1 1
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/pub.h
  30. 25 19
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Aerobics.cpp
  31. 128 521
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/BuildHouse.cpp
  32. 22 22
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/FootStep.cpp
  33. 5 0
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Kongfu.cpp
  34. 48 21
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/RunGame.cpp
  35. 24 1
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Tricycle.cpp
  36. 197 51
      Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/online_motion.cpp
  37. 18 0
      Paoku_ios_20220923/Classes/UnityAppController.mm
  38. 2 2
      Paoku_ios_20220923/Info.plist
  39. 14 14
      Paoku_ios_20220923/Unity-iPhone.xcodeproj/project.pbxproj
  40. BIN
      Paoku_ios_20220923/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate
  41. BIN
      Tricycle/.DS_Store
  42. 14 1
      Tricycle/Classes/SDK/BLE/BTDataProcess.mm
  43. 3 0
      Tricycle/Unity-iPhone.xcodeproj/project.pbxproj
  44. BIN
      Tricycle/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate

BIN
.DS_Store


BIN
DanceGame/.DS_Store


+ 1 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/UI/DebugView/DebugView.mm

@@ -308,7 +308,7 @@ static DebugView* instance = nil;
         if (total > 30){
             NSLog(@"getGameDataStr 丢包 ================================>> %d",total);
             dispatch_async(dispatch_get_main_queue(), ^{
-                AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
+//                AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
 //                [PopupView showCusHUDA:[NSString stringWithFormat:@"丢包数: %d",total]];
             });
         }

BIN
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/.DS_Store


+ 7 - 27
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/BuildHouse.h

@@ -5,11 +5,6 @@
 
 using namespace std;
 
-struct dualPressData {
-	int left_press;
-	int right_press;
-	int time;
-};
 
 struct dualAccData {
 	int left_acc;
@@ -22,39 +17,24 @@ class BuildHouse: public PublicSDKMotion {
 	int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_front_press, int left_back_press,
 		int jump, int down, int rssi);
 
-	deque<dualPressData> front_press;
-	deque<dualPressData> back_press;
-
-	deque<dualPressData> front_press_left;
-	deque<dualPressData> front_press_right;
-
-	deque<dualPressData> dual_press_front;
-	deque<dualPressData> dual_press_back;
-
-	deque<dualPressData> dual_press_front_for_back_down;
 
 	deque<dualAccData> dual_acc;
 
-	int refuse_down_motion_time = 0;
+	deque<int> left_press_filter_window;
+	deque<int> right_press_filter_window;
+
+	deque<int> left_front_press_queue;
+	deque<int> left_back_press_queue;
 
-	int down_count = 0;
+	deque<int> right_front_press_queue;
+	deque<int> right_back_press_queue;
 
 	int last_down = 0;
 	int last_front_down = 0;
 
-	int front_wait_500 = 0;
-
-	int back_wait_1000 = 0;
 
 	int cmd_wait_time = 0;
 
-	int front_down_cmd_wait_time = 0;
-
-	int back_down_cmd_wait_time = 0;
-
-	int front_down_continue_time = 0;
-
-	int back_down_continue_time = 0;
 
 	int left_front_press_top = 0;
 	int right_front_press_top = 0;

+ 3 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/H5_Game.h

@@ -26,4 +26,7 @@ private:
 	int valid_down_wait_time;
 	int valid_jump_wait_time;
 
+	deque<int> left_front_press_deque;
+	deque<int> right_front_press_deque;
+
 };

+ 1 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/RunGame.h

@@ -34,6 +34,7 @@ private:
 	int down_count;
 
 	int last_down;
+	int last_canva_down;
 	int last_jump;
 
 	int down_wait_after_jump;

+ 3 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/Tricycle.h

@@ -46,4 +46,7 @@ private:
 
 	int prop_status;
 
+	deque<int> left_acc_z_queue;
+	deque<int> right_acc_z_queue;
+
 };

+ 3 - 0
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/online_motion.h

@@ -23,6 +23,9 @@ private:
 	deque<int> right_front_mag_queue;
 	deque<int> left_front_mag_queue;
 
+	deque<int> right_front_mag_canve_queue;
+	deque<int> left_front_mag_canve_queue;
+
 	deque<int> left_front_acc;
 	deque<int> right_front_acc;
 

+ 1 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/include/pub.h

@@ -43,7 +43,7 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.5.46"
+#define GAME_VERSION "0.5.51"
 
 enum CMD_MOTION
 {

+ 32 - 12
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/Aerobics.cpp

@@ -62,11 +62,14 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 	down = 0;
 
-	if (extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+	/*if (extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
 		right_acc, left_acc))
 	{
 		down = 1;
-	}
+	}*/
+
+	down = extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
 
 	if (left_shoes_data_vector.size() == 1 && left_shoes_data_vector.back().zupt)
 	{
@@ -82,11 +85,11 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	//设置单脚的空中命令状态,使得命令在空中只判断一次,区别于触地才能触发的命令。
 
 	//如果触发了抬脚命令,那么触地的时候,将不会触发下端,用一个禁止下蹲倒计来计时
-	if ((left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 1 && lift_left_status == 0)
+	/*if ((left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 1 && lift_left_status == 0)
 		||(right_step_data_vector.size() > 1 && right_step_data_vector.front().zupt == 1 && right_step_data_vector.back().zupt == 1 && lift_right_status == 0))
 	{
 		ResetDenyDownTime(time_stamp);
-	}
+	}*/
 
 	if (left_zupt)
 	{
@@ -125,14 +128,14 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	left_acc_deque.push_back(left_acc[2]);
 	right_acc_deque.push_back(right_acc[2]);
 
-	if (left_acc_deque.size() > 5)
+	if (left_acc_deque.size() > 10)
 	{
 		left_acc_deque.pop_front();
 		right_acc_deque.pop_front();
 	}
 
 	int acc_valid = 0;
-	if (left_acc_deque.size() == 5)
+	if (left_acc_deque.size() == 10)
 	{
 		int left_max_val = *(std::max_element(left_acc_deque.begin(), left_acc_deque.end()));
 		int left_min_val = *(std::min_element(left_acc_deque.begin(), left_acc_deque.end()));
@@ -148,31 +151,48 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	}
 	//std::cout << "time_stamp : " << time_stamp << endl;
 	//if (last_down == 0 && down == 1 && isValidDown(time_stamp))
-	if (last_down == 0 && down == 1 && wait_down == 0)
+	//if (last_down == 0 && down != 0 && wait_down == 0 && deny_down_time == 0)
+	if (last_down == 0 && down != 0 && deny_down_time == 0)
 	{
-		//统计步数
-		//addMotionCount(DOWN_COUNT);
+		if (down & 0x04)
+		{
+			addMotionCount(DOWN_COUNT);
 
-		//std::cout << "normal down motion" << endl;
-		//result[0] = MOTION_DOWN;
+			std::cout << "normal down motion" << endl;
+			result[0] = MOTION_DOWN;
+			wait_down = 0;
+			deny_down_time = 20;
+		}
+		else if(wait_down == 0 && deny_down_time == 0)
+		{
+			wait_down = 10;
+			deny_down_time = 20;
+		}
 
-		wait_down = 10;
 		
 	}
 
 	if (wait_down == 1 && acc_valid == 1)
+	//if (wait_down == 1 )
 	//if(down)
 	{
 		addMotionCount(DOWN_COUNT);
 
 		std::cout << "normal down motion" << endl;
 		result[0] = MOTION_DOWN;
+
+		deny_down_time = 20;
 	}
 
 	if (wait_down > 0)
 	{
 		wait_down--;
 	}
+
+	if (deny_down_time > 0 && down == 0)
+	{
+		deny_down_time--;
+	}
 	
 	//判断踮脚蹲
 	if (left_att[1] * 0.0001f > 0.1f && right_att[1] * 0.0001f > 0.1f && down == 1)

+ 152 - 499
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/BuildHouse.cpp

@@ -2,63 +2,6 @@
 
 #include "BuildHouse.h"
 
-bool isUpDeque(deque<dualPressData>& dual_press,int &min_index, int deque_size)
-{
-	if (dual_press.size() != deque_size)
-	{
-		return false;
-	}
-
-	int max_left_val = dual_press.front().left_press;
-	int max_right_val = dual_press.front().right_press;
-
-	int max_left_index = 0;
-	int max_right_index = 0;
-
-	int min_left_val = dual_press.front().left_press;
-	int min_right_val = dual_press.front().right_press;
-
-	int min_left_index = 0;
-	int min_right_index = 0;
-
-
-	for (int i = 0; i < dual_press.size(); i++)
-	{
-		if (max_left_val < dual_press[i].left_press)
-		{
-			max_left_val = dual_press[i].left_press;
-			max_left_index = i;
-		}
-		if (max_right_val < dual_press[i].right_press)
-		{
-			max_right_val = dual_press[i].right_press;
-			max_right_index = i;
-		}
-
-		if (min_left_val > dual_press[i].left_press)
-		{
-			min_left_val = dual_press[i].left_press;
-			min_left_index = i;
-		}
-		if (min_right_val > dual_press[i].right_press)
-		{
-			min_right_val = dual_press[i].right_press;
-			min_right_index = i;
-		}
-
-	}
-
-	if (max_left_val - min_left_val > 50 && max_left_index > min_left_index &&
-		max_right_val - min_right_val > 50 && max_right_index > min_right_index)
-	{
-		min_index = max(min_left_index, min_right_index);
-
-		return true;
-	}
-
-	return false;
-}
-
 bool isValidAcc(deque<dualAccData>& dual_acc, int start_index,  int thresh_hold)
 {
 	int left_max_val = dual_acc[start_index].left_acc;
@@ -97,129 +40,21 @@ bool isValidAcc(deque<dualAccData>& dual_acc, int start_index,  int thresh_hold)
 	return false;
 }
 
-int isUptrendDeque(deque<dualPressData> &dual_press_front,int deque_size)
-{
-	int min_index = deque_size - 1;
-
-
-
-	if (deque_size > 4)
-	{
-		while (min_index > 3)
-		{
-			if ((dual_press_front[min_index].left_press < dual_press_front[min_index - 1].left_press
-				|| dual_press_front[min_index].left_press < dual_press_front[min_index - 2].left_press
-				|| dual_press_front[min_index].left_press < dual_press_front[min_index - 3].left_press) &&
-				(dual_press_front[min_index].right_press < dual_press_front[min_index - 1].right_press
-					|| dual_press_front[min_index].right_press < dual_press_front[min_index - 2].right_press
-					|| dual_press_front[min_index].right_press < dual_press_front[min_index - 3].right_press))
-			/*	&& dual_press_front[min_index].left_press > 10000
-				&& dual_press_front[min_index].right_press > 10000)*/
-			{
-				min_index--;
-			}
-			else
-			{
-				break;
-			}
-		}
 
-		if(  dual_press_front[deque_size - 1].left_press - dual_press_front[min_index].left_press < -2000
-			&& dual_press_front[deque_size - 1].right_press - dual_press_front[min_index].right_press < -2000)
-		{
 
-			return 1;
-		}
-	}
-	
-
-	return 0;
-}
 
-void setUptrendDequeFront(deque<dualPressData>& dual_press_front, deque<dualPressData>& front_press_left, deque<dualPressData>& front_press_right, int deque_size)
-{
-	if (dual_press_front.size() == deque_size)
-	{
-		int left_min_index = 0, left_max_index = 0;
-		int right_min_index = 0, right_max_index = 0;
-
-		int left_min_press = dual_press_front.front().left_press;
-		int right_min_press = dual_press_front.front().right_press;
-		
-		int left_max_press = left_min_press, right_max_press = right_min_press;
-		int i = 0;
-		std::for_each(dual_press_front.begin(), dual_press_front.end(), [&](dualPressData value) {
-			if (left_min_press > value.left_press) {
-				left_min_index = i; left_min_press = value.left_press;
-			}
-			if (right_min_press > value.right_press) {
-				right_min_index = i; right_min_press = value.right_press;
-			}
-			if (left_max_press < value.left_press) {
-				left_max_index = i; left_max_press = value.left_press;
-			}
-			if (right_max_press < value.right_press) {
-				right_max_index = i; right_max_press = value.right_press;
-			}
-			i++;
-			});
-
-		if (right_max_index > right_min_index && right_max_press > right_min_press)
-		{
-			//缓存上升区域
-			if (front_press_right.size() == 0)
-			{
-				for (int i = right_min_index; i < dual_press_front.size(); i++)
-				{
-					front_press_right.push_back(dual_press_front[i]);
-				}
-			}
-			else
-			{
-				front_press_right.push_back(dual_press_front.back());
-			}
-
-		}
-		else
-		{
-			front_press_right.clear();
-		}
-
-
-		if (left_max_index > left_min_index && left_max_press > left_min_press)
-		{
-			//缓存上升区域
-			if (front_press_left.size() == 0)
-			{
-				for (int i = left_min_index; i < dual_press_front.size(); i++)
-				{
-					front_press_left.push_back(dual_press_front[i]);
-				}
-			}
-			else
-			{
-				front_press_left.push_back(dual_press_front.back());
-			}
-
-		}
-		else
-		{
-			front_press_left.clear();
-		}
-	}
-}
-
-void detect_concave_curve_left(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
+void detect_cancave_curve_top(deque<int>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
 {
 	//1、寻找最小值
 	int k = dual_press_back.size() - 1;
 
 	right_size_index = k;
 
-	while (k > 1)
+	while (k > 2)
 	{
-		if (dual_press_back[k].left_press > dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press > dual_press_back[k - 2].left_press)
+		if (dual_press_back[k] < dual_press_back[k - 1] + 50
+			|| dual_press_back[k] < dual_press_back[k - 2]
+			|| dual_press_back[k] < dual_press_back[k - 3])
 		{
 			k--;
 		}
@@ -231,14 +66,14 @@ void detect_concave_curve_left(deque<dualPressData>& dual_press_back, int& min_i
 
 	}
 
-	min_index = k;
+	max_index = k;
 
-	int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
 
-	while (k > 1)
+	while (k > 2)
 	{
-		if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press < dual_press_back[k - 2].left_press)
+		if (dual_press_back[k] > dual_press_back[k - 1] - 50
+			|| dual_press_back[k] > dual_press_back[k - 2]
+			|| dual_press_back[k] > dual_press_back[k - 3])
 		{
 			k--;
 		}
@@ -248,136 +83,41 @@ void detect_concave_curve_left(deque<dualPressData>& dual_press_back, int& min_i
 		}
 	}
 
-	left_size_index = k;
-}
 
-void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
-{
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
+	left_size_index = k;
 
-	right_size_index = k;
+	int distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
 
-	while (k > 1)
+	while (k < max_index)
 	{
-		if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press < dual_press_back[k - 2].left_press)
+		if (distance > abs(dual_press_back[k] - dual_press_back[right_size_index]))
 		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
-	}
-
-
-	max_index = k;
-
-	int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
+			distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
 
-
-	while (k > 1)
-	{
-		if (dual_press_back[k].left_press > dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press > dual_press_back[k - 2].left_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
+			left_size_index = k;
 		}
+		k++;
 	}
-
-	left_size_index = k;
 }
 
-void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
-{
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
 
-	right_size_index = k;
 
-	while (k > 1)
-	{
-		if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press < dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
-	}
-	
-	max_index = k;
-
-	int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
-
-
-	while (k > 1)
-	{
-		if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press > dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-	}
-
-	left_size_index = k;
-}
-
-void detect_concave_curve_right(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
+int mid_window_val(deque<int>& press_deque, int mid_window_size)
 {
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
-
-	right_size_index = k;
+	deque<int> press_deque_temp = press_deque;
 
-	while (k > 1)
+	if (press_deque_temp.size() >= mid_window_size)
 	{
-		if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press > dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
+		std::sort(press_deque_temp.begin(), press_deque_temp.end());
 	}
-
-	min_index = k;
-
-	int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
-
-	while (k > 1)
+	else
 	{
-		if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press < dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
+		return press_deque.back();
 	}
 
-	left_size_index = k;
+	//return press_deque[press_deque_temp.size() / 2];
+
+	return press_deque_temp[0];
 }
 
 void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_front_press, int right_back_press,
@@ -389,22 +129,37 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 	int front_down = 0;
 
 	result[0] = 0;
-	//处理队列的窗口
-
-	dual_press_front.push_back({ left_front_press , right_front_press , time_stamp });
-	dual_press_back.push_back({ left_back_press, right_back_press ,time_stamp });
 
 	//加速度窗口
 	dual_acc.push_back({ left_acc[2], right_acc[2] });
 
-	if (dual_press_front.size() > 40)
+	//滑动窗口补充
+	left_press_filter_window.push_back(left_back_press);
+	right_press_filter_window.push_back(right_back_press);
+
+	//采用最小值滤波, 较好的过滤毛刺
+	if (left_press_filter_window.size() > 5)
 	{
-		dual_press_front.pop_front();
+		left_press_filter_window.pop_front();
+		right_press_filter_window.pop_front();
+
+		left_back_press = mid_window_val(left_press_filter_window, 5);
+		right_back_press = mid_window_val(right_press_filter_window, 5);
+
 	}
 
-	if (dual_press_back.size() > 40)
+
+	left_front_press_queue.push_back(left_front_press); left_back_press_queue.push_back(left_back_press);
+	right_front_press_queue.push_back(right_front_press); right_back_press_queue.push_back(right_back_press);
+
+	if (left_back_press_queue.size() > 60)
 	{
-		dual_press_back.pop_front();
+		left_back_press_queue.pop_front(); right_back_press_queue.pop_front();
+	}
+
+	if (left_front_press_queue.size() > 40)
+	{
+		left_front_press_queue.pop_front(); right_front_press_queue.pop_front();
 	}
 
 	if (dual_acc.size() > 10)
@@ -413,7 +168,7 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 	}
 
 
-	if (dual_press_front.size() == 40)
+	if (left_front_press_queue.size() == 40)
 	{
 		/*
 		*  检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
@@ -422,290 +177,188 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 
 		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
 
-		detect_concave_curve_left_top(dual_press_front, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
+		detect_cancave_curve_top(left_front_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
 
 		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
 		
-		detect_concave_curve_right_top(dual_press_front, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
+		detect_cancave_curve_top(right_front_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
+
+		int left_dist = 500, right_dist = 500;
+
+		if (wait_press_top_unvalid > 0)
+		{
+			left_dist = max(left_dist, left_front_press_top);
+			right_dist = max(right_dist, right_front_press_top);
+		}
 
+		bool acc_valid = isValidAcc(dual_acc, 0, 512);
 		//检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
 		if (abs(left_max_index - right_max_index) < 6 &&
-			(wait_press_top_unvalid == 0 ||
-				(wait_press_top_unvalid > 0 && dual_press_front[left_max_index].left_press > left_front_press_top 
-					&& dual_press_front[right_max_index].right_press > right_front_press_top)) &&
-			dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -500
-			&& dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -500
-			&& dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -500
-			&& dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -500
+			right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -right_dist
+			&& right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -right_dist
+			&& left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -left_dist
+			&& left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -left_dist
 			&& right_foot_right_side_index - right_foot_left_side_index < 31
 			&& left_foot_right_side_index - left_foot_left_side_index < 31
-			&& isValidAcc(dual_acc, 0, 512)
+			&& acc_valid
 			//&& abs(dual_press_front[right_max_index].right_press - dual_press_front[left_max_index].left_press) < 8000//经验值
 			)
 		{
 			// 还要检测双凸曲线的顶点,如果还处于上一个双凸曲线的有效时间内,则顶点值与左右的差值需要大于上一个双凸曲线,才能判断有效的双凸曲线
 			// 记录上一个双凸曲线的差值
-			if (dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -2000
-				&& dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -2000
-				&& dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -2000
-				&& dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -2000)
+			if (right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -1000
+				&& right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -1000
+				&& left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -1000
+				&& left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -1000)
 			{
-				int right_dist = dual_press_front[right_max_index].right_press - dual_press_front[right_foot_right_side_index].right_press;
+				int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
 
-				right_dist = min(right_dist, dual_press_front[right_max_index].right_press - dual_press_front[right_foot_left_side_index].right_press);
+				right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
 
-				right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
+				//right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
+				right_front_press_top = 0.5 * right_dist;
 
-				int left_dist = dual_press_front[left_max_index].left_press - dual_press_front[left_foot_right_side_index].left_press;
+				int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
 
-				left_dist = min(left_dist, dual_press_front[left_max_index].left_press - dual_press_front[left_foot_left_side_index].left_press);
+				left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
 
-				left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
+				//left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
+				left_front_press_top =  0.5 * left_dist;
 
-				wait_press_top_unvalid = 40;
+				wait_press_top_unvalid = 60;
 
 			}
 
 			front_down = 1;
 		}
 
-		int i = dual_press_front.size() - 1;
-		for (; i > dual_press_front.size() - 15; i--)
+		if ( left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -2000
+			&& right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -2000
+			&& left_foot_right_side_index - left_max_index < 20 && right_foot_right_side_index - right_max_index < 20
+			)
 		{
-			/*if (dual_press_front[i].left_press > dual_press_front[i - 1].left_press
-				&& dual_press_back[i].left_press > dual_press_back[i - 1].left_press
-				&& dual_press_front[i].right_press > dual_press_front[i - 1].right_press
-				&& dual_press_back[i].right_press > dual_press_back[i - 1].right_press)*/
-			if ((dual_press_front[i].left_press > dual_press_front[i - 1].left_press || dual_press_front[i].left_press > dual_press_front[i - 2].left_press)
-				&& (dual_press_front[i].right_press > dual_press_front[i - 1].right_press || dual_press_front[i].right_press > dual_press_front[i - 2].right_press))
-			{
-				continue;
-			}
-			else
-			{
-				break;
-			}
-		}
 
-		//曲线有在15个数据处于上升曲线,则判断为前蹲
-		if ((wait_press_top_unvalid == 0 ||
-			(wait_press_top_unvalid >0 && dual_press_front.back().left_press > left_front_press_top && dual_press_front.back().right_press > right_front_press_top) )
-			&& dual_press_front.back().left_press > dual_press_front[i].left_press + 1800
-			&& dual_press_front.back().right_press > dual_press_front[i].right_press + 1800)
-		{
-			front_down = 1;
-		}
-		//延续前蹲的操作
-		if (last_front_down == 1 &&
-			(dual_press_front[39].left_press < dual_press_front[38].left_press || dual_press_front[39].left_press < dual_press_front[37].left_press)
-			&& (dual_press_front[39].right_press < dual_press_front[38].right_press || dual_press_front[39].right_press < dual_press_front[37].right_press))
-		{
+			int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
+
+			right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
+
+			//right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
+			right_front_press_top = 0.5 * right_dist;
+
+			int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
+
+			left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
+
+			//left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
+			left_front_press_top = 0.5 * left_dist;
+
+			wait_press_top_unvalid = 60;
+
 			front_down = 1;
 		}
+
 	}
 
 	int back_down = 0;
-	if (dual_press_back.size() > 10)
+	if (left_back_press_queue.size()>=40 )
 	{
-		int left_min_index, left_foot_right_side_index, left_foot_left_side_index;
+		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
 
-		detect_concave_curve_left(dual_press_back, left_min_index, left_foot_right_side_index, left_foot_left_side_index);
+		detect_cancave_curve_top(left_back_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
 
-		int right_min_index, right_foot_right_side_index, right_foot_left_side_index;
+		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
 
-		detect_concave_curve_right(dual_press_back, right_min_index, right_foot_right_side_index, right_foot_left_side_index);
+		detect_cancave_curve_top(right_back_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
 
 
 		int special_down = 0;
 
 		//同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
-		if (abs(right_min_index  - left_min_index) < 6 && 
-			dual_press_back[right_foot_right_side_index].right_press - dual_press_back[right_min_index].right_press > 2000
-			&& dual_press_back[right_foot_left_side_index].right_press - dual_press_back[right_min_index].right_press > 500
-			&& dual_press_back[left_foot_right_side_index].left_press - dual_press_back[left_min_index].left_press > 2000
-			&& dual_press_back[left_foot_left_side_index].left_press - dual_press_back[left_min_index].left_press > 500
-			
+		if (
+			abs(left_max_index - right_max_index) < 11 &&
+			right_back_press_queue[right_foot_right_side_index] - right_back_press_queue[right_max_index] < -1500
+			&& right_back_press_queue[right_foot_left_side_index] - right_back_press_queue[right_max_index] < -1000
+			&& left_back_press_queue[left_foot_right_side_index] - left_back_press_queue[left_max_index] < -1500
+			&& left_back_press_queue[left_foot_left_side_index] - left_back_press_queue[left_max_index] < -1000
+			&& right_back_press_queue[right_max_index] > 7500 && left_back_press_queue[left_max_index] > 7500
 			)
 		{
-			//back_down = 1;
-			//special_down = 1;
+			back_down = 1;
 		}
 
-		//双凹曲线下蹲 或 后脚跟压力明显上升
-		//if (special_down || isUptrendDeque(dual_press_back, dual_press_back.size()))
-
-		if(isUptrendDeque(dual_press_back, dual_press_back.size()))
-		{
-
-			int left_min_val = min(dual_press_back[left_min_index].left_press, dual_press_back.back().left_press);
-			int right_min_val = min(dual_press_back[right_min_index].right_press, dual_press_back.back().right_press);
-
-			//如果处于上一个后脚蹲压力有效时间,则需要处理后脚蹲延续情况
-			if (wait_back_press_top_unvalid > 0)
-			{
-				if (wait_back_press_top_unvalid > 58 && left_min_val < left_back_press_top + 500 &&
-					right_min_val < right_back_press_top + 500)
-				{
-					wait_back_press_top_unvalid = 60;
-
-					left_back_press_top = min(left_min_val, left_back_press_top);
-					right_back_press_top = min(right_min_val, right_back_press_top);
-
-					back_down = 1;
-				}
-				else if (left_min_val < left_back_press_top - 500 &&
-					right_min_val < right_back_press_top - 500)
-				{
-					wait_back_press_top_unvalid = 60;
-
-					left_back_press_top = min(left_min_val, left_back_press_top);
-					right_back_press_top = min(right_min_val, right_back_press_top);
-
-					back_down = 1;
-				}
-			}
-			else
-			{
-				back_down = 1;
-
-				wait_back_press_top_unvalid = 60;
-
-				/*left_back_press_top = min(dual_press_back.back().left_press, left_back_press_top);
-				right_back_press_top = min(dual_press_back.back().right_press, right_back_press_top);*/
-				left_back_press_top = left_min_val;
-				right_back_press_top = right_min_val;
-			}
-		}
-
-
-
-
 	}
 
+	//尝试降采样来一次
 
-
-	/*if (front_down == 1)
+	if (left_back_press_queue.size() >= 40 )
 	{
-		front_down_cmd_wait_time = 10;
-	}*/
 
-	if (front_down_cmd_wait_time > 0)
-	{
-		front_down = 1;
-		//result[0] = MOTION_DOWN;
-	}
+		deque<int> left_press_back_temp;
 
-	//if (back_down == 1)
-	//{
-	//	back_down_cmd_wait_time = 10;
-	//}
+		deque<int> right_press_back_temp;
 
-	if(back_down_cmd_wait_time > 0)
-	{
-		back_down = 1;
-	}
+		for (int i = 0; i < left_back_press_queue.size(); i+=3)
+		{
+			left_press_back_temp.push_back(left_back_press_queue[i]);
+			right_press_back_temp.push_back(right_back_press_queue[i]);
+		}
 
-	if (wait_press_top_unvalid > 0)
-	{
-		wait_press_top_unvalid--;
-	}
 
-	if (wait_back_press_top_unvalid > 0)
-	{
-		wait_back_press_top_unvalid--;
+		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
 
-	}
+		detect_cancave_curve_top(left_press_back_temp, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
 
-	if ( dual_press_front.size()==40)
-	{
-		int size = dual_press_front.size()-1;
-		
-		deque<dualPressData>::iterator left_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.left_press < val2.left_press; });
+		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
 
-		deque<dualPressData>::iterator left_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.left_press <  val2.left_press; });
+		detect_cancave_curve_top(right_press_back_temp, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
 
-		deque<dualPressData>::iterator right_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
 
-		deque<dualPressData>::iterator right_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
+		int special_down = 0;
 
-		//如果判断上一个任意下蹲情况,当前发现是前脚眼里上升,则视为前脚下蹲状态
-		if (left_max_it - left_min_it > 0 && left_max_it->left_press - left_min_it->left_press > 50
-			&& right_max_it - right_min_it > 0 && right_max_it->right_press - right_min_it->right_press > 50)
+		//同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
+		if (
+			abs(left_max_index - right_max_index) < 6 &&
+			right_press_back_temp[right_foot_right_side_index] - right_press_back_temp[right_max_index] < -2000
+			&& right_press_back_temp[right_foot_left_side_index] - right_press_back_temp[right_max_index] < -2000
+			&& left_press_back_temp[left_foot_right_side_index] - left_press_back_temp[left_max_index] < -2000
+			&& left_press_back_temp[left_foot_left_side_index] - left_press_back_temp[left_max_index] < -2000
+			&& right_press_back_temp[right_max_index] > 7500 && left_press_back_temp[left_max_index] > 7500
+
+			&& abs(right_press_back_temp[right_max_index] - left_press_back_temp[right_max_index]) < 5000
+			&& abs(right_press_back_temp[left_max_index] - left_press_back_temp[left_max_index]) < 5000
+			)
 		{
-			if (last_front_down == 1 || last_down == 1)
-			{
-				front_down = 1;
-			}
-
+			back_down = 1;
 		}
 
-		if((dual_press_front[size].left_press > dual_press_front[size - 1].left_press || dual_press_front[size].left_press > dual_press_front[size - 2].left_press)
-			&& (dual_press_front[size].right_press > dual_press_front[size - 1].right_press || dual_press_front[size].right_press > dual_press_front[size - 2].right_press))
-		{
-			if (last_front_down == 1 || last_down == 1)
-			{
-				front_down = 1;
-			}
-		}
 	}
 
-	
 
-	
-	if ((front_down == 1 || back_down == 1) && (last_down == 0 && last_front_down == 0))
-	{
-		result[0] = MOTION_DOWN;
 
-		addMotionCount(DOWN_COUNT);
-	}
 
-	if (front_down == 1 || back_down == 1)
+	if (wait_press_top_unvalid > 0)
 	{
-		cmd_wait_time++;
-
-		//result[0] = MOTION_DOWN;
-
-		//addMotionCount(DOWN_COUNT);
+		back_down = 0;
 	}
-	else
+
+	if (wait_press_top_unvalid > 0)
 	{
-		cmd_wait_time = 0; 
+		wait_press_top_unvalid--;
 	}
 
-	//if (cmd_wait_time > 0)
-	//{
-	//	cmd_wait_time--;
-
-	//	back_down_continue_time++;
-
-	//}
-
-	if (front_down_cmd_wait_time > 0)
+	if ((front_down == 1 || back_down == 1) && (last_down == 0 && last_front_down == 0) && cmd_wait_time == 0)
 	{
-		front_down_cmd_wait_time--;
+		result[0] = MOTION_DOWN;
 
-		front_down_continue_time++;
-	}
-	else
-	{
-		front_down_continue_time = 0;
-	}
+		addMotionCount(DOWN_COUNT);
 
-	if (front_down_continue_time == 30)
-	{
-		front_down_continue_time = 0;
-		front_down_cmd_wait_time = 0;
-		front_down = 0;
+		cmd_wait_time = 20;
 	}
 
-	if (back_down_cmd_wait_time > 0)
+	//处于蹲的倒计时,倒计时就不要工作了
+	if (!(front_down == 1 || back_down == 1) && cmd_wait_time > 0)
 	{
-		back_down_cmd_wait_time--;
-		back_down_continue_time++;
+		cmd_wait_time--;
 
 	}
 

+ 22 - 22
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/FootStep.cpp

@@ -51,7 +51,7 @@ void calStepFreq(vector<FLOOR_TIME_STYPE>& time_vector, float &mean_step_vel)
 
 	if (length < 2)
 	{
-//		cout << "FootStep::calStepFreq vector_length < 2" << endl;
+		cout << "FootStep::calStepFreq vector_length < 2" << endl;
 
 		return;
 	}
@@ -63,18 +63,18 @@ void calStepFreq(vector<FLOOR_TIME_STYPE>& time_vector, float &mean_step_vel)
 	if (cur_floor_time_stype.time_type != LEAVE_TIME_STYPE || last_floor_time_stype.time_type != LEAVE_TIME_STYPE
 		|| time_vector[length - 2].time_type != CATCH_TIME_STYPE)
 	{
-//		cout << "FootStep::calStepFreq time_stype is not valid " << endl;
+		cout << "FootStep::calStepFreq time_stype is not valid " << endl;
 
 		for (int i = 0; i < length; i++)
 		{
 			cout << time_vector[i].time << ", ";
 			if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 			{
-//				cout << "LEAVE_TIME_STYPE," << endl;
+				cout << "LEAVE_TIME_STYPE," << endl;
 			}
 			else
 			{
-//				cout << "CATCH_TIME_STYPE," << endl;
+				cout << "CATCH_TIME_STYPE," << endl;
 			}
 		}
 	}
@@ -102,7 +102,7 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 	vector<FLOOR_TIME_STYPE> time_vector_tmp(time_vector);
 
-//	cout << "FootStep::time_vector before" << endl;
+	cout << "FootStep::time_vector before" << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -110,11 +110,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, ";
+			cout << "LEAVE_TIME_STYPE, ";
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -134,12 +134,12 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 		}
 		else
 		{
-//			std::cout << "delect time_vector_tmp cell " << endl;
+			std::cout << "delect time_vector_tmp cell " << endl;
 		}
 
 	}
 
-//	cout << "FootStep::time_vector mid " << endl;
+	cout << "FootStep::time_vector mid " << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -148,11 +148,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, " ;
+			cout << "LEAVE_TIME_STYPE, " ;
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -172,7 +172,7 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 		index++;
 	}
 
-//	cout << "FootStep::time_vector end" << endl;
+	cout << "FootStep::time_vector end" << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -181,11 +181,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, ";
+			cout << "LEAVE_TIME_STYPE, ";
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -338,31 +338,31 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 
 				step_vel_buff[2] = mean_vel;
 
-//				cout << "now step mean_vel is " << mean_vel << endl;
+				cout << "now step mean_vel is " << mean_vel << endl;
 
 				mean_window_vel = (step_vel_buff[0] + step_vel_buff[1] + step_vel_buff[2]) / 3.0f;
 
 				stepFreq = mean_window_vel * 60;
 
-//				cout << "now step mean_window_vel is " << mean_window_vel << endl;
+				cout << "now step mean_window_vel is " << mean_window_vel << endl;
 
 				memcpy(vel_sqrt_buff, vel_sqrt_buff + 1, 2 * sizeof(float));
 
 				vel_sqrt_buff[2] = vel_sqrt_sum / vel_sqrt_num * mean_vel;
 
-//				cout << "now step vel_sqrt_buff_mean is " << (vel_sqrt_buff[0] + vel_sqrt_buff[1] + vel_sqrt_buff[2]) / 3.0f << endl;
+				cout << "now step vel_sqrt_buff_mean is " << (vel_sqrt_buff[0] + vel_sqrt_buff[1] + vel_sqrt_buff[2]) / 3.0f << endl;
 
 				vel_sqrt_sum = 0;
 				vel_sqrt_num = 0;
 
 				stepCount++;
 
-//				std::cout << "step_count : " << stepCount << endl;
+				std::cout << "step_count : " << stepCount << endl;
 			}
 
 			leave_time_wait = 0;
 
-//			std::cout << "leave_time_wait = 0;" << endl;
+			std::cout << "leave_time_wait = 0;" << endl;
 		}
 
 		leave_time_wait--;
@@ -410,9 +410,9 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 
 		stepFreq = mean_window_vel * 60;
 
-//		cout << "stop signal : now step mean_window_vel is " << mean_window_vel <<endl;
+		cout << "stop signal : now step mean_window_vel is " << mean_window_vel <<endl;
 
-//		cout << step_vel_buff[0] << ", " << step_vel_buff[1] << ", " << step_vel_buff[2] << endl;
+		cout << step_vel_buff[0] << ", " << step_vel_buff[1] << ", " << step_vel_buff[2] << endl;
 
 		zuptCount = 0;
 
@@ -447,4 +447,4 @@ int FootStep::getStepStatus()
 int FootStep::getStepCount()
 {
 	return stepCount;
-}
+}

+ 23 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/H5_Game.cpp

@@ -27,6 +27,19 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 	int jump, int down, int rssi)
 {
 
+	//规避一些跳的动作
+	left_front_press_deque.push_back(left_front_press);
+
+	right_front_press_deque.push_back(right_front_press);
+
+	if (left_front_press_deque.size() > 10)
+	{
+		left_front_press_deque.pop_front();
+		
+		right_front_press_deque.pop_front();
+
+	}
+
 	//获取触地
 	if (last_left_zupt == 0 && left_zupt == 1)
 	{
@@ -56,7 +69,16 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 
 	//filter down jump
 
-	if (last_jump == 0 && jump == 1)
+	int valid_press = 1;
+
+	if (*max_element(left_front_press_deque.begin(), left_front_press_deque.end()) - *min_element(left_front_press_deque.begin(), left_front_press_deque.end()) < 1024
+		|| *max_element(right_front_press_deque.begin(), right_front_press_deque.end()) - *min_element(right_front_press_deque.begin(), right_front_press_deque.end()) < 1024)
+	{
+		valid_press = 0;
+	}
+
+
+	if (last_jump == 0 && jump == 1 && valid_press)
 	{
 		//统计步数
 		addMotionCount(JUMP_COUNT);

+ 40 - 21
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/RunGame.cpp

@@ -10,6 +10,8 @@ RunGame::RunGame()
 
 	last_left_zupt = 1;
 	last_right_zupt = 1;
+
+	last_canva_down = 0;
 }
 
 
@@ -21,10 +23,12 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 {
 
 	// 额外处理蹲
-	if (extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
-		right_acc, left_acc))
+	down = 0;
+	int online_down = extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
+	if (online_down)
 	{
-		down = 1;
+		down = online_down;
 	}
 	//存放一步的空中数据到shoes_data_vector 队列中, 头必须是触地时刻信息
 	setData(right_shoes_data_vector, time_stamp, right_pos[0] * 0.001f, right_pos[1] * 0.001f, right_pos[2] * 0.001f,
@@ -114,6 +118,8 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 
 	int down_cmd = -1;
 
+	result[3] = -1;
+
 	down_cmd = getResultDown(down);
 
 
@@ -142,27 +148,35 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 		}
 	}
 
-	if (down_cmd == MOTION_DOWN)
+	if (down_cmd == 1)
 	{
 		wait_down = 10;
 	}
+	if (down_cmd == MOTION_DOWN)
+	{
+		addMotionCount(DOWN_COUNT);
 
-	if (wait_down > 0  && acc_valid == 1)
+		down_wait_after_jump = 20;
+
+		result[3] = MOTION_DOWN;
+
+		wait_down = 0;
+	}
+
+	if (wait_down == 1  && acc_valid == 1)
 	//if (wait_down == 10)
 	//if(down)
 	{
 
 		addMotionCount(DOWN_COUNT);
 
-		std::cout << "RUNGAME:: MOTION_DOWN" << endl;
+		down_wait_after_jump = 20;
+
 		result[3] = MOTION_DOWN;
 
 		wait_down = 0;
 	}
-	else
-	{
-		result[3] = -1;
-	}
+
 
 	if (wait_down > 0)
 	{
@@ -203,28 +217,30 @@ int RunGame::getResultDown(int down)
 {
 	int isDown = -1;
 
+	int canva_down = ((down & 0x04) > 0 ? 1 : 0);
+	
 
-	if (last_down == 0 && down == 1 && down_wait_after_jump < 0)
-	//if ( last_down == 0 && down == 1)
+
+	if (last_canva_down == 0 && canva_down == 1 && down_wait_after_jump < 0)
+	//if (last_canva_down == 0 && canva_down == 1 )
 	{
 		isDown = MOTION_DOWN;
-
-		down_wait_after_jump = 10;
+	}
+	else if (last_down == 0 && down > 0 && down_wait_after_jump < 0)
+	//if ( last_down == 0 && down == 1)
+	{
+		isDown = 1;
 
 		//addMotionCount(DOWN_COUNT);
 
 		//std::cout << "motion : down" << std::endl;
 
-		down_count++;
+		//down_count++;
 	}
 	/*
 	* down_wait_after_jump:避免前脚蹲后,接着后脚压下来的情况,当down_wait_after_jump == -1时候,判断蹲生效
 	* 当一直处于蹲的时候,额外加拖延时间,在这个时间不允许触发蹲。
 	*/
-	/*if (down && down_wait_after_jump < 0)
-	{
-		down_wait_after_jump = 10;
-	}*/
 
 	if (down == 0 && down_wait_after_jump >=0)
 	{
@@ -233,13 +249,16 @@ int RunGame::getResultDown(int down)
 
 	last_down = down;
 
+	last_canva_down = canva_down;
+
+
 	return isDown;
 
 }
 
 int RunGame::getResultJump(int jump)
 {
-	int isJump = -1;
+	int isJump = 0;
 
 	if (last_jump == 0 && jump == 1)
 	{
@@ -256,7 +275,7 @@ int RunGame::getResultJump(int jump)
 	*/
 	if (jump)
 	{
-		down_wait_after_jump = 10;
+		down_wait_after_jump = 20;
 	}
 
 	last_jump = jump;

+ 24 - 1
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/Tricycle.cpp

@@ -39,6 +39,27 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 {
 	//1¡¢È·¶¨³õʼµÄ·½Ïò
 
+
+	if (left_acc_z_queue.size() > 10)
+	{
+		left_acc_z_queue.pop_front();
+		right_acc_z_queue.pop_front();
+	}
+	
+	left_acc_z_queue.push_back(left_acc[2]);
+	right_acc_z_queue.push_back(right_acc[2]);
+
+	if (has_init == 0)
+	{
+		if (*(max_element(left_acc_z_queue.begin(), left_acc_z_queue.end())) - *(min_element(left_acc_z_queue.begin(), left_acc_z_queue.end())) < 102
+			&& *(max_element(right_acc_z_queue.begin(), right_acc_z_queue.end())) - *(min_element(right_acc_z_queue.begin(), right_acc_z_queue.end())) < 102)
+		{
+			left_zupt = 1;
+			right_zupt = 1;
+		}
+	}
+
+
 	if (left_zupt)
 	{
 		left_zupt_count++;
@@ -204,6 +225,8 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	result[2] = (down_prop == 1 ? MOTION_JUMP_OC : -1);
 	result[3] = (up_prop == 1 ? MOTION_JUMP_VERTICAL : -1);
 
+	result[4] = left_att[0];
+
 	if (has_init == 0)
 	{
 		/*result[0] = 0;
@@ -215,7 +238,7 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 float Tricycle::calHeadingOffset(float init_heading, float cur_heading)
 {
-	float heading_offset = cur_heading - init_heading;
+	float heading_offset = (cur_heading  - init_heading);
 
 	if (heading_offset > PI)
 	{

+ 121 - 78
DanceGame/Classes/FitfunTool/FitfunSDK_V2.0/SDK/shoes_sdk_3.0/src/online_motion.cpp

@@ -83,9 +83,13 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	right_front_mag_queue.push_back(right_front_mag);
 	left_front_mag_queue.push_back(left_front_mag);
 
+	/*left_front_acc.push_back(left_acc[2]);
+	right_front_acc.push_back(right_acc[2]);*/
+
 	left_front_acc.push_back(sqrt(left_acc[0] * left_acc[0] + left_acc[1] * left_acc[1]));
 	right_front_acc.push_back(sqrt(right_acc[0] * right_acc[0] + right_acc[1] * right_acc[1]));
 
+
 	deque<int> right_back_temp{ right_back_mag };
 	deque<int> left_back_temp{ left_back_mag };
 
@@ -104,10 +108,10 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 			//if (right_back_mag_queue[i] > right_back_temp.front() || left_back_mag_queue[i] > left_back_temp.front())
 
 
-			if ((left_back_mag_queue[i] < left_back_mag_queue[i - 1] || left_back_mag_queue[i] < left_back_mag_queue[i - 2]
-				|| left_back_mag_queue[i] < left_back_mag_queue[i - 3]) &&
-				(right_back_mag_queue[i] < right_back_mag_queue[i - 1] || right_back_mag_queue[i] < right_back_mag_queue[i - 2]
-					|| right_back_mag_queue[i] < right_back_mag_queue[i - 3]))
+			if ((left_back_mag_queue[i] > left_back_mag_queue[i - 1] || left_back_mag_queue[i] > left_back_mag_queue[i - 2]
+				|| left_back_mag_queue[i] > left_back_mag_queue[i - 3]) &&
+				(right_back_mag_queue[i] > right_back_mag_queue[i - 1] || right_back_mag_queue[i] > right_back_mag_queue[i - 2]
+					|| right_back_mag_queue[i] > right_back_mag_queue[i - 3]))
 			{
 				right_back_temp.push_back(right_back_mag_queue[i]);
 				left_back_temp.push_back(left_back_mag_queue[i]);
@@ -118,11 +122,12 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 			}
 		}
 
-		if (*max_element(left_front_acc.begin(), left_front_acc.end()) - *min_element(left_front_acc.begin(), left_front_acc.end()) < 512
-			&& *max_element(right_front_acc.begin(), right_front_acc.end()) - *min_element(right_front_acc.begin(), right_front_acc.end()) < 512)
+		if (*max_element(left_front_acc.begin()+10, left_front_acc.end()) - *min_element(left_front_acc.begin() + 10, left_front_acc.end()) < 512
+			&& *max_element(right_front_acc.begin() + 10, right_front_acc.end()) - *min_element(right_front_acc.begin() + 10, right_front_acc.end()) < 512)
 		{
-			if (left_back_temp.size() > 5 && right_back_temp.size() > 5 && left_back_temp.front() < left_back_temp.back() - 2000
-				&& right_back_temp.front() < right_back_temp.back() - 2000)
+			if (left_back_temp.size() < 10 && right_back_temp.size() < 10 && left_back_temp.front() > left_back_temp.back() + 3000
+				&& right_back_temp.front() > right_back_temp.back() + 3000
+				&& left_back_temp.front() > 10000 && right_back_temp.front() > 10000)
 			{
 				back_down = 1;
 			}
@@ -143,12 +148,12 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	
 	int front_down = 0;
 	if (right_front_mag_queue.size() > 20)
-	for (int i = right_front_mag_queue.size() - 1; i >2 ; i--)
+	for (int i = right_front_mag_queue.size() - 1; i > right_front_mag_queue.size() -11; i--)
 	{
-		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1] || left_front_mag_queue[i] > left_front_mag_queue[i - 2]
-			|| left_front_mag_queue[i] > left_front_mag_queue[i - 3]) &&
-			(right_front_mag_queue[i] > right_front_mag_queue[i - 1] || right_front_mag_queue[i] > right_front_mag_queue[i - 2]
-				|| right_front_mag_queue[i] < right_front_mag_queue[i - 3]))
+		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1]+100 || left_front_mag_queue[i] > left_front_mag_queue[i - 2] + 100
+			|| left_front_mag_queue[i] > left_front_mag_queue[i - 3]) + 100 &&
+			(right_front_mag_queue[i] > right_front_mag_queue[i - 1] + 100 || right_front_mag_queue[i] > right_front_mag_queue[i - 2] + 100
+				|| right_front_mag_queue[i] < right_front_mag_queue[i - 3] + 100))
 		{
 			right_front_temp.push_back(right_front_mag_queue[i]);
 			left_front_temp.push_back(left_front_mag_queue[i]);
@@ -158,11 +163,12 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 			break;
 		}
 
-		if (*max_element(left_front_acc.begin() + 10, left_front_acc.end()) - *min_element(left_front_acc.begin() + 10, left_front_acc.end()) < 256
-			&& *max_element(right_front_acc.begin() + 10, right_front_acc.end()) - *min_element(right_front_acc.begin() + 10, right_front_acc.end()) < 256)
+		if (*max_element(left_front_acc.begin() , left_front_acc.end()) - *min_element(left_front_acc.begin() , left_front_acc.end()) < 256
+			&& *max_element(right_front_acc.begin() , right_front_acc.end()) - *min_element(right_front_acc.begin() , right_front_acc.end()) < 256)
 		{
 			if (right_front_temp.size() > 5 && left_front_temp.size() > 5 && left_front_temp.front() >  left_front_temp.back() + 1500
-				&& right_front_temp.front() > right_front_temp.back() + 1500)
+				&& right_front_temp.front() > right_front_temp.back() + 1500
+				&& abs(left_front_temp.front() - right_front_temp.front()) < 6000)
 			{
 				front_down = 1;
 			}
@@ -174,41 +180,64 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	int little_front_down = 0;
 
 
-	if (right_front_mag_queue.size() == 21)
+
+	if (left_front_acc.size() > 20)
+	{
+		if (*max_element(left_front_acc.end() - 5, left_front_acc.end())
+			- *min_element(left_front_acc.end() - 5, left_front_acc.end()) < 256
+			&& *max_element(right_front_acc.end() - 5, right_front_acc.end())
+			- *min_element(right_front_acc.end() - 5, right_front_acc.end()) < 256)
+		{
+	
+			if (right_front_mag_canve_queue.size() == 0)
+			{
+				for (int k = right_front_mag_queue.size() - 6; k < right_front_mag_queue.size(); k++)
+				{
+					right_front_mag_canve_queue.push_back(right_front_mag_queue[k]);
+					left_front_mag_canve_queue.push_back(left_front_mag_queue[k]);
+				}
+			}
+			else
+			{
+				right_front_mag_canve_queue.push_back(right_front_mag_queue.back());
+				left_front_mag_canve_queue.push_back(left_front_mag_queue.back());
+			}
+
+		}
+		else
+		{
+			right_front_mag_canve_queue.clear();
+			left_front_mag_canve_queue.clear();
+		}
+	}
+
+	if (right_front_mag_canve_queue.size() > 20)
+	{
+		right_front_mag_canve_queue.pop_front();
+		left_front_mag_canve_queue.pop_front();
+	}
+
+
+	if (left_front_mag_canve_queue.size() > 9)
 	{
 		//1、补充蹲,检测到一个完成的波视为蹲就好
 
 		int left_top_index;
 		int left_foot_left_side_index, left_foot_right_side_index;
-		top_point(left_front_mag_queue, left_top_index, left_foot_left_side_index, left_foot_right_side_index);
+		top_point(left_front_mag_canve_queue, left_top_index, left_foot_left_side_index, left_foot_right_side_index);
 
 		int right_top_index;
 		int right_foot_left_side_index, right_foot_right_side_index;
-		top_point(right_front_mag_queue, right_top_index, right_foot_left_side_index, right_foot_right_side_index);
+		top_point(right_front_mag_canve_queue, right_top_index, right_foot_left_side_index, right_foot_right_side_index);
 
 		if (
 			abs(left_top_index - right_top_index) < 4    //保持定点位置不要相差太多
-			&&left_front_mag_queue[left_top_index] > left_front_mag_queue[left_foot_left_side_index] + 500
-			&& left_front_mag_queue[left_top_index] > left_front_mag_queue[left_foot_right_side_index] + 500
-
-			&& right_front_mag_queue[right_top_index] > right_front_mag_queue[right_foot_left_side_index] + 500
-			&& right_front_mag_queue[right_top_index] > right_front_mag_queue[right_foot_right_side_index] + 500
-
-			//&& abs(left_front_mag_queue[left_foot_left_side_index] - left_front_mag_queue[left_foot_right_side_index]) < 500
-			//&& abs(right_front_mag_queue[right_foot_left_side_index] - right_front_mag_queue[right_foot_right_side_index]) < 500
-
-			//&& left_foot_right_side_index - left_top_index > 1 
-			//&& right_foot_right_side_index - right_top_index > 1
-			)
+			&& left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_left_side_index] + 800
+			&& left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_right_side_index] + 800
+			&& right_front_mag_canve_queue[right_top_index] > right_front_mag_canve_queue[right_foot_left_side_index] + 800
+			&& right_front_mag_canve_queue[right_top_index] > right_front_mag_canve_queue[right_foot_right_side_index] + 800)
 		{
-
-			if (*max_element(left_front_acc.begin() + left_foot_left_side_index, left_front_acc.begin() + left_foot_right_side_index)
-				- *min_element(left_front_acc.begin() + left_foot_left_side_index, left_front_acc.begin() + left_foot_right_side_index) < 512
-				&& *max_element(right_front_acc.begin() + right_foot_left_side_index, right_front_acc.begin() + right_foot_right_side_index)
-				- *min_element(right_front_acc.begin() + right_foot_left_side_index, right_front_acc.begin() + right_foot_right_side_index) < 512)
-			{
-				little_front_down = 1;
-			}
+			little_front_down = 1;
 		}
 	}
 
@@ -216,10 +245,8 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	{
 		int i = right_front_mag_queue.size() - 1;
 
-		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1] || left_front_mag_queue[i] > left_front_mag_queue[i - 2]
-			|| left_front_mag_queue[i] > left_front_mag_queue[i - 3]) &&
-			(right_front_mag_queue[i] > right_front_mag_queue[i - 1] || right_front_mag_queue[i] > right_front_mag_queue[i - 2]
-				|| right_front_mag_queue[i] < right_front_mag_queue[i - 3]))
+		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1] ) &&
+			(right_front_mag_queue[i] > right_front_mag_queue[i - 1]))
 		{
 			if (last_back_down || last_front_down)
 			{
@@ -244,11 +271,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 		}
 	}
 
-	//if (left_back_temp.size() > 5 && right_back_temp.size() > 5
-	//	&& left_back_temp.front() > left_back_temp.back() + 2000
-	//	&& right_back_temp.front() > right_back_temp.back() + 2000)
-	/*if ( left_back_temp.front() > left_back_temp.back() + 1500
-		&& right_back_temp.front() > right_back_temp.back() + 1500)*/
+
 
 	int res = 0;
 	if (back_down == 1)
@@ -264,59 +287,79 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 
 	if (little_front_down == 1)
 	{
-		res |= 0x01;
+		res |= 0x04;
 	}
 
 	last_back_down = back_down;
 	last_front_down = front_down;
 	last_little_front_down = little_front_down;
 
-	//if (left_back_temp.front() > left_back_temp.back() + 500 && right_back_temp.front() > right_back_temp.back() + 500
-	//	&& left_front_temp.front() > left_front_temp.back() + 1000 && right_front_temp.front() > right_front_temp.back() + 1000)
-	//{
-	//	return 1;
-	//}
+
 
 
 	return res;
 
+}
+
+/*
+* 检测触地的一个东西
+*/
 
-	/*if (right_back_mag_queue.size() > 20)
+void online_motion::push_press_queue(deque<int>& press_queue, int press, int queue_size)
+{
+	press_queue.push_back(press);
+
+	if (press_queue.size() > queue_size)
 	{
-		right_back_mag_queue.pop_front();
-		left_back_mag_queue.pop_front();
+		press_queue.pop_front();
 	}
-	right_back_mag_queue.push_back(right_back_mag);
-	left_back_mag_queue.push_back(left_back_mag);
+}
 
-	deque<int> right_back_temp{ right_back_mag };
-	deque<int> left_back_temp{ left_back_mag };
+int online_motion::check_press_queue_up(deque<int>& press_queue, int thresh_hold)
+{
+	int k = press_queue.size() - 1;
 
-	for (int i = right_back_mag_queue.size() - 2; i >= 0; i--)
+	while (k > 0)
 	{
-		if ((right_back_mag_queue[i] > right_back_temp.front() || left_back_mag_queue[i] > left_back_temp.front())
-			&& i > right_back_mag_queue.size() / 2 - 1)
+		if (!(press_queue[k] >= press_queue[k - 1]))
 		{
-			return 0;
+			break;
 		}
+		k--;
+	}
 
-		if (right_back_mag_queue[i] < right_back_temp.back())
-		{
-			right_back_temp.push_back(right_back_mag_queue[i]);
-		}
+	if(press_queue.back() - press_queue[k] > thresh_hold)
+	{
+		return 1;
+	}
 
-		if (left_back_mag_queue[i] < left_back_temp.back())
-		{
-			left_back_temp.push_back(left_back_mag_queue[i]);
-		}
+	return 0;
+}
+
+
+int online_motion::online_detect_touch_floor(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag)
+{
+	push_press_queue(left_front_press_queue_touch_floor, left_front_mag, 10);
+
+	push_press_queue(right_front_press_queue_touch_floor, right_front_mag, 10);
+
+	push_press_queue(left_back_press_queue_touch_floor, left_back_mag, 10);
+
+	push_press_queue(right_back_press_queue_touch_floor, right_back_mag, 10);
+
+	int right_foot_on_floor = 0;
+	if (check_press_queue_up(right_front_press_queue_touch_floor, 1000) || check_press_queue_up(right_back_press_queue_touch_floor, 1000))
+	{
+		right_foot_on_floor = 1;
 	}
 
-	if (left_back_temp.size() > 5 && right_back_temp.size() > 5
-		&& left_back_temp.front() > left_back_temp.back() + 3000
-		&& right_back_temp.front() > right_back_temp.back() + 3000)
+	int left_foot_on_floor = 0;
+	if (check_press_queue_up(left_front_press_queue_touch_floor, 1000) || check_press_queue_up(left_back_press_queue_touch_floor, 1000))
 	{
-		return 1;
+		left_foot_on_floor = 1;
 	}
 
-	return 0;*/
+	return  right_foot_on_floor << 1 | left_foot_on_floor;
+
+
 }

+ 0 - 2
DanceGame/Info.plist

@@ -272,14 +272,12 @@
 	<string>UIStatusBarStyleDefault</string>
 	<key>UISupportedInterfaceOrientations</key>
 	<array>
-		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
 	</array>
 	<key>UISupportedInterfaceOrientations~ipad</key>
 	<array>
 		<string>UIInterfaceOrientationLandscapeLeft</string>
 		<string>UIInterfaceOrientationLandscapeRight</string>
-		<string>UIInterfaceOrientationPortraitUpsideDown</string>
 	</array>
 	<key>UIUserInterfaceStyle</key>
 	<string>Light</string>

+ 12 - 24
DanceGame/Unity-iPhone.xcodeproj/project.pbxproj

@@ -2341,10 +2341,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = (
-					armv7,
-					arm64,
-				);
+				ARCHS = arm64;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
 				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
@@ -2353,7 +2350,7 @@
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CODE_SIGN_ENTITLEMENTS = "Unity-iPhone/Unity-iPhone.entitlements";
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 13001;
+				CURRENT_PROJECT_VERSION = 13201;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2388,7 +2385,7 @@
 					"\"$(SRCROOT)\"",
 					"\"$(SRCROOT)/Libraries\"",
 				);
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -2424,10 +2421,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = (
-					armv7,
-					arm64,
-				);
+				ARCHS = arm64;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
 				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
@@ -2436,7 +2430,7 @@
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CODE_SIGN_ENTITLEMENTS = "Unity-iPhone/Unity-iPhone.entitlements";
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13001;
+				CURRENT_PROJECT_VERSION = 13201;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2468,7 +2462,7 @@
 					"\"$(SRCROOT)\"",
 					"\"$(SRCROOT)/Libraries\"",
 				);
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = NO;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -2649,10 +2643,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = (
-					armv7,
-					arm64,
-				);
+				ARCHS = arm64;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
 				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
@@ -2661,7 +2652,7 @@
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CODE_SIGN_ENTITLEMENTS = "Unity-iPhone/Unity-iPhone.entitlements";
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13001;
+				CURRENT_PROJECT_VERSION = 13201;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
@@ -2694,7 +2685,7 @@
 					"\"$(SRCROOT)\"",
 					"\"$(SRCROOT)/Libraries\"",
 				);
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -2812,10 +2803,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ALWAYS_SEARCH_USER_PATHS = NO;
-				ARCHS = (
-					armv7,
-					arm64,
-				);
+				ARCHS = arm64;
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
 				CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
@@ -2824,7 +2812,7 @@
 				CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 				CODE_SIGN_ENTITLEMENTS = "Unity-iPhone/Unity-iPhone.entitlements";
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13001;
+				CURRENT_PROJECT_VERSION = 13201;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -2856,7 +2844,7 @@
 					"\"$(SRCROOT)\"",
 					"\"$(SRCROOT)/Libraries\"",
 				);
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",

BIN
DanceGame/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate


BIN
Paoku_ios_20220923/.DS_Store


+ 3 - 1
Paoku_ios_20220923/Classes/SDK/BLE/BTDataProcess.mm

@@ -433,7 +433,7 @@ void inviteFriends (CFNotificationCenterRef center, void *observer, CFStringRef
                             }
                     }
 
-                    //数据回调给 搜索蓝牙弹
+                    //数据回调给 搜索蓝牙弹
                     self.searchDeviceVC.deviceArray = self.deviceArray;
                     [self.searchDeviceVC reloadData];
 
@@ -562,6 +562,8 @@ void inviteFriends (CFNotificationCenterRef center, void *observer, CFStringRef
     //蓝牙连接丢失
     LEManager.disConnectBlock = ^(CBPeripheral * _Nonnull peripheral, NSError * _Nonnull error){
               
+        NSLog(@"蓝牙链接丢失");
+
         if (LEManager.peripheral!=nil && peripheral==LEManager.peripheral){
             [[IOSPlatformSDK sharedInstance] bridgingDeviceAction:DEVICETYPE_MAIN
                                         name:LEManager.peripheral.name

+ 1 - 1
Paoku_ios_20220923/Classes/SDK/UI/DebugView/DebugView.mm

@@ -308,7 +308,7 @@ static DebugView* instance = nil;
         if (total > 30){
             NSLog(@"getGameDataStr 丢包 ================================>> %d",total);
             dispatch_async(dispatch_get_main_queue(), ^{
-                AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
+//                AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
 //                [PopupView showCusHUDA:[NSString stringWithFormat:@"丢包数: %d",total]];
             });
         }

BIN
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/.DS_Store


+ 6 - 29
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/BuildHouse.h

@@ -5,11 +5,6 @@
 
 using namespace std;
 
-struct dualPressData {
-	int left_press;
-	int right_press;
-	int time;
-};
 
 struct dualAccData {
 	int left_acc;
@@ -22,44 +17,25 @@ class BuildHouse: public PublicSDKMotion {
 	int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_front_press, int left_back_press,
 		int jump, int down, int rssi);
 
-	deque<dualPressData> front_press;
-	deque<dualPressData> back_press;
-
-	deque<dualPressData> front_press_left;
-	deque<dualPressData> front_press_right;
-
-	deque<dualPressData> dual_press_front;
-	deque<dualPressData> dual_press_back;
+	int back_press_up_trend(deque<int>& left_press_deque, deque<int>& right_press_deque);
 
-	deque<dualPressData> dual_press_front_for_back_down;
 
 	deque<dualAccData> dual_acc;
 
 	deque<int> left_press_filter_window;
 	deque<int> right_press_filter_window;
 
+	deque<int> left_front_press_queue;
+	deque<int> left_back_press_queue;
 
-	int refuse_down_motion_time = 0;
-
-	int down_count = 0;
+	deque<int> right_front_press_queue;
+	deque<int> right_back_press_queue;
 
 	int last_down = 0;
 	int last_front_down = 0;
 
-	int front_wait_500 = 0;
-
-	int back_wait_1000 = 0;
-
 	int cmd_wait_time = 0;
 
-	int front_down_cmd_wait_time = 0;
-
-	int back_down_cmd_wait_time = 0;
-
-	int front_down_continue_time = 0;
-
-	int back_down_continue_time = 0;
-
 	int left_front_press_top = 0;
 	int right_front_press_top = 0;
 
@@ -69,5 +45,6 @@ class BuildHouse: public PublicSDKMotion {
 	int right_back_press_top = 0;
 	
 	int wait_back_press_top_unvalid = 0;
+
 	
 };

+ 1 - 0
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/RunGame.h

@@ -34,6 +34,7 @@ private:
 	int down_count;
 
 	int last_down;
+	int last_canva_down;
 	int last_jump;
 
 	int down_wait_after_jump;

+ 3 - 0
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/Tricycle.h

@@ -46,4 +46,7 @@ private:
 
 	int prop_status;
 
+	deque<int> left_acc_z_queue;
+	deque<int> right_acc_z_queue;
+
 };

+ 24 - 0
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/online_motion.h

@@ -10,19 +10,32 @@ public:
 	int online_detect_down(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag,
 		int* right_acc, int* left_acc);
 
+	int online_detect_jump(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag,
+		int* right_acc, int* left_acc);
+
 	int online_detect_touch_floor(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag );
 
 	void push_press_queue(deque<int>& press_queue ,int press, int queue_size);
 
 	int check_press_queue_up(deque<int>& press_queue, int thresh_hold);
 
+	int  min_window_val(deque<int>& press_deque, int mid_window_size);
+
+	int back_press_up_trend(deque<int>& left_press_deque, deque<int>& right_press_deque);
+
 private:
 	deque<int> right_back_mag_queue;
 	deque<int> left_back_mag_queue;
 
+	deque<int> left_press_filter_window;
+	deque<int> right_press_filter_window;
+
 	deque<int> right_front_mag_queue;
 	deque<int> left_front_mag_queue;
 
+	deque<int> right_front_mag_canve_queue;
+	deque<int> left_front_mag_canve_queue;
+
 	deque<int> left_front_acc;
 	deque<int> right_front_acc;
 
@@ -30,9 +43,20 @@ private:
 	int last_front_down = 0;
 	int last_little_front_down = 0;
 
+	int left_top_back_press = 0;
+	int right_top_back_press = 0;
+
+	int top_back_press_valid_time = 0;
+
 	deque<int> left_front_press_queue_touch_floor;
 	deque<int> left_back_press_queue_touch_floor;
 
 	deque<int> right_front_press_queue_touch_floor;
 	deque<int> right_back_press_queue_touch_floor;
+
+	deque<int> right_front_jump_mag_queue;
+	deque<int> left_front_jump_mag_queue;
+
+	deque<int> right_acc_z_queue;
+	deque<int> left_acc_z_queue;
 };

+ 1 - 1
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/include/pub.h

@@ -43,7 +43,7 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.5.47"
+#define GAME_VERSION "0.5.56"
 
 enum CMD_MOTION
 {

+ 25 - 19
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Aerobics.cpp

@@ -62,11 +62,8 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 	down = 0;
 
-	if (extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
-		right_acc, left_acc))
-	{
-		down = 1;
-	}
+	down = extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
 
 	if (left_shoes_data_vector.size() == 1 && left_shoes_data_vector.back().zupt)
 	{
@@ -122,8 +119,8 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 	//会有多个蹲命令触发
 	//在这个游戏单独处理蹲
-	left_acc_deque.push_back(left_acc[2]);
-	right_acc_deque.push_back(right_acc[2]);
+	left_acc_deque.push_back(sqrt(left_acc[0] * left_acc[0] + left_acc[1] * left_acc[1]));
+	right_acc_deque.push_back(sqrt(right_acc[0] * right_acc[0] + right_acc[1] * right_acc[1]));
 
 	if (left_acc_deque.size() > 10)
 	{
@@ -148,26 +145,38 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	}
 	//std::cout << "time_stamp : " << time_stamp << endl;
 	//if (last_down == 0 && down == 1 && isValidDown(time_stamp))
-	if (last_down == 0 && down == 1 && wait_down == 0 && deny_down_time == 0)
+	//if (last_down == 0 && down != 0 && wait_down == 0 && deny_down_time == 0)
+	if (last_down == 0 && down != 0 && deny_down_time == 0)
 	{
-		//统计步数
-		//addMotionCount(DOWN_COUNT);
+		/*if (down & 0x04)
+		{
+			addMotionCount(DOWN_COUNT);
 
-		//std::cout << "normal down motion" << endl;
-		//result[0] = MOTION_DOWN;
+			std::cout << "normal down motion" << endl;
+			result[0] = MOTION_DOWN;
+			wait_down = 0;
+			deny_down_time = 20;
+		}
+		else*/
+		if(wait_down == 0 && deny_down_time == 0)
+		{
+			wait_down = 10;
+			deny_down_time = 20;
+		}
 
-		wait_down = 10;
-		deny_down_time = 20;
 		
 	}
 
 	if (wait_down == 1 && acc_valid == 1)
+	//if (wait_down == 1 )
 	//if(down)
 	{
 		addMotionCount(DOWN_COUNT);
 
 		std::cout << "normal down motion" << endl;
 		result[0] = MOTION_DOWN;
+
+		deny_down_time = 20;
 	}
 
 	if (wait_down > 0)
@@ -175,12 +184,9 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 		wait_down--;
 	}
 
-	if (deny_down_time > 0)
+	if (deny_down_time > 0 && down == 0)
 	{
-		if (!down)
-		{
-			deny_down_time--;
-		}
+		deny_down_time--;
 	}
 	
 	//判断踮脚蹲

+ 128 - 521
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/BuildHouse.cpp

@@ -2,63 +2,6 @@
 
 #include "BuildHouse.h"
 
-bool isUpDeque(deque<dualPressData>& dual_press,int &min_index, int deque_size)
-{
-	if (dual_press.size() != deque_size)
-	{
-		return false;
-	}
-
-	int max_left_val = dual_press.front().left_press;
-	int max_right_val = dual_press.front().right_press;
-
-	int max_left_index = 0;
-	int max_right_index = 0;
-
-	int min_left_val = dual_press.front().left_press;
-	int min_right_val = dual_press.front().right_press;
-
-	int min_left_index = 0;
-	int min_right_index = 0;
-
-
-	for (int i = 0; i < dual_press.size(); i++)
-	{
-		if (max_left_val < dual_press[i].left_press)
-		{
-			max_left_val = dual_press[i].left_press;
-			max_left_index = i;
-		}
-		if (max_right_val < dual_press[i].right_press)
-		{
-			max_right_val = dual_press[i].right_press;
-			max_right_index = i;
-		}
-
-		if (min_left_val > dual_press[i].left_press)
-		{
-			min_left_val = dual_press[i].left_press;
-			min_left_index = i;
-		}
-		if (min_right_val > dual_press[i].right_press)
-		{
-			min_right_val = dual_press[i].right_press;
-			min_right_index = i;
-		}
-
-	}
-
-	if (max_left_val - min_left_val > 50 && max_left_index > min_left_index &&
-		max_right_val - min_right_val > 50 && max_right_index > min_right_index)
-	{
-		min_index = max(min_left_index, min_right_index);
-
-		return true;
-	}
-
-	return false;
-}
-
 bool isValidAcc(deque<dualAccData>& dual_acc, int start_index,  int thresh_hold)
 {
 	int left_max_val = dual_acc[start_index].left_acc;
@@ -97,161 +40,10 @@ bool isValidAcc(deque<dualAccData>& dual_acc, int start_index,  int thresh_hold)
 	return false;
 }
 
-int isUptrendDeque(deque<dualPressData> &dual_press_front,int deque_size)
-{
-	int min_index = deque_size - 1;
-
 
 
-	if (deque_size > 4)
-	{
-		while (min_index > 3)
-		{
-			if ((dual_press_front[min_index].left_press < dual_press_front[min_index - 1].left_press
-				|| dual_press_front[min_index].left_press < dual_press_front[min_index - 2].left_press
-				|| dual_press_front[min_index].left_press < dual_press_front[min_index - 3].left_press) &&
-				(dual_press_front[min_index].right_press < dual_press_front[min_index - 1].right_press
-					|| dual_press_front[min_index].right_press < dual_press_front[min_index - 2].right_press
-					|| dual_press_front[min_index].right_press < dual_press_front[min_index - 3].right_press))
-			/*	&& dual_press_front[min_index].left_press > 10000
-				&& dual_press_front[min_index].right_press > 10000)*/
-			{
-				min_index--;
-			}
-			else
-			{
-				break;
-			}
-		}
 
-		if(  dual_press_front[deque_size - 1].left_press - dual_press_front[min_index].left_press < -2000
-			&& dual_press_front[deque_size - 1].right_press - dual_press_front[min_index].right_press < -2000)
-		{
-
-			return 1;
-		}
-	}
-	
-
-	return 0;
-}
-
-void setUptrendDequeFront(deque<dualPressData>& dual_press_front, deque<dualPressData>& front_press_left, deque<dualPressData>& front_press_right, int deque_size)
-{
-	if (dual_press_front.size() == deque_size)
-	{
-		int left_min_index = 0, left_max_index = 0;
-		int right_min_index = 0, right_max_index = 0;
-
-		int left_min_press = dual_press_front.front().left_press;
-		int right_min_press = dual_press_front.front().right_press;
-		
-		int left_max_press = left_min_press, right_max_press = right_min_press;
-		int i = 0;
-		std::for_each(dual_press_front.begin(), dual_press_front.end(), [&](dualPressData value) {
-			if (left_min_press > value.left_press) {
-				left_min_index = i; left_min_press = value.left_press;
-			}
-			if (right_min_press > value.right_press) {
-				right_min_index = i; right_min_press = value.right_press;
-			}
-			if (left_max_press < value.left_press) {
-				left_max_index = i; left_max_press = value.left_press;
-			}
-			if (right_max_press < value.right_press) {
-				right_max_index = i; right_max_press = value.right_press;
-			}
-			i++;
-			});
-
-		if (right_max_index > right_min_index && right_max_press > right_min_press)
-		{
-			//缓存上升区域
-			if (front_press_right.size() == 0)
-			{
-				for (int i = right_min_index; i < dual_press_front.size(); i++)
-				{
-					front_press_right.push_back(dual_press_front[i]);
-				}
-			}
-			else
-			{
-				front_press_right.push_back(dual_press_front.back());
-			}
-
-		}
-		else
-		{
-			front_press_right.clear();
-		}
-
-
-		if (left_max_index > left_min_index && left_max_press > left_min_press)
-		{
-			//缓存上升区域
-			if (front_press_left.size() == 0)
-			{
-				for (int i = left_min_index; i < dual_press_front.size(); i++)
-				{
-					front_press_left.push_back(dual_press_front[i]);
-				}
-			}
-			else
-			{
-				front_press_left.push_back(dual_press_front.back());
-			}
-
-		}
-		else
-		{
-			front_press_left.clear();
-		}
-	}
-}
-
-void detect_concave_curve_left(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
-{
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
-
-	right_size_index = k;
-
-	while (k > 1)
-	{
-		if (dual_press_back[k].left_press > dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press > dual_press_back[k - 2].left_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
-	}
-
-	min_index = k;
-
-	int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
-
-	while (k > 1)
-	{
-		if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press < dual_press_back[k - 2].left_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-	}
-
-	left_size_index = k;
-}
-
-void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
+void detect_cancave_curve_top(deque<int>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
 {
 	//1、寻找最小值
 	int k = dual_press_back.size() - 1;
@@ -260,9 +52,9 @@ void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& m
 
 	while (k > 2)
 	{
-		if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press - 50
-			|| dual_press_back[k].left_press < dual_press_back[k - 2].left_press
-			|| dual_press_back[k].left_press < dual_press_back[k - 3].left_press)
+		if (dual_press_back[k] < dual_press_back[k - 1] + 50
+			|| dual_press_back[k] < dual_press_back[k - 2]
+			|| dual_press_back[k] < dual_press_back[k - 3])
 		{
 			k--;
 		}
@@ -276,67 +68,12 @@ void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& m
 
 	max_index = k;
 
-	while (k > 2)
-	{
-		if (dual_press_back[k].left_press >= dual_press_back[k - 1].left_press
-			|| dual_press_back[k].left_press > dual_press_back[k - 2].left_press
-			|| dual_press_back[k].left_press > dual_press_back[k - 3].left_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-	}
-
-	left_size_index = k;
-
-	int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
-
-	while (k < max_index)
-	{
-		if (distance > abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press))
-		{
-			distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
-
-			left_size_index = k;
-		}
-		k++;
-	}
-}
-
-void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
-{
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
-
-	right_size_index = k;
-
-	while (k > 2)
-	{
-		if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press+50
-			|| dual_press_back[k].right_press < dual_press_back[k - 2].right_press
-			|| dual_press_back[k].right_press < dual_press_back[k - 3].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
-	}
-	
-	max_index = k;
-
 
 	while (k > 2)
 	{
-		if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press -50
-			|| dual_press_back[k].right_press > dual_press_back[k - 2].right_press
-			|| dual_press_back[k].right_press > dual_press_back[k - 3].right_press)
+		if (dual_press_back[k] > dual_press_back[k - 1] - 50
+			|| dual_press_back[k] > dual_press_back[k - 2]
+			|| dual_press_back[k] > dual_press_back[k - 3])
 		{
 			k--;
 		}
@@ -349,13 +86,13 @@ void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int&
 
 	left_size_index = k;
 
-	int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
+	int distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
 
 	while (k < max_index)
 	{
-		if (distance > abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press))
+		if (distance > abs(dual_press_back[k] - dual_press_back[right_size_index]))
 		{
-			distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
+			distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
 
 			left_size_index = k;
 		}
@@ -363,47 +100,7 @@ void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int&
 	}
 }
 
-void detect_concave_curve_right(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
-{
-	//1、寻找最小值
-	int k = dual_press_back.size() - 1;
-
-	right_size_index = k;
-
-	while (k > 1)
-	{
-		if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press > dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-
-
-	}
-
-	min_index = k;
-
-	int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
 
-	while (k > 1)
-	{
-		if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press
-			|| dual_press_back[k].right_press < dual_press_back[k - 2].right_press)
-		{
-			k--;
-		}
-		else
-		{
-			break;
-		}
-	}
-
-	left_size_index = k;
-}
 
 int mid_window_val(deque<int>& press_deque, int mid_window_size)
 {
@@ -423,6 +120,30 @@ int mid_window_val(deque<int>& press_deque, int mid_window_size)
 	return press_deque_temp[0];
 }
 
+int BuildHouse::back_press_up_trend(deque<int>& left_press_deque, deque<int>& right_press_deque)
+{
+	if (left_press_deque.size() > 20)
+	{
+		int i = left_press_deque.size() - 1;
+
+		while (i > 10 && (left_press_deque[i] >= left_press_deque[i - 1] || left_press_deque[i] >= left_press_deque[i - 2]
+			|| left_press_deque[i] >= left_press_deque[i - 3]) &&
+			(right_press_deque[i] >= right_press_deque[i - 1] || right_press_deque[i] >= right_press_deque[i - 2]
+				|| right_press_deque[i] >= right_press_deque[i - 3])
+			&& left_press_deque[i] > 12000 && right_press_deque[i] > 12000)
+		{
+			i--;
+		}
+
+		if (left_press_deque.back() > left_press_deque[i] + 1000&& right_press_deque.back() > right_press_deque[i] + 1000)
+		{
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
 void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_front_press, int right_back_press,
 	int* left_pos, int* left_att, int* left_acc, int left_zupt, int left_front_press, int left_back_press,
 	int jump, int down, int rssi)
@@ -440,7 +161,7 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 	left_press_filter_window.push_back(left_back_press);
 	right_press_filter_window.push_back(right_back_press);
 
-
+	//采用最小值滤波, 较好的过滤毛刺
 	if (left_press_filter_window.size() > 5)
 	{
 		left_press_filter_window.pop_front();
@@ -451,18 +172,20 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 
 	}
 
-	dual_press_back.push_back({ left_back_press, right_back_press ,time_stamp });
 
-	dual_press_front.push_back({ left_front_press , right_front_press , time_stamp });
 
-	if (dual_press_front.size() > 40)
+
+	left_front_press_queue.push_back(left_front_press); left_back_press_queue.push_back(left_back_press);
+	right_front_press_queue.push_back(right_front_press); right_back_press_queue.push_back(right_back_press);
+
+	if (left_back_press_queue.size() > 40)
 	{
-		dual_press_front.pop_front();
+		left_back_press_queue.pop_front(); right_back_press_queue.pop_front();
 	}
 
-	if (dual_press_back.size() > 40)
+	if (left_front_press_queue.size() > 40)
 	{
-		dual_press_back.pop_front();
+		left_front_press_queue.pop_front(); right_front_press_queue.pop_front();
 	}
 
 	if (dual_acc.size() > 10)
@@ -471,7 +194,7 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 	}
 
 
-	if (dual_press_front.size() == 40)
+	if (left_front_press_queue.size() == 40)
 	{
 		/*
 		*  检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
@@ -480,48 +203,50 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 
 		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
 
-		detect_concave_curve_left_top(dual_press_front, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
+		detect_cancave_curve_top(left_front_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
 
 		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
 		
-		detect_concave_curve_right_top(dual_press_front, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
+		detect_cancave_curve_top(right_front_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
 
-		int left_dist = 500, right_dist = 500;
+		int left_dist = 1000, right_dist = 1000;
 
 		if (wait_press_top_unvalid > 0)
 		{
 			left_dist = max(left_dist, left_front_press_top);
 			right_dist = max(right_dist, right_front_press_top);
 		}
+
+		bool acc_valid = isValidAcc(dual_acc, 0, 512);
 		//检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
 		if (abs(left_max_index - right_max_index) < 6 &&
-			dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -right_dist
-			&& dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -right_dist
-			&& dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -left_dist
-			&& dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -left_dist
+			right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -right_dist
+			&& right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -right_dist
+			&& left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -left_dist
+			&& left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -left_dist
 			&& right_foot_right_side_index - right_foot_left_side_index < 31
 			&& left_foot_right_side_index - left_foot_left_side_index < 31
-			&& isValidAcc(dual_acc, 0, 512)
+			&& acc_valid
 			//&& abs(dual_press_front[right_max_index].right_press - dual_press_front[left_max_index].left_press) < 8000//经验值
 			)
 		{
 			// 还要检测双凸曲线的顶点,如果还处于上一个双凸曲线的有效时间内,则顶点值与左右的差值需要大于上一个双凸曲线,才能判断有效的双凸曲线
 			// 记录上一个双凸曲线的差值
-			if (dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -1000
-				&& dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -1000
-				&& dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -1000
-				&& dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -1000)
+			if (right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -1000
+				&& right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -1000
+				&& left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -1000
+				&& left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -1000)
 			{
-				int right_dist = dual_press_front[right_max_index].right_press - dual_press_front[right_foot_right_side_index].right_press;
+				int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
 
-				right_dist = min(right_dist, dual_press_front[right_max_index].right_press - dual_press_front[right_foot_left_side_index].right_press);
+				right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
 
 				//right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
 				right_front_press_top = 0.5 * right_dist;
 
-				int left_dist = dual_press_front[left_max_index].left_press - dual_press_front[left_foot_right_side_index].left_press;
+				int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
 
-				left_dist = min(left_dist, dual_press_front[left_max_index].left_press - dual_press_front[left_foot_left_side_index].left_press);
+				left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
 
 				//left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
 				left_front_press_top =  0.5 * left_dist;
@@ -533,136 +258,97 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 			front_down = 1;
 		}
 
-		//int i = dual_press_front.size() - 1;
-		//for (; i > dual_press_front.size() - 15; i--)
-		//{
-		//	/*if (dual_press_front[i].left_press > dual_press_front[i - 1].left_press
-		//		&& dual_press_back[i].left_press > dual_press_back[i - 1].left_press
-		//		&& dual_press_front[i].right_press > dual_press_front[i - 1].right_press
-		//		&& dual_press_back[i].right_press > dual_press_back[i - 1].right_press)*/
-		//	if ((dual_press_front[i].left_press < dual_press_front[i - 1].left_press || dual_press_front[i].left_press < dual_press_front[i - 2].left_press)
-		//		&& (dual_press_front[i].right_press < dual_press_front[i - 1].right_press || dual_press_front[i].right_press < dual_press_front[i - 2].right_press))
-		//	{
-		//		continue;
-		//	}
-		//	else
-		//	{
-		//		break;
-		//	}
-		//}
-
-		////曲线有在15个数据处于上升曲线,则判断为前蹲
-		//if (
-		//	  dual_press_front.back().left_press < dual_press_front[i].left_press - 1200
-		//	&& dual_press_front.back().right_press < dual_press_front[i].right_press - 1200)
-		//{
-		//	front_down = 1;
-		//}
-		//延续前蹲的操作
-	/*	if (last_front_down == 1 &&
-			(dual_press_front[39].left_press < dual_press_front[38].left_press || dual_press_front[39].left_press < dual_press_front[37].left_press)
-			&& (dual_press_front[39].right_press < dual_press_front[38].right_press || dual_press_front[39].right_press < dual_press_front[37].right_press))
+		if ( left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -2000
+			&& right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -2000
+			&& left_foot_right_side_index - left_max_index < 30 && right_foot_right_side_index - right_max_index < 30
+			)
 		{
-			front_down = 1;
-		}*/
-	}
 
-	int back_down = 0;
-	if (dual_press_back.size()==40)
-	{
-		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
+			int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
 
-		detect_concave_curve_left_top(dual_press_back, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
+			right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
 
-		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
+			//right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
+			right_front_press_top = 0.5 * right_dist;
 
-		detect_concave_curve_right_top(dual_press_back, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
+			int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
 
+			left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
 
-		int special_down = 0;
+			//left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
+			left_front_press_top = 0.5 * left_dist;
 
-		//同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
-		if (
-			abs(left_max_index - right_max_index) < 11 &&
-			dual_press_back[right_foot_right_side_index].right_press - dual_press_back[right_max_index].right_press < -1000
-			&& dual_press_back[right_foot_left_side_index].right_press - dual_press_back[right_max_index].right_press < -1000
-			&& dual_press_back[left_foot_right_side_index].left_press - dual_press_back[left_max_index].left_press < -1000
-			&& dual_press_back[left_foot_left_side_index].left_press - dual_press_back[left_max_index].left_press < -1000
-			
-			&& dual_press_back[right_max_index].right_press > 7500 && dual_press_back[left_max_index].left_press > 7500
-			 
-			)
-		{
-			back_down = 1;
-			//special_down = 1;
+			wait_press_top_unvalid = 60;
+
+			front_down = 1;
 		}
 
 	}
 
-	//尝试降采样来一次
-
-	if (dual_press_back.size() == 40)
+	int back_down = 0;
+	if (left_back_press_queue.size()>=20 )
 	{
+		 back_down = back_press_up_trend(left_back_press_queue, right_back_press_queue);
 
-		deque<dualPressData> dual_press_back_temp;
-
-		for (int i = 0; i < dual_press_back.size(); i+=3)
+		if (back_down)
 		{
-			dual_press_back_temp.push_back(dual_press_back[i]);
-		}
+			//记录最大值
+			if (wait_back_press_top_unvalid == 0)
+			{
+				wait_back_press_top_unvalid = 60;
 
+				left_back_press_top = left_back_press_queue.back();
+				right_back_press_top = right_back_press_queue.back();
 
-		int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
+			}
+			else
+			{
+				if (left_back_press_top > left_back_press_queue.back() || right_back_press_top > right_back_press_queue.back())
+				{
+					back_down = 0;
+				}
+				else
+				{
+					wait_back_press_top_unvalid = 60;
 
-		detect_concave_curve_left_top(dual_press_back_temp, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
+					left_back_press_top = left_back_press_queue.back();
+					right_back_press_top = right_back_press_queue.back();
+				}
+			}
+		}
 
-		int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
+		//int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
 
-		detect_concave_curve_right_top(dual_press_back_temp, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
+		//detect_cancave_curve_top(left_back_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
 
+		//int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
 
-		int special_down = 0;
+		//detect_cancave_curve_top(right_back_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
 
-		//同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
-		if (
-			abs(left_max_index - right_max_index) < 11 &&
-			dual_press_back_temp[right_foot_right_side_index].right_press - dual_press_back_temp[right_max_index].right_press < -1500
-			&& dual_press_back_temp[right_foot_left_side_index].right_press - dual_press_back_temp[right_max_index].right_press < -1000
-			&& dual_press_back_temp[left_foot_right_side_index].left_press - dual_press_back_temp[left_max_index].left_press < -1500
-			&& dual_press_back_temp[left_foot_left_side_index].left_press - dual_press_back_temp[left_max_index].left_press < -1000
 
-			&& dual_press_back_temp[right_max_index].right_press > 7500 && dual_press_back_temp[left_max_index].left_press > 7500
+		//int special_down = 0;
 
-			)
-		{
-			back_down = 1;
-			//special_down = 1;
-		}
+		////同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
+		//if (
+		//	abs(left_max_index - right_max_index) < 11 &&
+		//	right_back_press_queue[right_foot_right_side_index] - right_back_press_queue[right_max_index] < -1500
+		//	&& right_back_press_queue[right_foot_left_side_index] - right_back_press_queue[right_max_index] < -1500
+		//	&& left_back_press_queue[left_foot_right_side_index] - left_back_press_queue[left_max_index] < -1500
+		//	&& left_back_press_queue[left_foot_left_side_index] - left_back_press_queue[left_max_index] < -1500
+		//	&& right_back_press_queue[right_max_index] > 12000 && left_back_press_queue[left_max_index] > 12000
+		//	)
+		//{
+		//	back_down = 1;
+		//}
 
 	}
-
-
-
-	/*if (front_down == 1)
-	{
-		front_down_cmd_wait_time = 10;
-	}*/
-
-	if (front_down_cmd_wait_time > 0)
+	if (wait_back_press_top_unvalid > 0)
 	{
-		front_down = 1;
-		//result[0] = MOTION_DOWN;
+		wait_back_press_top_unvalid--;
 	}
 
-	//if (back_down == 1)
-	//{
-	//	back_down_cmd_wait_time = 10;
-	//}
 
-	if(back_down_cmd_wait_time > 0)
-	{
-		back_down = 1;
-	}
+
 
 	if (wait_press_top_unvalid > 0)
 	{
@@ -674,53 +360,8 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 		wait_press_top_unvalid--;
 	}
 
-	if (wait_back_press_top_unvalid > 0)
-	{
-		wait_back_press_top_unvalid--;
-
-	}
-
-	if ( dual_press_front.size()==40)
-	{
-		int size = dual_press_front.size()-1;
-		
-		deque<dualPressData>::iterator left_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.left_press < val2.left_press; });
-
-		deque<dualPressData>::iterator left_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.left_press <  val2.left_press; });
-
-		deque<dualPressData>::iterator right_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
-
-		deque<dualPressData>::iterator right_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
-			[](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
-
-		//如果判断上一个任意下蹲情况,当前发现是前脚眼里上升,则视为前脚下蹲状态
-		/*if (left_max_it - left_min_it > 0 && left_max_it->left_press - left_min_it->left_press > 50
-			&& right_max_it - right_min_it > 0 && right_max_it->right_press - right_min_it->right_press > 50)
-		{
-			if (last_front_down == 1 || last_down == 1)
-			{
-				front_down = 1;
-			}
-
-		}*/
-
-		/*if((dual_press_front[size].left_press > dual_press_front[size - 1].left_press || dual_press_front[size].left_press > dual_press_front[size - 2].left_press)
-			&& (dual_press_front[size].right_press > dual_press_front[size - 1].right_press || dual_press_front[size].right_press > dual_press_front[size - 2].right_press))
-		{
-			if (last_front_down == 1 || last_down == 1)
-			{
-				front_down = 1;
-			}
-		}*/
-	}
-
-	
-
-	
 	if ((front_down == 1 || back_down == 1) && (last_down == 0 && last_front_down == 0) && cmd_wait_time == 0)
+	//if((front_down == 1 || back_down == 1))
 	{
 		result[0] = MOTION_DOWN;
 
@@ -729,53 +370,19 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
 		cmd_wait_time = 20;
 	}
 
-	/*if (( back_down == 1))
-	{
-		result[0] = MOTION_DOWN;
-	}*/
-
+	//处于蹲的倒计时,倒计时就不要工作了
 	if (!(front_down == 1 || back_down == 1) && cmd_wait_time > 0)
 	{
 		cmd_wait_time--;
 
 	}
 
-
-	//if (cmd_wait_time > 0)
-	//{
-	//	cmd_wait_time--;
-
-	//	back_down_continue_time++;
-
-	//}
-
-	if (front_down_cmd_wait_time > 0)
-	{
-		front_down_cmd_wait_time--;
-
-		front_down_continue_time++;
-	}
-	else
-	{
-		front_down_continue_time = 0;
-	}
-
-	if (front_down_continue_time == 30)
-	{
-		front_down_continue_time = 0;
-		front_down_cmd_wait_time = 0;
-		front_down = 0;
-	}
-
-	if (back_down_cmd_wait_time > 0)
-	{
-		back_down_cmd_wait_time--;
-		back_down_continue_time++;
-
-	}
-
 	last_down = back_down;
 
 	last_front_down = front_down;
+
+
+	//result[1] = left_back_press;
+	//result[2] = right_back_press;
 	
 }

+ 22 - 22
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/FootStep.cpp

@@ -51,7 +51,7 @@ void calStepFreq(vector<FLOOR_TIME_STYPE>& time_vector, float &mean_step_vel)
 
 	if (length < 2)
 	{
-//		cout << "FootStep::calStepFreq vector_length < 2" << endl;
+		cout << "FootStep::calStepFreq vector_length < 2" << endl;
 
 		return;
 	}
@@ -63,18 +63,18 @@ void calStepFreq(vector<FLOOR_TIME_STYPE>& time_vector, float &mean_step_vel)
 	if (cur_floor_time_stype.time_type != LEAVE_TIME_STYPE || last_floor_time_stype.time_type != LEAVE_TIME_STYPE
 		|| time_vector[length - 2].time_type != CATCH_TIME_STYPE)
 	{
-//		cout << "FootStep::calStepFreq time_stype is not valid " << endl;
+		cout << "FootStep::calStepFreq time_stype is not valid " << endl;
 
 		for (int i = 0; i < length; i++)
 		{
 			cout << time_vector[i].time << ", ";
 			if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 			{
-//				cout << "LEAVE_TIME_STYPE," << endl;
+				cout << "LEAVE_TIME_STYPE," << endl;
 			}
 			else
 			{
-//				cout << "CATCH_TIME_STYPE," << endl;
+				cout << "CATCH_TIME_STYPE," << endl;
 			}
 		}
 	}
@@ -102,7 +102,7 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 	vector<FLOOR_TIME_STYPE> time_vector_tmp(time_vector);
 
-//	cout << "FootStep::time_vector before" << endl;
+	cout << "FootStep::time_vector before" << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -110,11 +110,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, ";
+			cout << "LEAVE_TIME_STYPE, ";
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -134,12 +134,12 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 		}
 		else
 		{
-//			std::cout << "delect time_vector_tmp cell " << endl;
+			std::cout << "delect time_vector_tmp cell " << endl;
 		}
 
 	}
 
-//	cout << "FootStep::time_vector mid " << endl;
+	cout << "FootStep::time_vector mid " << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -148,11 +148,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, " ;
+			cout << "LEAVE_TIME_STYPE, " ;
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -172,7 +172,7 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 		index++;
 	}
 
-//	cout << "FootStep::time_vector end" << endl;
+	cout << "FootStep::time_vector end" << endl;
 
 	for (int i = 0; i < time_vector.size(); i++)
 	{
@@ -181,11 +181,11 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 
 		if (time_vector[i].time_type == LEAVE_TIME_STYPE)
 		{
-//			cout << "LEAVE_TIME_STYPE, ";
+			cout << "LEAVE_TIME_STYPE, ";
 		}
 		else
 		{
-//			cout << "CATCH_TIME_STYPE, ";
+			cout << "CATCH_TIME_STYPE, ";
 		}
 	}
 	cout << endl;
@@ -338,31 +338,31 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 
 				step_vel_buff[2] = mean_vel;
 
-//				cout << "now step mean_vel is " << mean_vel << endl;
+				cout << "now step mean_vel is " << mean_vel << endl;
 
 				mean_window_vel = (step_vel_buff[0] + step_vel_buff[1] + step_vel_buff[2]) / 3.0f;
 
 				stepFreq = mean_window_vel * 60;
 
-//				cout << "now step mean_window_vel is " << mean_window_vel << endl;
+				cout << "now step mean_window_vel is " << mean_window_vel << endl;
 
 				memcpy(vel_sqrt_buff, vel_sqrt_buff + 1, 2 * sizeof(float));
 
 				vel_sqrt_buff[2] = vel_sqrt_sum / vel_sqrt_num * mean_vel;
 
-//				cout << "now step vel_sqrt_buff_mean is " << (vel_sqrt_buff[0] + vel_sqrt_buff[1] + vel_sqrt_buff[2]) / 3.0f << endl;
+				cout << "now step vel_sqrt_buff_mean is " << (vel_sqrt_buff[0] + vel_sqrt_buff[1] + vel_sqrt_buff[2]) / 3.0f << endl;
 
 				vel_sqrt_sum = 0;
 				vel_sqrt_num = 0;
 
 				stepCount++;
 
-//				std::cout << "step_count : " << stepCount << endl;
+				std::cout << "step_count : " << stepCount << endl;
 			}
 
 			leave_time_wait = 0;
 
-//			std::cout << "leave_time_wait = 0;" << endl;
+			std::cout << "leave_time_wait = 0;" << endl;
 		}
 
 		leave_time_wait--;
@@ -410,9 +410,9 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 
 		stepFreq = mean_window_vel * 60;
 
-//		cout << "stop signal : now step mean_window_vel is " << mean_window_vel <<endl;
+		cout << "stop signal : now step mean_window_vel is " << mean_window_vel <<endl;
 
-//		cout << step_vel_buff[0] << ", " << step_vel_buff[1] << ", " << step_vel_buff[2] << endl;
+		cout << step_vel_buff[0] << ", " << step_vel_buff[1] << ", " << step_vel_buff[2] << endl;
 
 		zuptCount = 0;
 
@@ -447,4 +447,4 @@ int FootStep::getStepStatus()
 int FootStep::getStepCount()
 {
 	return stepCount;
-}
+}

+ 5 - 0
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Kongfu.cpp

@@ -106,6 +106,11 @@ void Kongfu::Process(int time_stamp, int* right_pos, int* right_att, int* right_
 	setData(left_shoes_data_vector, time_stamp, left_pos[0] * 0.001f, left_pos[1] * 0.001f, left_pos[2] * 0.001f,
 		left_att[0] * 0.0001f, left_att[1] * 0.0001f, left_att[2] * 0.0001f, left_zupt, rssi);
 
+	down = 0;
+
+	down = extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
+
 	//ÉèÖÃÖØÖÃΪ-1
 	result[0] = -1;
 	result[1] = -1;

+ 48 - 21
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/RunGame.cpp

@@ -10,6 +10,8 @@ RunGame::RunGame()
 
 	last_left_zupt = 1;
 	last_right_zupt = 1;
+
+	last_canva_down = 0;
 }
 
 
@@ -21,11 +23,21 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 {
 
 	// 额外处理蹲
-	if (extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
-		right_acc, left_acc))
+	down = 0;
+	int online_down = extract_motion.online_detect_down(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
+	if (online_down)
 	{
-		down = 1;
+		down = online_down;
 	}
+
+	int online_jump = extract_motion.online_detect_jump(right_front_press, left_front_press, right_back_press, left_back_press,
+		right_acc, left_acc);
+	if (online_jump)
+	{
+		jump = online_jump;
+	}
+
 	//存放一步的空中数据到shoes_data_vector 队列中, 头必须是触地时刻信息
 	setData(right_shoes_data_vector, time_stamp, right_pos[0] * 0.001f, right_pos[1] * 0.001f, right_pos[2] * 0.001f,
 		right_att[0] * 0.0001f, right_att[1] * 0.0001f, right_att[2] * 0.0001f, right_zupt, rssi);
@@ -114,6 +126,8 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 
 	int down_cmd = -1;
 
+	result[3] = -1;
+
 	down_cmd = getResultDown(down);
 
 
@@ -142,27 +156,35 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 		}
 	}
 
-	if (down_cmd == MOTION_DOWN)
+	if (down_cmd == 1)
 	{
 		wait_down = 10;
 	}
+	if (down_cmd == MOTION_DOWN)
+	{
+		addMotionCount(DOWN_COUNT);
+
+		down_wait_after_jump = 20;
+
+		result[3] = MOTION_DOWN;
 
-	if (wait_down > 0  && acc_valid == 1)
+		wait_down = 0;
+	}
+
+	if (wait_down == 1  && acc_valid == 1)
 	//if (wait_down == 10)
 	//if(down)
 	{
 
 		addMotionCount(DOWN_COUNT);
 
-		std::cout << "RUNGAME:: MOTION_DOWN" << endl;
+		down_wait_after_jump = 20;
+
 		result[3] = MOTION_DOWN;
 
 		wait_down = 0;
 	}
-	else
-	{
-		result[3] = -1;
-	}
+
 
 	if (wait_down > 0)
 	{
@@ -203,28 +225,30 @@ int RunGame::getResultDown(int down)
 {
 	int isDown = -1;
 
+	int canva_down = ((down & 0x04) > 0 ? 1 : 0);
+	
 
-	if (last_down == 0 && down == 1 && down_wait_after_jump < 0)
-	//if ( last_down == 0 && down == 1)
+
+	if (last_canva_down == 0 && canva_down == 1 && down_wait_after_jump < 0)
+	//if (last_canva_down == 0 && canva_down == 1 )
 	{
 		isDown = MOTION_DOWN;
-
-		down_wait_after_jump = 10;
+	}
+	else if (last_down == 0 && down > 0 && down_wait_after_jump < 0)
+	//if ( last_down == 0 && down == 1)
+	{
+		isDown = 1;
 
 		//addMotionCount(DOWN_COUNT);
 
 		//std::cout << "motion : down" << std::endl;
 
-		down_count++;
+		//down_count++;
 	}
 	/*
 	* down_wait_after_jump:避免前脚蹲后,接着后脚压下来的情况,当down_wait_after_jump == -1时候,判断蹲生效
 	* 当一直处于蹲的时候,额外加拖延时间,在这个时间不允许触发蹲。
 	*/
-	/*if (down && down_wait_after_jump < 0)
-	{
-		down_wait_after_jump = 10;
-	}*/
 
 	if (down == 0 && down_wait_after_jump >=0)
 	{
@@ -233,13 +257,16 @@ int RunGame::getResultDown(int down)
 
 	last_down = down;
 
+	last_canva_down = canva_down;
+
+
 	return isDown;
 
 }
 
 int RunGame::getResultJump(int jump)
 {
-	int isJump = -1;
+	int isJump = 0;
 
 	if (last_jump == 0 && jump == 1)
 	{
@@ -256,7 +283,7 @@ int RunGame::getResultJump(int jump)
 	*/
 	if (jump)
 	{
-		down_wait_after_jump = 10;
+		down_wait_after_jump = 20;
 	}
 
 	last_jump = jump;

+ 24 - 1
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/Tricycle.cpp

@@ -39,6 +39,27 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 {
 	//1¡¢È·¶¨³õʼµÄ·½Ïò
 
+
+	if (left_acc_z_queue.size() > 10)
+	{
+		left_acc_z_queue.pop_front();
+		right_acc_z_queue.pop_front();
+	}
+	
+	left_acc_z_queue.push_back(left_acc[2]);
+	right_acc_z_queue.push_back(right_acc[2]);
+
+	if (has_init == 0)
+	{
+		if (*(max_element(left_acc_z_queue.begin(), left_acc_z_queue.end())) - *(min_element(left_acc_z_queue.begin(), left_acc_z_queue.end())) < 102
+			&& *(max_element(right_acc_z_queue.begin(), right_acc_z_queue.end())) - *(min_element(right_acc_z_queue.begin(), right_acc_z_queue.end())) < 102)
+		{
+			left_zupt = 1;
+			right_zupt = 1;
+		}
+	}
+
+
 	if (left_zupt)
 	{
 		left_zupt_count++;
@@ -204,6 +225,8 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	result[2] = (down_prop == 1 ? MOTION_JUMP_OC : -1);
 	result[3] = (up_prop == 1 ? MOTION_JUMP_VERTICAL : -1);
 
+	result[4] = left_att[0];
+
 	if (has_init == 0)
 	{
 		/*result[0] = 0;
@@ -215,7 +238,7 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 float Tricycle::calHeadingOffset(float init_heading, float cur_heading)
 {
-	float heading_offset = cur_heading - init_heading;
+	float heading_offset = (cur_heading  - init_heading);
 
 	if (heading_offset > PI)
 	{

+ 197 - 51
Paoku_ios_20220923/Classes/SDK/shoes_sdk_3.0/src/online_motion.cpp

@@ -62,9 +62,68 @@ void top_point(deque<int> &left_front_mag_queue , int &top_index, int &left_inde
 
 }
 
+//最小值滤波
+int online_motion::min_window_val(deque<int>& press_deque, int mid_window_size)
+{
+	deque<int> press_deque_temp = press_deque;
+
+	if (press_deque_temp.size() >= mid_window_size)
+	{
+		std::sort(press_deque_temp.begin(), press_deque_temp.end());
+	}
+	else
+	{
+		return press_deque.back();
+	}
+
+	//return press_deque[press_deque_temp.size() / 2];
+
+	return press_deque_temp[0];
+}
+
+int online_motion::back_press_up_trend(deque<int>& left_press_deque, deque<int>& right_press_deque)
+{
+	if (left_press_deque.size() >= 20)
+	{
+		int i = left_press_deque.size() - 1;
+
+		while (i > 10 && (left_press_deque[i] >= left_press_deque[i - 1] || left_press_deque[i] >= left_press_deque[i - 2]
+			|| left_press_deque[i] >= left_press_deque[i - 3]) &&
+			(right_press_deque[i] >= right_press_deque[i - 1] || right_press_deque[i] >= right_press_deque[i - 2]
+				|| right_press_deque[i] >= right_press_deque[i - 3])
+			&& left_press_deque[i] > 12000 && right_press_deque[i] > 12000)
+		{
+			i--;
+		}
+
+		if (left_press_deque.back() > left_press_deque[i] + 1000 && right_press_deque.back() > right_press_deque[i] + 1000)
+		{
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
 int online_motion::online_detect_down(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag,
 	int* right_acc, int* left_acc)
 {
+
+	//滑动窗口补充
+	left_press_filter_window.push_back(left_back_mag);
+	right_press_filter_window.push_back(right_back_mag);
+
+	//采用最小值滤波, 较好的过滤毛刺
+	if (left_press_filter_window.size() > 5)
+	{
+		left_press_filter_window.pop_front();
+		right_press_filter_window.pop_front();
+
+		left_back_mag = min_window_val(left_press_filter_window, 5);
+		right_back_mag = min_window_val(right_press_filter_window, 5);
+
+	}
+
 	if (right_back_mag_queue.size() > 20)
 	{
 		right_back_mag_queue.pop_front();
@@ -83,9 +142,13 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	right_front_mag_queue.push_back(right_front_mag);
 	left_front_mag_queue.push_back(left_front_mag);
 
+	/*left_front_acc.push_back(left_acc[2]);
+	right_front_acc.push_back(right_acc[2]);*/
+
 	left_front_acc.push_back(sqrt(left_acc[0] * left_acc[0] + left_acc[1] * left_acc[1]));
 	right_front_acc.push_back(sqrt(right_acc[0] * right_acc[0] + right_acc[1] * right_acc[1]));
 
+
 	deque<int> right_back_temp{ right_back_mag };
 	deque<int> left_back_temp{ left_back_mag };
 
@@ -96,39 +159,42 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	int right_acc_z_min = right_front_acc.back();
 
 	int back_down = 0;
-	if (right_back_mag_queue.size() > 20)
+	if (right_back_mag_queue.size() >= 20)
 	{
-		int i = right_back_mag_queue.size() - 2;
-		for ( i = right_back_mag_queue.size() - 1; i > 2; i--)
-		{
-			//if (right_back_mag_queue[i] > right_back_temp.front() || left_back_mag_queue[i] > left_back_temp.front())
+		back_down = back_press_up_trend(left_back_mag_queue, right_back_mag_queue);
 
-
-			if ((left_back_mag_queue[i] > left_back_mag_queue[i - 1] || left_back_mag_queue[i] > left_back_mag_queue[i - 2]
-				|| left_back_mag_queue[i] > left_back_mag_queue[i - 3]) &&
-				(right_back_mag_queue[i] > right_back_mag_queue[i - 1] || right_back_mag_queue[i] > right_back_mag_queue[i - 2]
-					|| right_back_mag_queue[i] > right_back_mag_queue[i - 3]))
+		if (back_down)
+		{
+			if (top_back_press_valid_time == 0)
 			{
-				right_back_temp.push_back(right_back_mag_queue[i]);
-				left_back_temp.push_back(left_back_mag_queue[i]);
+				left_top_back_press = left_back_mag_queue.back();
+				right_top_back_press = right_back_mag_queue.back();
+
+				top_back_press_valid_time = 60;
 			}
 			else
 			{
-				break;
-			}
-		}
 
-		if (*max_element(left_front_acc.begin(), left_front_acc.end()) - *min_element(left_front_acc.begin(), left_front_acc.end()) < 256
-			&& *max_element(right_front_acc.begin(), right_front_acc.end()) - *min_element(right_front_acc.begin(), right_front_acc.end()) < 256)
-		{
-			if (left_back_temp.size() > 5 && right_back_temp.size() > 5 && left_back_temp.front() > left_back_temp.back() + 2000
-				&& right_back_temp.front() > right_back_temp.back() + 2000 && abs(left_back_temp.front() - right_back_temp.front()) < 6000)
-			{
-				back_down = 1;
+				if (left_top_back_press > left_back_mag_queue.back() || right_top_back_press > right_back_mag_queue.back())
+				{
+					back_down = 0;
+				}
+				else
+				{
+					left_top_back_press = left_back_mag_queue.back();
+					right_top_back_press = right_back_mag_queue.back();
+
+					top_back_press_valid_time = 60;
+				}
 			}
 		}
 	}
 
+	if (top_back_press_valid_time > 0)
+	{
+		top_back_press_valid_time--;
+	}
+
 
 	 deque<int> right_front_temp{ right_front_mag };
 	 deque<int> left_front_temp{ left_front_mag };
@@ -143,7 +209,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	
 	int front_down = 0;
 	if (right_front_mag_queue.size() > 20)
-	for (int i = right_front_mag_queue.size() - 1; i >2 ; i--)
+	for (int i = right_front_mag_queue.size() - 1; i > right_front_mag_queue.size() -11; i--)
 	{
 		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1]+100 || left_front_mag_queue[i] > left_front_mag_queue[i - 2] + 100
 			|| left_front_mag_queue[i] > left_front_mag_queue[i - 3]) + 100 &&
@@ -162,7 +228,8 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 			&& *max_element(right_front_acc.begin() , right_front_acc.end()) - *min_element(right_front_acc.begin() , right_front_acc.end()) < 256)
 		{
 			if (right_front_temp.size() > 5 && left_front_temp.size() > 5 && left_front_temp.front() >  left_front_temp.back() + 1500
-				&& right_front_temp.front() > right_front_temp.back() + 1500)
+				&& right_front_temp.front() > right_front_temp.back() + 1500
+				&& abs(left_front_temp.front() - right_front_temp.front()) < 6000)
 			{
 				front_down = 1;
 			}
@@ -174,39 +241,64 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	int little_front_down = 0;
 
 
-	if (right_front_mag_queue.size() == 21)
+
+	if (left_front_acc.size() > 20)
+	{
+		if (*max_element(left_front_acc.end() - 5, left_front_acc.end())
+			- *min_element(left_front_acc.end() - 5, left_front_acc.end()) < 256
+			&& *max_element(right_front_acc.end() - 5, right_front_acc.end())
+			- *min_element(right_front_acc.end() - 5, right_front_acc.end()) < 256)
+		{
+	
+			if (right_front_mag_canve_queue.size() == 0)
+			{
+				for (int k = right_front_mag_queue.size() - 6; k < right_front_mag_queue.size(); k++)
+				{
+					right_front_mag_canve_queue.push_back(right_front_mag_queue[k]);
+					left_front_mag_canve_queue.push_back(left_front_mag_queue[k]);
+				}
+			}
+			else
+			{
+				right_front_mag_canve_queue.push_back(right_front_mag_queue.back());
+				left_front_mag_canve_queue.push_back(left_front_mag_queue.back());
+			}
+
+		}
+		else
+		{
+			right_front_mag_canve_queue.clear();
+			left_front_mag_canve_queue.clear();
+		}
+	}
+
+	if (right_front_mag_canve_queue.size() > 20)
+	{
+		right_front_mag_canve_queue.pop_front();
+		left_front_mag_canve_queue.pop_front();
+	}
+
+
+	if (left_front_mag_canve_queue.size() > 9)
 	{
 		//1、补充蹲,检测到一个完成的波视为蹲就好
 
 		int left_top_index;
 		int left_foot_left_side_index, left_foot_right_side_index;
-		top_point(left_front_mag_queue, left_top_index, left_foot_left_side_index, left_foot_right_side_index);
+		top_point(left_front_mag_canve_queue, left_top_index, left_foot_left_side_index, left_foot_right_side_index);
 
 		int right_top_index;
 		int right_foot_left_side_index, right_foot_right_side_index;
-		top_point(right_front_mag_queue, right_top_index, right_foot_left_side_index, right_foot_right_side_index);
+		top_point(right_front_mag_canve_queue, right_top_index, right_foot_left_side_index, right_foot_right_side_index);
 
 		if (
 			abs(left_top_index - right_top_index) < 4    //保持定点位置不要相差太多
-			&&left_front_mag_queue[left_top_index] > left_front_mag_queue[left_foot_left_side_index] + 500
-			&& left_front_mag_queue[left_top_index] > left_front_mag_queue[left_foot_right_side_index] + 500
-
-			&& right_front_mag_queue[right_top_index] > right_front_mag_queue[right_foot_left_side_index] + 500
-			&& right_front_mag_queue[right_top_index] > right_front_mag_queue[right_foot_right_side_index] + 500
-
-			//&& abs(left_front_mag_queue[left_foot_left_side_index] - left_front_mag_queue[left_foot_right_side_index]) < 500
-			//&& abs(right_front_mag_queue[right_foot_left_side_index] - right_front_mag_queue[right_foot_right_side_index]) < 500
-
-			//&& left_foot_right_side_index - left_top_index > 1 
-			//&& right_foot_right_side_index - right_top_index > 1
-			)
+			&& left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_left_side_index] + 800
+			&& left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_right_side_index] + 800
+			&& right_front_mag_canve_queue[right_top_index] > right_front_mag_canve_queue[right_foot_left_side_index] + 800
+			&& right_front_mag_canve_queue[right_top_index] > right_front_mag_canve_queue[right_foot_right_side_index] + 800)
 		{
-
-			if (*max_element(left_front_acc.begin(), left_front_acc.end()) - *min_element(left_front_acc.begin(), left_front_acc.end()) < 256
-				&& *max_element(right_front_acc.begin(), right_front_acc.end()) - *min_element(right_front_acc.begin(), right_front_acc.end()) < 256)
-			{
-				little_front_down = 1;
-			}
+			little_front_down = 1;
 		}
 	}
 
@@ -214,10 +306,8 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	{
 		int i = right_front_mag_queue.size() - 1;
 
-		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1] || left_front_mag_queue[i] > left_front_mag_queue[i - 2]
-			|| left_front_mag_queue[i] > left_front_mag_queue[i - 3]) &&
-			(right_front_mag_queue[i] > right_front_mag_queue[i - 1] || right_front_mag_queue[i] > right_front_mag_queue[i - 2]
-				|| right_front_mag_queue[i] < right_front_mag_queue[i - 3]))
+		if ((left_front_mag_queue[i] > left_front_mag_queue[i - 1] ) &&
+			(right_front_mag_queue[i] > right_front_mag_queue[i - 1]))
 		{
 			if (last_back_down || last_front_down)
 			{
@@ -258,7 +348,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 
 	if (little_front_down == 1)
 	{
-		res |= 0x01;
+		res |= 0x04;
 	}
 
 	last_back_down = back_down;
@@ -333,4 +423,60 @@ int online_motion::online_detect_touch_floor(int right_front_mag, int left_front
 	return  right_foot_on_floor << 1 | left_foot_on_floor;
 
 
-}
+}
+
+
+/*
+* 在线检测跳
+*/
+
+int online_motion::online_detect_jump(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag,
+	int* right_acc, int* left_acc)
+{
+	right_front_jump_mag_queue.push_back(right_front_mag);
+	left_front_jump_mag_queue.push_back(left_front_mag);
+
+	right_acc_z_queue.push_back(right_acc[2]);
+	left_acc_z_queue.push_back(left_acc[2]);
+
+	if (right_front_jump_mag_queue.size() > 10)
+	{
+		right_front_jump_mag_queue.pop_front();
+		left_front_jump_mag_queue.pop_front();
+
+		right_acc_z_queue.pop_front();
+		left_acc_z_queue.pop_front();
+	}
+
+	int k = left_front_jump_mag_queue.size() - 1;
+	while (k > 0)
+	{
+		if (!(left_front_jump_mag_queue[k] < left_front_jump_mag_queue[k - 1] + 100
+			&& right_front_jump_mag_queue[k] < right_front_jump_mag_queue[k - 1] + 100))
+		{
+			break;
+		}
+		k--;
+	}
+
+	int res = 0;
+
+	if (left_front_jump_mag_queue[k] - left_front_jump_mag_queue.back() > 4000
+		&& right_front_jump_mag_queue[k] - right_front_jump_mag_queue.back() > 4000)
+	{
+		auto left_max_element = max_element(left_acc_z_queue.begin(), left_acc_z_queue.end());
+		auto left_min_element = min_element(left_acc_z_queue.begin(), left_acc_z_queue.end());
+
+		auto right_max_element = max_element(right_acc_z_queue.begin(), right_acc_z_queue.end());
+		auto right_min_element = min_element(right_acc_z_queue.begin(), right_acc_z_queue.end());
+
+		if (left_max_element < left_min_element && right_max_element < right_min_element &&
+			*left_max_element - *left_min_element > 1500 && *right_max_element - *right_min_element > 1500)
+		{
+			res = 1;
+		}
+	}
+	return res;
+
+}
+

+ 18 - 0
Paoku_ios_20220923/Classes/UnityAppController.mm

@@ -327,6 +327,24 @@ extern "C" void UnityCleanupTrampoline()
 
     // if you wont use keyboard you may comment it out at save some memory
     [KeyboardDelegate Initialize];
+    
+    //以下是几种打开App方式
+    if(launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]){
+         NSLog(@"打开方式 远程推送打开");
+     }else if(launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]){
+         NSLog(@"打开方式 本地推送打开");
+     }else if(launchOptions[UIApplicationLaunchOptionsUserActivityDictionaryKey]){
+         NSLog(@"打开方式 UniversalLinks打开");
+     }else if(launchOptions[UIApplicationLaunchOptionsURLKey]){
+     //我们需要在此处处理通过 scheme 打开App并截获参数。
+      NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
+         NSLog(@"打开方式 通过URL打开的  ===== >> %@",url);
+         IOSPlatformSDK * sdk = [IOSPlatformSDK sharedInstance];
+         [sdk startWithUrl:url];
+     }else if (!launchOptions){
+         NSLog(@"打开方式 手动点击打开");
+         [IOSPlatformSDK sharedInstance];
+     }
 
     return YES;
 }

+ 2 - 2
Paoku_ios_20220923/Info.plist

@@ -19,7 +19,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.3.1</string>
+	<string>1.3.2</string>
 	<key>CFBundleURLTypes</key>
 	<array>
 		<dict>
@@ -34,7 +34,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>13105</string>
+	<string>13200</string>
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 		<string>com.cheedo.oujia</string>

+ 14 - 14
Paoku_ios_20220923/Unity-iPhone.xcodeproj/project.pbxproj

@@ -1710,16 +1710,16 @@
 		9333B52128DD8A3C00EB5F2D /* BLE */ = {
 			isa = PBXGroup;
 			children = (
-				9333B52228DD8A3C00EB5F2D /* CBPeripheral+ADName.m */,
-				9333B52328DD8A3C00EB5F2D /* LEONBLManager.h */,
-				9333B52428DD8A3C00EB5F2D /* BTDataSend.m */,
+				9333B52A28DD8A3C00EB5F2D /* BTDataAnalysis.h */,
+				9333B52B28DD8A3C00EB5F2D /* BTDataAnalysis.mm */,
 				9333B52528DD8A3C00EB5F2D /* BTDataProcess.h */,
 				9333B52628DD8A3C00EB5F2D /* BTDataProcess.mm */,
 				9333B52728DD8A3C00EB5F2D /* BTDataSend.h */,
-				9333B52828DD8A3C00EB5F2D /* LEONBLManager.m */,
+				9333B52428DD8A3C00EB5F2D /* BTDataSend.m */,
 				9333B52928DD8A3C00EB5F2D /* CBPeripheral+ADName.h */,
-				9333B52A28DD8A3C00EB5F2D /* BTDataAnalysis.h */,
-				9333B52B28DD8A3C00EB5F2D /* BTDataAnalysis.mm */,
+				9333B52228DD8A3C00EB5F2D /* CBPeripheral+ADName.m */,
+				9333B52328DD8A3C00EB5F2D /* LEONBLManager.h */,
+				9333B52828DD8A3C00EB5F2D /* LEONBLManager.m */,
 			);
 			path = BLE;
 			sourceTree = "<group>";
@@ -2795,7 +2795,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 13101;
+				CURRENT_PROJECT_VERSION = 132001;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -2809,7 +2809,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_GENERATE_MAP_FILE = YES;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -2852,7 +2852,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13101;
+				CURRENT_PROJECT_VERSION = 132001;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -2863,7 +2863,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_GENERATE_MAP_FILE = YES;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = NO;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -3030,7 +3030,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13101;
+				CURRENT_PROJECT_VERSION = 132001;
 				DEBUG_INFORMATION_FORMAT = dwarf;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
@@ -3042,7 +3042,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_GENERATE_MAP_FILE = YES;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",
@@ -3154,7 +3154,7 @@
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
 				COPY_PHASE_STRIP = YES;
-				CURRENT_PROJECT_VERSION = 13101;
+				CURRENT_PROJECT_VERSION = 132001;
 				DEVELOPMENT_TEAM = 79QQ6HAK8M;
 				ENABLE_BITCODE = NO;
 				GCC_C_LANGUAGE_STANDARD = gnu11;
@@ -3165,7 +3165,7 @@
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_GENERATE_MAP_FILE = YES;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 1.3.1;
+				MARKETING_VERSION = 1.3.2;
 				ONLY_ACTIVE_ARCH = YES;
 				OTHER_CFLAGS = (
 					"$(inherited)",

BIN
Paoku_ios_20220923/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate


BIN
Tricycle/.DS_Store


+ 14 - 1
Tricycle/Classes/SDK/BLE/BTDataProcess.mm

@@ -405,7 +405,20 @@ void inviteFriends (CFNotificationCenterRef center, void *observer, CFStringRef
     LEManager.discoverPeripheralBlock = ^(CBCentralManager * _Nonnull central, CBPeripheral * _Nonnull peripheral, NSDictionary * _Nonnull advertisementData, NSNumber * _Nonnull RSSI){
         //        NSLog(@"扫描发现蓝牙设备advertisementData =  %@",advertisementData);
         NSString *advertiseName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey];
-
+        NSData * manufacturerData = [advertisementData objectForKey:CBAdvertisementDataManufacturerDataKey];
+        Byte *testByte = (Byte *)[manufacturerData bytes];
+        if (testByte!=nil) {
+            NSInteger byteLength = sizeof(testByte);
+            NSString * byteString;
+            for (int i = 0; i < byteLength; i++){
+                int index = testByte[i];
+                byteString = [NSString stringWithFormat:@"%@,%d",byteString,index];
+            }
+            NSLog(@" byteString ====================>> %@",byteString);
+        }
+     
+//        NSLog(@"扫描发现蓝牙设备advertisementDataManufacturerData =  %@",manufacturerData);
+       
                 peripheral.advertiseName = advertiseName;
 
                 if ([advertiseName hasPrefix:@"SH_"]||[advertiseName hasPrefix:@"fun_"]||[advertiseName hasPrefix:@"Fun_"]||[advertiseName hasPrefix:@"FUN_"]){//SH_DANCE BLE_LOOP  Shoes_4530 Shoes_2A74

+ 3 - 0
Tricycle/Unity-iPhone.xcodeproj/project.pbxproj

@@ -2368,6 +2368,7 @@
 				GCC_C_LANGUAGE_STANDARD = gnu11;
 				GCC_ENABLE_CPP_EXCEPTIONS = YES;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = Classes/Prefix.pch;
 				HEADER_SEARCH_PATHS = (
@@ -2578,6 +2579,7 @@
 				GCC_C_LANGUAGE_STANDARD = gnu11;
 				GCC_ENABLE_CPP_EXCEPTIONS = YES;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = Classes/Prefix.pch;
 				HEADER_SEARCH_PATHS = (
@@ -2727,6 +2729,7 @@
 				GCC_C_LANGUAGE_STANDARD = gnu11;
 				GCC_ENABLE_CPP_EXCEPTIONS = YES;
 				GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = Classes/Prefix.pch;
 				HEADER_SEARCH_PATHS = (

BIN
Tricycle/Unity-iPhone.xcodeproj/project.xcworkspace/xcuserdata/duowan123.xcuserdatad/UserInterfaceState.xcuserstate