浏览代码

优化脚环--踢馆大师

liang 2 年之前
父节点
当前提交
a92430ded5
共有 2 个文件被更改,包括 64 次插入57 次删除
  1. 1 1
      footRing_sdk_1.0/include/pub.h
  2. 63 56
      footRing_sdk_1.0/src/Aerobics.cpp

+ 1 - 1
footRing_sdk_1.0/include/pub.h

@@ -44,7 +44,7 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.6.3"
+#define GAME_VERSION "0.6.4"
 
 enum CMD_MOTION
 {

+ 63 - 56
footRing_sdk_1.0/src/Aerobics.cpp

@@ -77,6 +77,7 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 		ResetDenyDownTime(time_stamp);
 	}*/
 
+
 	if (left_zupt)
 	{
 		stretch_left_status = 1;
@@ -95,6 +96,21 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 		lift_right_status = 1;
 	}
 
+	if (last_down == 0 && down != 0)
+	{
+		addMotionCount(DOWN_COUNT);
+
+		std::cout << "normal down motion" << endl;
+		result[0] = MOTION_DOWN;
+
+		stretch_front_right_status = 0;
+		lift_right_status = 0;
+
+		stretch_front_left_status = 0;
+		lift_left_status = 0;
+
+	}
+
 	if (left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 0)
 	{
 		setResult(left_step_data_vector, LEFT_FOOT);
@@ -138,14 +154,7 @@ 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 != 0 && wait_down == 0 && deny_down_time == 0)
-	if (last_down == 0 && down != 0 )
-	{
-		addMotionCount(DOWN_COUNT);
-
-		std::cout << "normal down motion" << endl;
-		result[0] = MOTION_DOWN;
 
-	}
 
 
 	last_down = down;
@@ -183,45 +192,43 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 	float roll  = step_data_vector.back().roll;
 
 	//暂时先将抬脚的高度阈值为0.1m, 伸脚的距离设置为0.2m
-	if ( plane_length > 0.2)
-	{
-		//if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_left_status == 1 && roll > -2.9f && roll < 0.0f)
-		if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_left_status == 1 && roll > 1.55f)
-		{
-			std::cout << "MOTION_STRETCH_LEFT : " << "左侧踢"<< endl;
-			result[0] = MOTION_STRETCH_LEFT;
-			stretch_left_status = 0;
-			lift_left_status = 0;
-			stretch_front_left_status = 0;
-		}
-		else if(LEFT_OR_RIGHT == RIGHT_FOOT && stretch_right_status == 1 && roll > 1.55f)
-		{
-			std::cout << "MOTION_STRETCH_RIGHT: " << "右侧踢" << endl;
-			result[0] = MOTION_STRETCH_RIGHT;
-			stretch_right_status = 0;
-			lift_right_status = 0;
-			stretch_front_right_status = 0;
-		}
 
-		if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_front_left_status == 1
-			&& step_data_vector.back().pos_y > 0.2f)
-		{
-			std::cout << "MOTION_STRETCH_FRONT_LEFT: " << "左前踢" << endl;
-			result[0] = MOTION_STRETCH_FRONT_LEFT;
-			stretch_front_left_status = 0;
-			lift_left_status = 0;
-		}
-		else if (LEFT_OR_RIGHT == RIGHT_FOOT && stretch_front_right_status == 1 
-			&& step_data_vector.back().pos_y > 0.2f)
-		{
-			std::cout << "MOTION_STRETCH_FRONT_RIGHT" << "右前踢" << endl;
-			result[0] = MOTION_STRETCH_FRONT_RIGHT;
-			stretch_front_right_status = 0;
-			lift_right_status = 0;
-		}
+		//if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_left_status == 1 && roll > -2.9f && roll < 0.0f)
+	if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_left_status == 1 && roll > 1.8f &&  pitch > -0.4f)
+	{
+		std::cout << "MOTION_STRETCH_LEFT : " << "左侧踢"<< endl;
+		result[0] = MOTION_STRETCH_LEFT;
+		stretch_left_status = 0;
+		lift_left_status = 0;
+		stretch_front_left_status = 0;
+	}
+	else if(LEFT_OR_RIGHT == RIGHT_FOOT && stretch_right_status == 1 && roll > 1.8f && pitch > -0.4f)
+	{
+		std::cout << "MOTION_STRETCH_RIGHT: " << "右侧踢" << endl;
+		result[0] = MOTION_STRETCH_RIGHT;
+		stretch_right_status = 0;
+		lift_right_status = 0;
+		stretch_front_right_status = 0;
+	}
 
+	else if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_front_left_status == 1
+		&& pitch < -0.4f)
+	{
+		std::cout << "MOTION_STRETCH_FRONT_LEFT: " << "左前踢" << endl;
+		result[0] = MOTION_STRETCH_FRONT_LEFT;
+		stretch_front_left_status = 0;
+		lift_left_status = 0;
+	}
+	else if (LEFT_OR_RIGHT == RIGHT_FOOT && stretch_front_right_status == 1 
+		&& pitch < -0.4f)
+	{
+		std::cout << "MOTION_STRETCH_FRONT_RIGHT" << "右前踢" << endl;
+		result[0] = MOTION_STRETCH_FRONT_RIGHT;
+		stretch_front_right_status = 0;
+		lift_right_status = 0;
 	}
-	else if (high > high_thresh && plane_length < 0.2f)
+
+	else if (fabs(high) > high_thresh && plane_length < 0.2f && pitch > 0.3f)
 	{
 		if (LEFT_OR_RIGHT == LEFT_FOOT && lift_left_status == 1)
 		{
@@ -237,17 +244,17 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 		}
 	}
 
-	if (plane_length > 0.2)
-	{
-		if (LEFT_OR_RIGHT == RIGHT_FOOT)
-		{
-			std::cout << "step_data_vector.back().pos_y : " << step_data_vector.back().pos_y << std::endl;
-		}
-		std::cout << "test : plane_length > 0.2" << endl;
-	}
-
-	if (high > high_thresh)
-	{
-		std::cout << "high > high_thresh" << endl;
-	}
+//	if (plane_length > 0.2)
+//	{
+//		if (LEFT_OR_RIGHT == RIGHT_FOOT)
+//		{
+//			std::cout << "step_data_vector.back().pos_y : " << step_data_vector.back().pos_y << std::endl;
+//		}
+//		std::cout << "test : plane_length > 0.2" << endl;
+//	}
+//
+//	if (high > high_thresh)
+//	{
+//		std::cout << "high > high_thresh" << endl;
+//	}
 }