Преглед на файлове

优化脚环--石头剪刀布游戏

liang преди 2 години
родител
ревизия
96794061d5
променени са 3 файла, в които са добавени 57 реда и са изтрити 4 реда
  1. 5 1
      footRing_sdk_1.0/include/FingerGuessing.h
  2. 1 1
      footRing_sdk_1.0/include/pub.h
  3. 51 2
      footRing_sdk_1.0/src/FingerGuessing.cpp

+ 5 - 1
footRing_sdk_1.0/include/FingerGuessing.h

@@ -21,6 +21,8 @@ public:
 	int ProcessDualStepVector(deque<shoes_data_cell>& left_cmd_step_data_vector, deque<shoes_data_cell> &right_cmd_step_data_vector,
 		float* left_cmd_global_pos, float* right_cmd_global_pos , int rssi);
 
+	bool unzuptValid(int* max_acc, int* min_acc);
+
 	virtual void 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);
@@ -58,7 +60,6 @@ private:
 	float left_step_pos[3];
 	float right_step_pos[3];
 
-
 	float left_heading;
 	float right_heading;
 
@@ -75,6 +76,9 @@ private:
 	int left_init;
 	int right_init;
 
+	int left_zupt_extension_time = 0;
+	int right_zupt_extension_time = 0;
+
 
 	const int rssi_threshold = 30;
 

+ 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.6"
+#define GAME_VERSION "0.6.8"
 
 enum CMD_MOTION
 {

+ 51 - 2
footRing_sdk_1.0/src/FingerGuessing.cpp

@@ -187,6 +187,15 @@ int FingerGuessing::ProcessDualStepVector(deque<shoes_data_cell>& left_cmd_step_
 	return -1;
 }
 
+bool FingerGuessing::unzuptValid(int* max_acc, int* min_acc)
+{
+	if ((max_acc[0] - min_acc[0] > 2048 || max_acc[1] - min_acc[1] > 2048 || max_acc[2] - min_acc[2] > 2048) && min_acc[0] < 500)
+	{
+		return true;
+	}
+
+	return false;
+}
 
 
 void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc, int right_zupt, int right_front_press, int right_back_press,
@@ -254,6 +263,37 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	}
 
 
+	if (left_zupt || right_zupt)
+	{
+		left_zupt = 1; right_zupt = 1;
+	}
+
+	if (left_zupt)
+	{
+		left_zupt_extension_time = 5;
+	}
+
+	if (right_zupt)
+	{
+		right_zupt_extension_time = 5;
+	}
+
+	if (left_zupt_extension_time > 0)
+	{
+		left_zupt = 1;
+
+		left_zupt_extension_time--;
+	}
+
+
+	if (right_zupt_extension_time > 0)
+	{
+		right_zupt = 1;
+
+		right_zupt_extension_time--;
+	}
+
+
 	//缓存一步内的空中数据
 	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);
@@ -295,6 +335,12 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 			left_cmd_wait_time = time_stamp;
 
 			left_init = 1;
+
+			right_shoes_data_vector.pop_front();
+			right_step_data_vector.pop_front();
+
+			left_shoes_data_vector.pop_front();
+			left_step_data_vector.pop_front();
 		}
 
 	}
@@ -337,8 +383,10 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	//看起来rssi的延迟有够烂的
 
 
-	if (left_init == 1 && right_init == 1 &&
-		time_stamp - left_cmd_wait_time > 9 && time_stamp - left_cmd_wait_time < 40 && time_stamp - right_cmd_wait_time > 9 && time_stamp - right_cmd_wait_time < 40)
+	//if (left_init == 1 && right_init == 1 &&
+	//	time_stamp - left_cmd_wait_time > 9 && time_stamp - left_cmd_wait_time < 40 && time_stamp - right_cmd_wait_time > 9 && time_stamp - right_cmd_wait_time < 40)
+	if ((left_init == 1 && time_stamp - left_cmd_wait_time > 9 && time_stamp - left_cmd_wait_time < 40) || 
+		(right_init == 1 && time_stamp - right_cmd_wait_time > 9 && time_stamp - right_cmd_wait_time < 40))
 	{
 
 		if (rssi < rssi_threshold)
@@ -391,6 +439,7 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 
 		left_init = 0;
 		right_init = 0;
+
 	}
 
 }