kidd3166 1 anno fa
parent
commit
d305b09887

+ 1 - 1
plugin/shoes_sdk/ios/Classes/include/FingerGuessing.h

@@ -80,7 +80,7 @@ private:
 	int right_zupt_extension_time = 0;
 
 
-	const int rssi_threshold = 25;
+	const int rssi_threshold = 30;
 
 
 };

+ 10 - 0
plugin/shoes_sdk/ios/Classes/include/RunGame.h

@@ -18,6 +18,16 @@ public:
 	int getResultDown(int down);
 
 private:
+
+	deque<int> rssi_delay;
+
+	deque<int> left_roll_vec;
+	deque<int> right_roll_vec;
+
+	int last_left_cmd = -1;
+	int last_right_cmd = -1;
+
+
 	deque<shoes_data_cell> left_shoes_data_vector;
 	deque<shoes_data_cell> right_shoes_data_vector;
 

+ 2 - 0
plugin/shoes_sdk/ios/Classes/include/SportFunction.h

@@ -118,4 +118,6 @@ private:
 	int jump_high;
 	int jump_length;
 
+	int last_jump = 0;
+
 };

+ 32 - 32
plugin/shoes_sdk/ios/Classes/include/pub.h

@@ -44,45 +44,45 @@ using namespace std;
 
 #define PRESS_MIN 41000
 
-#define GAME_VERSION "0.6.100"
+#define GAME_VERSION "0.6.17"
 
 enum CMD_MOTION
 {
     MOTION_STOP = 0,
-    MOTION_RUN, // 锟斤拷
-    MOTION_JUMP, // 锟斤拷
-    MOTION_DOWN, // 锟斤拷
-    MOTION_LEFT, // 锟斤拷锟斤拷
-    MOTION_RIGHT, // 锟斤拷锟斤拷
-    MOTION_FRONT, // 锟斤拷
-    MOTION_BACK, // 锟斤拷锟斤拷
-    MOTION_LEFT_UP, // 锟斤拷锟�-锟斤拷锟斤拷
-    MOTION_LEFT_DOWN, // 锟斤拷锟�-锟斤拷锟斤拷
-    MOTION_RIGHT_UP, // 锟斤拷锟�-锟斤拷锟斤拷
-    MOTION_RIGHT_DOWN, // 锟斤拷锟�-锟斤拷锟斤拷
-    MOTION_STEP, // 锟斤拷锟�-原锟截诧拷
-    MOTION_JUMP_OC, // 锟斤拷锟斤拷锟斤拷
-    MOTION_JUMP_VERTICAL, // 锟斤拷直锟斤拷
+    MOTION_RUN, // 
+    MOTION_JUMP, // 
+    MOTION_DOWN, // 
+    MOTION_LEFT, // 滑左
+    MOTION_RIGHT, // 滑右
+    MOTION_FRONT, // 
+    MOTION_BACK, // 滑后
+    MOTION_LEFT_UP, // 点击-左上
+    MOTION_LEFT_DOWN, // 点击-左下
+    MOTION_RIGHT_UP, // 点击-右上
+    MOTION_RIGHT_DOWN, // 点击-右下
+    MOTION_STEP, // 点击-原地踩
+    MOTION_JUMP_OC, // 开合跳
+    MOTION_JUMP_VERTICAL, // 垂直跳
     MOTION_ROCK, //石头
-    MOTION_SCISSORS, //锟斤拷锟斤拷
-    MOTION_PAPER, //锟斤拷
+    MOTION_SCISSORS, //剪刀
+    MOTION_PAPER, //
 
-    MOTION_STRETCH_LEFT, //锟斤拷锟斤拷锟斤拷
-    MOTION_LIFT_LEFT, //锟斤拷抬锟斤拷
+    MOTION_STRETCH_LEFT, //左伸腿
+    MOTION_LIFT_LEFT, //左抬腿
 
-    MOTION_STRETCH_RIGHT, //锟斤拷锟斤拷锟斤拷
-    MOTION_LIFT_RIGHT, //锟斤拷抬锟斤拷
+    MOTION_STRETCH_RIGHT, //右伸腿
+    MOTION_LIFT_RIGHT, //右抬腿
 
     MOTION_STRETCH_FRONT_LEFT,
     MOTION_STRETCH_FRONT_RIGHT,
 
-    MOTION_DOWN_FRONT, //锟节脚讹拷
+    MOTION_DOWN_FRONT, //踮脚蹲
 
-    MOTION_LEFT_ON_FLOOR,//锟斤拷鹊锟�
-    MOTION_RIGHT_ON_FLOOR, //锟揭踩碉拷
+    MOTION_LEFT_ON_FLOOR,//左踩地
+    MOTION_RIGHT_ON_FLOOR, //右踩地
 
-    MOTION_BOTH_ON_FLOOR_CLOSE, //锟较脚踩碉拷
-    MOTION_BOTH_ON_FLOOR_OPEN, //锟斤拷锟脚踩碉拷
+    MOTION_BOTH_ON_FLOOR_CLOSE, //合脚踩地
+    MOTION_BOTH_ON_FLOOR_OPEN, //岔开脚踩地
 
     NUMBERS_OF_MOTION,
 
@@ -109,12 +109,12 @@ enum MOTION_COUNT_TYPE {
 enum CMD_INTERATION
 {
    NONE_INTERATION = 0,
-   FRONT_LEFT,//锟斤拷锟较硷拷
-   FRONT_RIGHT,//锟斤拷锟较硷拷
-   BACK_LEFT,//锟斤拷锟铰硷拷
-   BACK_RIGHT,//锟斤拷锟铰硷拷
-   ENTER_KEY,//确锟较硷拷
-   CANCLE_KEY,//取锟斤拷锟斤拷
+   FRONT_LEFT,//左上键
+   FRONT_RIGHT,//右上键
+   BACK_LEFT,//左下键
+   BACK_RIGHT,//右下键
+   ENTER_KEY,//确认键
+   CANCLE_KEY,//取消键
 };
 
 struct posData

+ 16 - 16
plugin/shoes_sdk/ios/Classes/src/Aerobics.cpp

@@ -1,5 +1,5 @@
 #include "Aerobics.h"
-//锟竭馆达拷
+//踢馆大
 
 Aerobics::Aerobics()
 {
@@ -68,9 +68,9 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 	//static int time_count;
 	//std::cout << time_count++ << std::endl;
-	//锟斤拷锟矫碉拷锟脚的匡拷锟斤拷锟斤拷锟斤拷状态锟斤拷使锟斤拷锟斤拷锟斤拷锟节匡拷锟斤拷只锟叫讹拷一锟轿o拷锟斤拷锟斤拷锟节达拷锟截诧拷锟杰达拷锟斤拷锟斤拷锟斤拷锟筋
+	//设置单脚的空中命令状态,使得命令在空中只判断一次,区别于触地才能触发的命令
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷锟教э拷锟斤拷锟斤拷睿�拷锟矫达拷锟斤拷氐锟绞憋拷颍�锟斤拷锟斤拷岽ワ拷锟斤拷露耍锟斤拷锟揭伙拷锟斤拷锟街癸拷露椎锟斤拷锟斤拷锟斤拷锟绞�
+	//如果触发了抬脚命令,那么触地的时候,将不会触发下端,用一个禁止下蹲倒计来计时
 	/*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))
 	{
@@ -125,8 +125,8 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 
 
-	//锟斤拷锟叫讹拷锟斤拷锟斤拷锟斤拷畲ワ拷锟�
-	//锟斤拷锟斤拷锟斤拷锟较凤拷锟斤拷锟斤拷锟斤拷锟斤拷
+	//会有多个蹲命令触发
+	//在这个游戏单独处理蹲
 	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]));
 
@@ -177,10 +177,10 @@ void Aerobics::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RIGHT)
 {
-	// 锟斤拷锟斤拷锟叫轨迹
-	//锟斤拷实锟斤拷锟斤拷实时锟斤拷獾斤拷旒o拷欠锟斤拷锟较达拷锟斤拷锟斤拷锟斤拷模锟斤拷锟斤拷锟轿�拷朔锟斤拷锟斤拷锟斤拷虻ィ锟斤拷锟斤拷诖锟斤拷氐锟剿诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
-	//1锟斤拷锟饺硷拷獾絑锟斤拷墓旒o拷锟斤拷锟斤拷欠锟斤拷锟斤拷10cm, 锟斤拷锟节就会触锟斤拷锟叫讹拷锟斤拷锟斤拷锟斤拷
-	//2锟斤拷 同时锟斤拷同一锟斤拷循锟斤拷锟斤,锟叫讹拷锟斤拷锟斤拷平锟芥(X,Y锟斤拷锟侥碉拷锟斤拷锟斤拷锟斤拷
+	// 描绘空中轨迹
+	//其实可以实时检测到轨迹是否符合触发命令的,但是为了方便代码简单,就在触地的瞬间来触发命令检测流程算了
+	//1、先检测到Z轴的轨迹向量是否大于10cm, 大于就会触发判断命令了
+	//2、 同时在同一个循环里,判断最大的平面(X,Y)的点在哪里
 
 	float high = step_data_vector.back().pos_z;
 
@@ -191,12 +191,12 @@ 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
+	//暂时先将抬脚的高度阈值为0.1m, 伸脚的距离设置为0.2m
 
 		//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;
+		std::cout << "MOTION_STRETCH_LEFT : " << "左侧踢"<< endl;
 		result[0] = MOTION_STRETCH_LEFT;
 		stretch_left_status = 0;
 		lift_left_status = 0;
@@ -204,7 +204,7 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 	}
 	else if(LEFT_OR_RIGHT == RIGHT_FOOT && stretch_right_status == 1 && roll > 1.8f && pitch > -0.4f)
 	{
-		std::cout << "MOTION_STRETCH_RIGHT: " << "锟揭诧拷锟斤拷" << endl;
+		std::cout << "MOTION_STRETCH_RIGHT: " << "右侧踢" << endl;
 		result[0] = MOTION_STRETCH_RIGHT;
 		stretch_right_status = 0;
 		lift_right_status = 0;
@@ -214,7 +214,7 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 	else if (LEFT_OR_RIGHT == LEFT_FOOT && stretch_front_left_status == 1
 		&& pitch < -0.4f)
 	{
-		std::cout << "MOTION_STRETCH_FRONT_LEFT: " << "锟斤拷前锟斤拷" << endl;
+		std::cout << "MOTION_STRETCH_FRONT_LEFT: " << "左前踢" << endl;
 		result[0] = MOTION_STRETCH_FRONT_LEFT;
 		stretch_front_left_status = 0;
 		lift_left_status = 0;
@@ -222,7 +222,7 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 	else if (LEFT_OR_RIGHT == RIGHT_FOOT && stretch_front_right_status == 1 
 		&& pitch < -0.4f)
 	{
-		std::cout << "MOTION_STRETCH_FRONT_RIGHT" << "锟斤拷前锟斤拷" << endl;
+		std::cout << "MOTION_STRETCH_FRONT_RIGHT" << "右前踢" << endl;
 		result[0] = MOTION_STRETCH_FRONT_RIGHT;
 		stretch_front_right_status = 0;
 		lift_right_status = 0;
@@ -232,13 +232,13 @@ void Aerobics::setResult(deque<shoes_data_cell>& step_data_vector,int LEFT_OR_RI
 	{
 		if (LEFT_OR_RIGHT == LEFT_FOOT && lift_left_status == 1)
 		{
-			std::cout << "MOTION_LIFT_LEFT " << "锟斤拷抬锟斤拷" << endl;
+			std::cout << "MOTION_LIFT_LEFT " << "左抬脚" << endl;
 			result[0] = MOTION_LIFT_LEFT;
 			lift_left_status = 0;
 		}
 		else if (LEFT_OR_RIGHT == RIGHT_FOOT && lift_right_status == 1)
 		{
-			std::cout << "MOTION_LIFT_RIGHT " << "锟斤拷抬锟斤拷" << endl;
+			std::cout << "MOTION_LIFT_RIGHT " << "右抬脚" << endl;
 			result[0] = MOTION_LIFT_RIGHT;
 			lift_right_status = 0;
 		}

+ 1 - 1
plugin/shoes_sdk/ios/Classes/src/BuildHouse.cpp

@@ -45,7 +45,7 @@ bool isValidAcc(deque<dualAccData>& dual_acc, int start_index,  int thresh_hold)
 
 void detect_cancave_curve_top(deque<int>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
 {
-	//1鐃緒申儖鐃緒申鐃緒申弌峙
+	//1、儖孀恷弌峙
 	int k = dual_press_back.size() - 1;
 
 	right_size_index = k;

+ 22 - 22
plugin/shoes_sdk/ios/Classes/src/FingerGuessing.cpp

@@ -23,7 +23,7 @@ FingerGuessing::FingerGuessing()
 	left_init = 0;
 	right_init = 0;
 
-	//原锟斤拷
+	//原
 	left_global_pos_vector.push_back({ 0, 0, 0, 0 });
 	right_global_pos_vector.push_back({ 0, 0, 0, 0 });
 
@@ -48,7 +48,7 @@ void FingerGuessing::ProcessResult(float* global_pos, deque<shoes_data_cell>& st
 		std::cout << "FingerGuessing::ProcessResult" << endl;
 		std::cout << endl;
 
-		//寻锟揭碉拷锟斤拷锟斤拷锟斤拷小锟斤拷
+		//寻找到距离最小的
 		int vector_length = global_pos_vector.size();
 
 		float distance_point = 0.05f;
@@ -58,7 +58,7 @@ void FingerGuessing::ProcessResult(float* global_pos, deque<shoes_data_cell>& st
 
 		for (int i = 0; i < vector_length; i++)
 		{
-			//锟斤拷锟斤拷寻锟斤拷锟斤拷锟斤拷锟饺癸拷锟侥碉拷
+			//回溯寻找曾经踩过的点
 			float dx = global_pos[0] - global_pos_vector.at(i).pos_x;
 			float dy = global_pos[1] - global_pos_vector.at(i).pos_y;
 
@@ -88,8 +88,8 @@ void FingerGuessing::ProcessResult(float* global_pos, deque<shoes_data_cell>& st
 		if (index == -1)
 		{
 			std::cout << "no find similar point" << endl;
-			//没锟斤拷锟揭碉拷锟斤拷准锟斤拷锟绞憋拷颍�锟解到锟斤拷锟斤拷锟斤拷锟绞憋拷锟�,锟斤拷锟斤拷锟叫讹拷
-			//锟斤拷锟斤拷獾斤拷咏锟皆�拷锟斤拷时锟斤拷应锟斤拷锟斤拷锟斤拷为0
+			//没有找到基准点的时候,检测到往返点的时候,再做判断
+			//当检测到接近原点的时候,应当设置为0
 
 			global_pos_vector.push_back({ 0, global_pos[0], global_pos[1],global_pos[2] });
 
@@ -123,7 +123,7 @@ void FingerGuessing::ProcessResult(float* global_pos, deque<shoes_data_cell>& st
 
 	}
 
-	//为锟剿凤拷止锟襟触点,锟斤拷锟斤拷锟斤拷锟斤拷氐锟斤拷锟斤拷锟斤拷锟�
+	//为了防止误触点,用五个触地点来测试
 
 }
 
@@ -146,7 +146,7 @@ int FingerGuessing::ProcessDualStepVector(deque<shoes_data_cell>& left_cmd_step_
 		return -1;
 	}
 
-	//锟斤拷锟斤拷锟叫讹拷拳头
+	//还是判断拳头
 
 	if (rssi > 30)
 	{
@@ -162,7 +162,7 @@ int FingerGuessing::ProcessDualStepVector(deque<shoes_data_cell>& left_cmd_step_
 			return MOTION_PAPER;
 		}
 
-		//锟叫断硷拷锟斤拷锟叫碉拷锟介
+		//判断剪刀有点麻
 		if (right_dx - left_dx < -0.3f)
 		{
 
@@ -203,7 +203,7 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	int jump, int down, int rssi)
 {
 
-	//锟斤拷锟节刚达拷锟截碉拷时锟斤拷,锟斤拷偶锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟脚号的关硷拷帧锟斤拷锟斤拷锟斤拷锟斤拷锟竭诧拷锟斤拷一锟斤拷
+	//由于刚触地的时候,会偶尔丢掉触地信号的关键帧,现在在线补充一下
 
 	//int online_zupt = extract_motion.online_detect_touch_floor(right_front_press, left_front_press, right_back_press, left_back_press);
 
@@ -296,30 +296,30 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	}
 
 
-	//锟斤拷锟斤拷一锟斤拷锟节的匡拷锟斤拷锟斤拷锟斤拷
+	//缓存一步内的空中数据
 	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);
 
 	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);
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷o拷锟斤拷锟斤拷锟饺�拷锟轿伙拷锟�
+	//根据新来的数据,计算的全局位置
 	calGlobalPos(right_shoes_data_vector, right_step_data_vector, right_global_pos, right_heading, 0, RIGHT_FOOT);
 
 	calGlobalPos(left_shoes_data_vector, left_step_data_vector, left_global_pos, left_heading, 0, LEFT_FOOT);
 
 
-	//锟斤拷锟较革拷锟斤拷rssi锟酵达拷锟斤拷锟脚猴拷锟斤拷锟斤拷锟狡癸拷位锟斤拷锟皆硷拷锟斤拷锟斤拷
+	//不断根据rssi和触地信号来估计归位,以及方向
 	resetZerosPointByRssi(left_zupt, 10, left_zupt_count, left_foot_has_init, left_att[0] * 0.0001f, left_heading, rssi, 25, left_global_pos);
 	resetZerosPointByRssi(right_zupt, 10, right_zupt_count, right_foot_has_init, right_att[0] * 0.0001f, right_heading, rssi, 25, right_global_pos);
 
 
-	//通锟斤拷锟斤拷锟劫度★拷锟皆硷拷vector锟窖撅拷锟斤拷锟斤拷锟剿匡拷锟叫碉拷锟斤拷锟斤拷锟斤拷锟斤拷位锟叫讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟斤拷时锟叫断碉拷效锟斤拷锟斤拷锟斤拷时锟斤拷为锟剿等猴拷锟绞碉拷RSSI
+	//通过加速度、以及vector已经缓存了空中的数据来定位判断命令所需的时间戳,这个时间戳是起延时判断的效果,延时是为了等合适的RSSI
 	if (left_step_data_vector.size() > 5 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 1)
 	{
 		if (unzuptValid(max_acc_unzupt_left, min_acc_unzupt_left))
 		{
-			//锟斤拷锟捷癸拷锟斤拷锟斤拷录锟斤拷位锟矫碉拷锟斤拷锟斤拷锟斤拷锟脚伙拷
+			//根据过往记录的位置点来,来优化
 			//ProcessResult(left_global_pos, left_step_data_vector, left_global_pos_vector, LEFT_FOOT);
 
 			left_cmd_step_data_vector = left_step_data_vector;
@@ -348,7 +348,7 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 		if (unzuptValid(max_acc_unzupt_right, min_acc_unzupt_right))
 		{
 
-			//锟斤拷锟捷癸拷锟斤拷锟斤拷录锟斤拷位锟矫碉拷锟斤拷锟斤拷锟斤拷锟脚伙拷
+			//根据过往记录的位置点来,来优化
 			//ProcessResult(right_global_pos, right_step_data_vector, right_global_pos_vector, RIGHT_FOOT);
 
 			right_cmd_step_data_vector = right_step_data_vector;
@@ -375,11 +375,11 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	setPolarAccUnzupt(max_acc_unzupt_left, min_acc_unzupt_left, left_acc, left_zupt);
 	setPolarAccUnzupt(max_acc_unzupt_right, min_acc_unzupt_right, right_acc, right_zupt);
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷
+	//重置命令
 	memset(result, -1, 4 * sizeof(int));
 
-	//锟叫讹拷双锟脚达拷锟截碉拷时锟斤拷, rssi < 23 锟斤拷锟斤拷锟轿伙拷锟斤拷锟饺灰裁伙拷旆�拷锟斤拷锟�
-	//锟斤拷锟斤拷锟斤拷rssi锟斤拷锟接筹拷锟叫癸拷锟矫碉拷
+	//判断双脚触地的时候, rssi < 23 必须归位,不然也没办法处理
+	//看起来rssi的延迟有够烂的
 
 
 	if (left_init == 1 && right_init == 1 &&
@@ -407,24 +407,24 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 
 			if (pitch_diff - pitch_reference_val > 2000 || pitch_diff - pitch_reference_val < -2000)
 			{
-				//统锟狡硷拷锟斤拷
+				//统计剪刀
 				addMotionCount(SCISSORS_COUNT);
 
 				result[0] = MOTION_SCISSORS;
 
-				std::cout << "FingureResult : MOTION_SCISSORS " << " 锟斤拷锟斤拷" << endl;
+				std::cout << "FingureResult : MOTION_SCISSORS " << " 剪刀" << endl;
 
 			}
 			else if (roll_mean - roll_reference_val > 1500)
 			{
-				//统锟狡诧拷锟斤拷
+				//统计步数
 				addMotionCount(PAPER_COUNT);
 
 				result[0] = MOTION_PAPER;
 
 				std::cout << "MOTION_PAPER, RSSI : " << rssi << endl;
 
-				std::cout << "FingureResult : MOTION_PAPER" << " 锟斤拷" << endl;
+				std::cout << "FingureResult : MOTION_PAPER" << " " << endl;
 			}
 			else
 			{

+ 5 - 5
plugin/shoes_sdk/ios/Classes/src/FootStep.cpp

@@ -4,7 +4,7 @@
 FootStep::FootStep()
 {
 	/*
-		锟斤拷始锟斤拷锟斤拷为0
+		初始化均为0
 	*/
 	stepStatus = 0;
 	stepFreq = 0;
@@ -83,7 +83,7 @@ void calStepFreq(vector<FLOOR_TIME_STYPE>& time_vector, float &mean_step_vel)
 		mean_step_vel = 100.f / (cur_floor_time_stype.time - last_floor_time_stype.time);
 	}
 
-	//删锟斤拷锟斤拷锟叫的碉拷
+	//删除所有的点
 	time_vector.clear();
 	time_vector.push_back(cur_floor_time_stype);
 
@@ -127,7 +127,7 @@ int check_time_vector(vector<FLOOR_TIME_STYPE>& time_vector)
 	for (int i = 1; i < time_vector_tmp.size(); i++)
 	{
 
-		//锟斤拷锟斤拷锟剿诧拷锟斤拷锟斤拷也锟斤拷锟斤拷锟杰达拷锟斤拷锟皆硷拷锟节匡拷锟叫碉拷时锟斤拷锟斤拷小锟斤拷50ms锟斤拷
+		//按照人步伐,也不可能触地以及在空中的时间是小于50ms的
 		if (time_vector_tmp[i].time - time_vector_tmp[i - 1].time >= 5)
 		{
 			time_vector.push_back(time_vector_tmp[i]);
@@ -231,7 +231,7 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 	localTime += timeDistance;
 
 
-	//锟斤拷锟姐触锟斤拷时锟斤拷
+	//计算触地时间
 	if (lastZupt == 0 && zupt == 1)
 	{
 		if (max_acc[0] - min_acc[0] > 2048 || max_acc[1] - min_acc[1] > 2048 || max_acc[2] - min_acc[2] > 2048)
@@ -337,7 +337,7 @@ void FootStep::stepCal(int timeStamp, int zupt, int front_mag, int back_mag, int
 
 	lastZupt = zupt;
 
-	//锟斤拷锟斤拷锟斤拷停也应锟斤拷锟叫讹拷为锟斤拷锟斤拷
+	//空中悬停也应当判断为不动
 	if (acc_z_deque.size() > 9)
 	{
 		acc_z_deque.pop_front();

+ 7 - 7
plugin/shoes_sdk/ios/Classes/src/Game.cpp

@@ -86,25 +86,25 @@ void Game::GameProcess(int gameTime, int* right_pos_data, int* right_att_data, i
 	int jump, int down, int rssi)
 {
 
-	//锟斤拷戏锟斤拷锟斤拷锟竭硷拷锟斤拷锟�
+	//游戏的主逻辑入口
 	game->Process(gameTime, right_pos_data, right_att_data, right_acc_data, right_zupt, right_front_mag, right_back_mag,
 		left_pos_data, left_att_data, left_acc_data, left_zupt, left_front_mag, left_back_mag, jump, down, rssi);
 	
-	//锟斤拷取锟斤拷戏锟斤拷锟�
+	//获取游戏结果
 	game->getResult(resultMatrix);
 
 
-	//*锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�*/
+	//*交互命令计算*/
 	interaction.Process(gameTime, right_pos_data, right_att_data, right_acc_data, right_zupt, right_front_mag, right_back_mag,
 		left_pos_data, left_att_data, left_acc_data, left_zupt, left_front_mag, left_back_mag, jump, down, rssi);
 
 
-	//*锟斤拷频锟斤拷锟斤拷*/
+	//*步频计算*/
 	leftFootStep.stepCal(gameTime, left_zupt, left_front_mag, left_back_mag, left_acc_data);
 
 	rightFootStep.stepCal(gameTime, right_zupt, right_front_mag, right_back_mag, right_acc_data);
 
-	///*锟斤拷锟矫脚诧拷抬锟竭的高讹拷锟皆硷拷锟斤拷频 平锟斤拷锟揭伙拷锟斤拷俣锟�*/
+	///*利用脚步抬高的高度以及步频 平衡出一个速度*/
 	//stepVel.Process(gameTime, right_pos_data, right_att_data, right_acc_data, right_zupt, right_front_mag, right_back_mag,
 		//left_pos_data, left_att_data, left_acc_data, left_zupt, left_front_mag, left_back_mag, jump, down, rssi);
 
@@ -176,7 +176,7 @@ string Game::getGameDataStr()
 {
 	string data_str_temp = "";
 
-	//锟饺硷拷录锟揭憋拷
+	//先记录右边
 
 	data_str_temp = data_str;
 
@@ -221,7 +221,7 @@ void Game::getFootAtt(int* left_att, int* right_att)
 }
 
 
-//锟斤拷锟斤拷鞋锟接碉拷锟斤拷锟斤拷
+//解析鞋子的数据
 void Game::GameProcessBuf(uint8_t* buf, int len) {
 
 	right_pos_data[0] = int32_t(buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3] << 0);

+ 5 - 5
plugin/shoes_sdk/ios/Classes/src/H5_Game.cpp

@@ -28,10 +28,10 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 {
 
 
-	//锟斤拷取锟斤拷锟斤拷
+	//获取触地
 	if (last_left_zupt == 0 && left_zupt == 1)
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(STEP_COUNT);
 
 		std::cout << "H5GAME:: MOTION_LEFT" << endl;
@@ -44,7 +44,7 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 
 	if (last_right_zupt == 0 && right_zupt == 1)
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(STEP_COUNT);
 
 		std::cout << "H5GAME:: MOTION_RIGHT" << endl;
@@ -58,7 +58,7 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 
 	if (last_jump == 0 && jump == 1)
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(JUMP_COUNT);
 
 		std::cout << "H5GAME:: MOTION_JUMP" << endl;
@@ -93,7 +93,7 @@ void H5::Process(int time_stamp, int* right_pos, int* right_att, int* right_acc,
 	//same process with jump
 	if (last_down == 0 && down == 1 )
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(DOWN_COUNT);
 
 		std::cout << "H5GAME:: MOTION_DOWN" << endl;

+ 7 - 7
plugin/shoes_sdk/ios/Classes/src/Interaction.cpp

@@ -64,8 +64,8 @@ int Interaction::foot_on_floor(int _time,  int& triggerring_time, int zupt, int
 
 int acc_is_valid(float* acc_window, int length)
 {
-	//要锟襟窗口达拷锟节筹拷锟饺达拷锟斤拷10
-	//锟斤拷锟叫讹拷锟斤拷锟斤拷锟斤拷元锟斤拷锟斤拷平锟饺的o拷锟斤拷值锟斤拷锟斤拷为0.06
+	//要求窗口窗口长度大于10
+	//先判断最后五个元素是平稳的,阈值设置为0.06
 	float station_max = acc_window[length - 1];
 	float station_min = acc_window[length - 1];
 
@@ -121,13 +121,13 @@ int Interaction::enter_key_listen( float* acc, float* acc_x_buff,int &station_co
 
 	pitch_buff[9] = pitch;
 
-	//锟斤拷锟叫断革拷锟斤拷锟斤拷锟角凤拷锟斤拷锟斤拷锟脚地o拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫讹拷确锟较硷拷
-	if (pitch < 0.6f)
+	//先判断俯仰角是否正常着地,这样才能判断确认键
+	if (pitch < 0.4f)
 	{
 		angle_has_reset = 1;
 	}
 
-	if (acc_is_valid(acc_x_buff, 10) && *max_element(pitch_buff, pitch_buff + 10) - *min_element(pitch_buff, pitch_buff + 10) < 0.1)
+	if (acc_is_valid(acc_x_buff, 10) && *max_element(pitch_buff, pitch_buff + 10) - *min_element(pitch_buff, pitch_buff + 10) < 0.1f)
 	{
 		station_count++;
 	}
@@ -136,8 +136,8 @@ int Interaction::enter_key_listen( float* acc, float* acc_x_buff,int &station_co
 		station_count = 0;
 	}
 
-	//x锟斤拷锟劫度撅拷锟揭讹拷锟斤拷锟斤拷锟斤拷锟揭革拷锟斤拷锟角达拷锟斤拷45锟饺o拷锟斤拷证锟斤拷锟斤拷锟节斤拷
-	if (station_count > 10 && pitch > 0.6f  && angle_has_reset == 1)
+	//x轴速度剧烈抖动,而且俯仰角大于45度,则证明是踮脚
+	if (station_count > 10 && pitch > 0.4f  && angle_has_reset == 1)
 	{
 		angle_has_reset = 0;
 

+ 17 - 17
plugin/shoes_sdk/ios/Classes/src/JumpHouse.cpp

@@ -37,7 +37,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 	int jump, int down, int rssi)
 {
 
-	//锟教斤拷锟斤拷为锟斤拷锟节碉拷锟斤拷
+	//翘脚视为不在地上
 	// 
 
 	if (has_init == 0)
@@ -118,19 +118,19 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 		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);
 
 	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);
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷o拷锟斤拷锟斤拷锟饺�拷锟轿伙拷锟�
+	//根据新来的数据,计算的全局位置
 	calGlobalPos(right_shoes_data_vector, right_step_data_vector, right_global_pos, right_heading, 0, RIGHT_FOOT);
 
 	calGlobalPos(left_shoes_data_vector, left_step_data_vector, left_global_pos, left_heading, 0, LEFT_FOOT);
 
-	//通锟斤拷锟斤拷锟劫度★拷锟皆硷拷vector锟窖撅拷锟斤拷锟斤拷锟剿匡拷锟叫碉拷锟斤拷锟斤拷锟斤拷锟斤拷位锟叫讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟斤拷时锟叫断碉拷效锟斤拷锟斤拷锟斤拷时锟斤拷为锟剿等猴拷锟绞碉拷RSSI
+	//通过加速度、以及vector已经缓存了空中的数据来定位判断命令所需的时间戳,这个时间戳是起延时判断的效果,延时是为了等合适的RSSI
 	if (left_step_data_vector.size() > 5 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 1)
 	{
 		//if (unzuptValid(max_acc_unzupt_left, min_acc_unzupt_left) && press_valid)
@@ -167,12 +167,12 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 	setPolarAccUnzupt(max_acc_unzupt_right, min_acc_unzupt_right, right_acc, right_zupt);
 	
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷
+	//重置命令
 	memset(result, -1, 4 * sizeof(int));
 
 
-	//锟叫讹拷双锟脚达拷锟截碉拷时锟斤拷, rssi < 23 锟斤拷锟斤拷锟轿伙拷锟斤拷锟饺灰裁伙拷旆�拷锟斤拷锟�
-	//锟斤拷锟斤拷锟斤拷rssi锟斤拷锟接筹拷锟叫癸拷锟矫碉拷
+	//判断双脚触地的时候, rssi < 23 必须归位,不然也没办法处理
+	//看起来rssi的延迟有够烂的
 
 	if (left_init == 1 && time_stamp - left_cmd_wait_time >= 9 && time_stamp - left_cmd_wait_time < 30)
 	{
@@ -183,13 +183,13 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 			{
 				result[0] = MOTION_BOTH_ON_FLOOR_CLOSE;
 
-				std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi <<  ", " << " 锟较斤拷"  <<std::endl;
+				std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi <<  ", " << " 合脚"  <<std::endl;
 			}
 			else
 			{
 				result[0] = MOTION_BOTH_ON_FLOOR_OPEN;
 
-				std::cout << " MOTION_BOTH_ON_FLOOR_OPEN "<< rssi << ", "  << " 锟斤拷锟斤拷"<<std::endl;
+				std::cout << " MOTION_BOTH_ON_FLOOR_OPEN "<< rssi << ", "  << " 开脚"<<std::endl;
 			}
 
 		}
@@ -202,12 +202,12 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 				{
 					result[0] = MOTION_BOTH_ON_FLOOR_CLOSE;
 
-					std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi << ", " << " 锟较斤拷" << std::endl;
+					std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi << ", " << " 合脚" << std::endl;
 				}
 				else
 				{
 					result[0] = MOTION_BOTH_ON_FLOOR_OPEN;
-					std::cout << " MOTION_BOTH_ON_FLOOR_OPEN " << rssi << ", " << " 锟斤拷锟斤拷" << std::endl;
+					std::cout << " MOTION_BOTH_ON_FLOOR_OPEN " << rssi << ", " << " 开脚" << std::endl;
 				}
 
 				right_shoes_data_vector.pop_front();
@@ -216,7 +216,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 			else
 			{
 				result[0] = MOTION_LEFT_ON_FLOOR;
-				std::cout << " MOTION_LEFT_ON_FLOOR " << time_stamp << ", " << " 锟襟单斤拷" << std::endl;
+				std::cout << " MOTION_LEFT_ON_FLOOR " << time_stamp << ", " << " 左单脚" << std::endl;
 			}
 		
 		}
@@ -237,12 +237,12 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 			{
 				result[0] = MOTION_BOTH_ON_FLOOR_CLOSE;
 
-				std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE "  << " "<< rssi << ", " << " 锟较斤拷" << std::endl;
+				std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE "  << " "<< rssi << ", " << " 合脚" << std::endl;
 			}
 			else
 			{
 				result[0] = MOTION_BOTH_ON_FLOOR_OPEN;
-				std::cout << " MOTION_BOTH_ON_FLOOR_OPEN "  << " " << rssi << ", "  << " 锟斤拷锟斤拷"<<std::endl;
+				std::cout << " MOTION_BOTH_ON_FLOOR_OPEN "  << " " << rssi << ", "  << " 开脚"<<std::endl;
 			}
 
 			left_init = 0;
@@ -258,12 +258,12 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 				{
 					result[0] = MOTION_BOTH_ON_FLOOR_CLOSE;
 
-					std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi << ", " << " 锟较斤拷" << std::endl;
+					std::cout << " MOTION_BOTH_ON_FLOOR_CLOSE " << rssi << ", " << " 合脚" << std::endl;
 				}
 				else
 				{
 					result[0] = MOTION_BOTH_ON_FLOOR_OPEN;
-					std::cout << " MOTION_BOTH_ON_FLOOR_OPEN " << rssi << ", " << " 锟斤拷锟斤拷" << std::endl;
+					std::cout << " MOTION_BOTH_ON_FLOOR_OPEN " << rssi << ", " << " 开脚" << std::endl;
 				}
 
 				left_shoes_data_vector.pop_front();
@@ -272,7 +272,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 			else
 			{
 				result[0] = MOTION_RIGHT_ON_FLOOR;
-				std::cout << " MOTION_RIGHT_ON_FLOOR " << time_stamp << ", " << "锟揭碉拷锟斤拷" << std::endl;
+				std::cout << " MOTION_RIGHT_ON_FLOOR " << time_stamp << ", " << "右单脚" << std::endl;
 			}
 			
 		}

+ 11 - 11
plugin/shoes_sdk/ios/Classes/src/Kongfu.cpp

@@ -1,6 +1,6 @@
 #include "Kongfu.h"
 
-//锟斤拷锟斤拷小锟斤拷锟斤拷
+//功夫小羊游
 
 Kongfu::Kongfu()
 {
@@ -35,7 +35,7 @@ int getKickByAcc(int zupt, int& kick, int& last_kick, int& kick_wait, float acc_
 	{
 		acc_x_buff.clear();
 	}
-	//锟斤拷锟斤拷锟节匡拷锟斤拷锟叫讹拷一锟斤拷
+	//利用在空中判断一次
 	if (shoes_data_vector.size() >  1)
 	{
 		float start_x = shoes_data_vector.front().pos_x;
@@ -55,7 +55,7 @@ int getKickByAcc(int zupt, int& kick, int& last_kick, int& kick_wait, float acc_
 		}
 
 	}
-	//锟斤拷锟斤拷x锟斤拷锟斤拷俣锟斤拷锟斤拷卸锟斤拷欠锟斤拷呓锟�, 锟斤拷锟揭斤拷应锟斤拷锟角凤拷转锟斤拷锟斤拷锟斤拷
+	//利用x轴加速度来判断是否踢脚, 左右脚应该是翻转过来的
 	if (acc_x_buff.size() > 1)
 	{
 		if (acc_x_buff.back() - acc_x_buff[acc_x_buff.size() - 2] > 0.0f)
@@ -71,7 +71,7 @@ int getKickByAcc(int zupt, int& kick, int& last_kick, int& kick_wait, float acc_
 		}
 	}
 
-	//锟斤拷锟剿筹拷锟斤拷锟叫讹拷锟竭的讹拷锟斤拷锟斤拷锟斤拷
+	//过滤持续判断踢的动作命令
 	if (last_kick == 0 && kick == 1)
 	{
 		kick_wait = 4;
@@ -84,7 +84,7 @@ int getKickByAcc(int zupt, int& kick, int& last_kick, int& kick_wait, float acc_
 		kick_wait = 0;
 	}
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟捷碉拷锟绞憋拷涑わ拷龋锟斤拷锟斤拷獯ワ拷锟绞憋拷锟斤拷叩亩锟斤拷锟�
+	//利用三个数据点的时间长度,避免触地时候踢的动作
 	if ((kick_wait--) == 1)
 	{
 		return 1;
@@ -132,14 +132,14 @@ void Kongfu::Process(int time_stamp, int* right_pos, int* right_att, int* right_
 	//	down = 1;
 	//}
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷为-1
+	//设置重置为-1
 	result[0] = -1;
 	result[1] = -1;
 
 	if (getKickByAcc(left_zupt, left_kick, last_left_kick, left_kick_wait, left_acc[2] / 2048.f, left_acc_x_buff, left_shoes_data_vector)
 		&& unzuptValid(max_acc_unzupt_left, min_acc_unzupt_left) && CANCLE_JUMP == 0)
 	{
-		//统锟斤拷锟竭的讹拷锟斤拷
+		//统计踢的动作
 		addMotionCount(KICK_COUNT);
 
 		CANCLE_FLOOR_CMD_LEFT = 1;
@@ -150,7 +150,7 @@ void Kongfu::Process(int time_stamp, int* right_pos, int* right_att, int* right_
 	if (getKickByAcc(right_zupt, right_kick, last_right_kick, right_kick_wait, right_acc[2] / 2048.f, right_acc_x_buff, right_shoes_data_vector)
 		&& unzuptValid(max_acc_unzupt_right, min_acc_unzupt_right) && CANCLE_JUMP == 0)
 	{
-		//统锟斤拷锟竭的讹拷锟斤拷
+		//统计踢的动作
 		addMotionCount(KICK_COUNT);
 
 		CANCLE_FLOOR_CMD_RIGHT = 1;
@@ -159,10 +159,10 @@ void Kongfu::Process(int time_stamp, int* right_pos, int* right_att, int* right_
 	}
 
 
-	//锟斤拷取锟斤拷锟斤拷
+	//获取触地
 	if (last_left_zupt == 0 && left_zupt == 1 && unzuptValid(max_acc_unzupt_left, min_acc_unzupt_left) && CANCLE_JUMP == 0)
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(STEP_COUNT);
 
 		if (CANCLE_FLOOR_CMD_LEFT == 0)
@@ -180,7 +180,7 @@ void Kongfu::Process(int time_stamp, int* right_pos, int* right_att, int* right_
 
 	if (last_right_zupt == 0 && right_zupt == 1 && unzuptValid(max_acc_unzupt_right, min_acc_unzupt_right) &&CANCLE_JUMP == 0)
 	{
-		//统锟狡诧拷锟斤拷
+		//统计步数
 		addMotionCount(STEP_COUNT);
 
 		if (CANCLE_FLOOR_CMD_RIGHT == 0)

+ 192 - 135
plugin/shoes_sdk/ios/Classes/src/RunGame.cpp

@@ -22,113 +22,227 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 	int jump, int down, int rssi)
 {
 
-	// 额外处理蹲
-	/*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)
+
+	int left_cmd = -1;
+	int right_cmd = -1;
+
+	if (left_roll_vec.size() == 0)
 	{
-		down = online_down;
+		left_roll_vec.push_back(left_att[2]);
 	}
-
-	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)
+	else
 	{
-		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);
-
-	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);
-
-	//计算全局位置,选择当前的旋转量为这一步即将离地时候的方向,额外的旋转量为10度
-	//hoes_data_vector存的是鞋子上传的数据,它的方向是鞋子烧录时候的方向,并不是玩游戏时候的方向,需要旋转至玩游戏的方向
-	//step_data_vector 的位置已经选择到游戏的方向了,位置是相对位移,即相对于left_step_data_vector[0]的位置偏移
-	calGlobalPos(right_shoes_data_vector, right_step_data_vector, right_global_pos, right_shoes_data_vector[0].heading, 10.0f / 180 * PI, RIGHT_FOOT);
-	calGlobalPos(left_shoes_data_vector, left_step_data_vector, left_global_pos, left_shoes_data_vector[0].heading, -10.0f / 180 * PI, LEFT_FOOT);
+		if (left_att[2] >= left_roll_vec.back())
+		{
+			left_roll_vec.push_back(left_att[2]);
+		}
+		else
+		{
+			left_roll_vec.clear();
+		}
+	}
 
-	//这里为了脚本容易观测,设置全局位置为0
-	if (left_step_data_vector.front().zupt == 0)
+	if (right_roll_vec.size() == 0)
 	{
-		memset(left_global_pos, 0, 3 * sizeof(float));
+		right_roll_vec.push_back(right_att[2]);
 	}
-
-	if (right_step_data_vector.front().zupt == 0)
+	else
 	{
-		memset(right_global_pos, 0, 3 * sizeof(float));
+		if (right_att[2] >= right_roll_vec.back())
+		{
+			right_roll_vec.push_back(right_att[2]);
+		}
+		else
+		{
+			right_roll_vec.clear();
+		}
 	}
 
-
-	//判断命令触发
-	int left_cmd = -1;
-	if (left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1)
+	if (right_roll_vec.size() > 1 && left_roll_vec.size() > 1)
 	{
-		std::cout << left_step_data_vector.back().pos_x << ", " << left_step_data_vector.back().pos_y << endl;
-		//跑酷游戏只要有空中的数据(不想其他游戏一样需要落地时候判断就好),就需要进行游戏
-		if (left_step_data_vector.back().zupt || left_step_data_vector.back().pitch < 0.3f)
-		{
-			//垫脚跑不触发命令。如果硬要垫脚跑,那么就等到他触地的时候再判断了
-			float max_val = left_step_data_vector.front().pos_x;
+		int right_dist = right_roll_vec.back() - right_roll_vec.front();
+
+		int left_dist = left_roll_vec.back() - left_roll_vec.front();
 
-			for (int i = 0; i < left_step_data_vector.size(); i++)
+		if (right_dist > 800 && left_dist > 800)
+		{
+			if (right_dist > 2000 || left_dist > 2000)
 			{
-				if (left_step_data_vector[i].pos_x > max_val)
+				std::cout << "right_dist : " << right_dist << " left_dist :" << left_dist << endl;
+				if (right_dist > left_dist)
 				{
-					max_val = left_step_data_vector[i].pos_x;
+					right_cmd = MOTION_RIGHT;
+				}
+				else
+				{
+					left_cmd = MOTION_LEFT;
 				}
-			}
-			//有效距离为0.23m
-			if (max_val - left_step_data_vector.back().pos_x > 0.23f)
-			{
-				left_cmd = MOTION_LEFT;
-				std::cout << "motion: left_side" << std::endl;
-
-				left_step_data_vector.pop_front();
 			}
 		}
 	}
 
-	int right_cmd = -1;
-	if (right_step_data_vector.size() > 1 && right_step_data_vector.front().zupt == 1)
+	result[0] = -1;
+
+	if (left_cmd != last_left_cmd && left_cmd == MOTION_LEFT)
 	{
+		result[0] = MOTION_LEFT;
+		std::cout << "	result[0] = MOTION_LEFT;" << endl;
+	}
 
-		if (right_step_data_vector.back().zupt || right_step_data_vector.back().pitch < 0.3f)
-		{
+	result[1] = -1;
+	if (right_cmd != last_right_cmd && right_cmd == MOTION_RIGHT)
+	{
+		result[1] = MOTION_RIGHT;
+		std::cout << "	result[1] = MOTION_RIGHT;" << endl;
+	}
 
-			float min_val = right_step_data_vector.front().pos_x;
+	last_left_cmd = left_cmd;
+	
+	last_right_cmd = right_cmd;
 
-			for (int i = 0; i < right_step_data_vector.size(); i++)
-			{
-				if (right_step_data_vector[i].pos_x < min_val)
-				{
-					min_val = right_step_data_vector[i].pos_x;
-				}
-			}
 
-			if (right_step_data_vector.back().pos_x - min_val > 0.23f)
-			{
-				right_cmd = MOTION_RIGHT;
+	////存放一步的空中数据到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);
 
-				std::cout << "motion: right_side" << std::endl;
+	//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);
 
-				right_step_data_vector.pop_front();
-			}
-		}
-	}
+	////计算全局位置,选择当前的旋转量为这一步即将离地时候的方向,额外的旋转量为10度
+	////hoes_data_vector存的是鞋子上传的数据,它的方向是鞋子烧录时候的方向,并不是玩游戏时候的方向,需要旋转至玩游戏的方向
+	////step_data_vector 的位置已经选择到游戏的方向了,位置是相对位移,即相对于left_step_data_vector[0]的位置偏移
+	//calGlobalPos(right_shoes_data_vector, right_step_data_vector, right_global_pos, right_shoes_data_vector[0].heading, 10.0f / 180 * PI, RIGHT_FOOT);
+	//calGlobalPos(left_shoes_data_vector, left_step_data_vector, left_global_pos, left_shoes_data_vector[0].heading, -10.0f / 180 * PI, LEFT_FOOT);
 
-	int jump_cmd = -1;
+	////这里为了脚本容易观测,设置全局位置为0
+	//if (left_step_data_vector.front().zupt == 0)
+	//{
+	//	memset(left_global_pos, 0, 3 * sizeof(float));
+	//}
+
+	//if (right_step_data_vector.front().zupt == 0)
+	//{
+	//	memset(right_global_pos, 0, 3 * sizeof(float));
+	//}
+
+	//if (left_step_data_vector.size() > 100)
+	//{
+	//	left_step_data_vector.pop_front();
+	//}
+
+	//if (right_step_data_vector.size() > 100)
+	//{
+	//	right_step_data_vector.pop_front();
+	//}
 
-	jump_cmd = getResultJump(jump);
 
-	int down_cmd = -1;
+	////判断命令触发
+	//int left_cmd = -1;
+	//if (left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1)
+	//{
+	//	//跑酷游戏只要有空中的数据(不想其他游戏一样需要落地时候判断就好),就需要进行游戏
+	//	if (left_step_data_vector.back().zupt || left_step_data_vector.back().pitch < 0.3f)
+	//	{
+	//		//垫脚跑不触发命令。如果硬要垫脚跑,那么就等到他触地的时候再判断了
+
+	//		float max_val = left_step_data_vector.front().pos_x;
+
+	//		for (int i = 0; i < left_step_data_vector.size(); i++)
+	//		{
+	//			if (left_step_data_vector[i].pos_x > max_val)
+	//			{
+	//				max_val = left_step_data_vector[i].pos_x;
+	//			}
+	//		}
+
+	//		int roll_valid = 0;
+	//		float front_roll = left_step_data_vector.front().roll;
+	//		for (int i = 1; i < left_step_data_vector.size(); i++)
+	//		{
+	//			if (left_step_data_vector[i].roll > left_step_data_vector[i - 1].roll - 0.000001f)
+	//			{
+	//				if (left_step_data_vector[i].roll - front_roll > 0.3f)
+	//				{
+	//					roll_valid = 1;
+	//				}
+	//				continue;
+	//			}
+	//			front_roll = left_step_data_vector[i].roll;
+	//		}
+	//		
+
+	//		//有效距离为0.23m
+	//		if (max_val - left_step_data_vector.back().pos_x > 0.23f && roll_valid)
+	//		{
+	//			if (!(rssi_delay.size() > 0 && rssi < 25 && rssi_delay.front() > 32))
+	//			{
+	//				left_cmd = MOTION_LEFT;
+	//				std::cout << "motion: left_side, " << left_step_data_vector.back().pitch << std::endl;
+	//			}
+
+	//			left_step_data_vector.pop_front();
+	//		}
+	//	}
+	//}
 
-	result[3] = -1;
+	//int right_cmd = -1;
+	//if (right_step_data_vector.size() > 1 && right_step_data_vector.front().zupt == 1)
+	//{
 
-	down_cmd = getResultDown(down);
+	//	if (right_step_data_vector.back().zupt || right_step_data_vector.back().pitch < 0.3f)
+	//	{
+
+	//		float min_val = right_step_data_vector.front().pos_x;
+
+	//		for (int i = 0; i < right_step_data_vector.size(); i++)
+	//		{
+	//			if (right_step_data_vector[i].pos_x < min_val)
+	//			{
+	//				min_val = right_step_data_vector[i].pos_x;
+	//			}
+	//		}
+
+	//		int roll_valid = 0;
+	//		float front_roll = right_step_data_vector.front().roll;
+	//		for (int i = 1; i < right_step_data_vector.size(); i++)
+	//		{
+	//			if (right_step_data_vector[i].roll > right_step_data_vector[i - 1].roll - 0.000001f)
+	//			{
+	//				if (right_step_data_vector[i].roll - front_roll > 0.3f)
+	//				{
+	//					roll_valid = 1;
+	//				}
+	//				continue;
+	//			}
+	//			front_roll = right_step_data_vector[i].roll;
+	//		}
+
+	//		if (right_step_data_vector.back().pos_x - min_val > 0.23f && roll_valid)
+	//		{
+	//			if (!(rssi_delay.size() > 0 && rssi < 25 && rssi_delay.front() > 32))
+	//			{
+	//				right_cmd = MOTION_RIGHT;
+
+	//				std::cout << "motion: right_side, " << left_step_data_vector.back().pitch << std::endl;
+	//			}
+	//			right_step_data_vector.pop_front();
+	//		}
+	//	}
+	//}
+
+
+
+	//result[0] = left_cmd;
+
+	//result[1] = right_cmd;
+
+	result[2] = getResultJump(jump);
+
+	result[3] = getResultDown(down);
+
+	//result[2] = left_zupt;
+
+	//result[3] = right_zupt;
 
 
 	left_acc_deque.push_back(left_acc[2]);
@@ -156,42 +270,6 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
 		}
 	}
 
-	if (down_cmd == 1)
-	{
-		wait_down = 10;
-	}
-	if (down_cmd == MOTION_DOWN)
-	{
-		addMotionCount(DOWN_COUNT);
-
-		result[3] = MOTION_DOWN;
-
-	}
-	//std::cout << "test_down" << endl;
-	//if (wait_down == 1  && acc_valid == 1)
-	//if (wait_down == 10)
-	//if(down)
-	//{
-
-	//	addMotionCount(DOWN_COUNT);
-
-	//	down_wait_after_jump = 20;
-
-	//	result[3] = MOTION_DOWN;
-
-	//	wait_down = 0;
-	//}
-
-
-	if (wait_down > 0)
-	{
-		wait_down--;
-	}
-
-	result[0] = left_cmd;
-	result[1] = right_cmd;
-	result[2] = jump_cmd;
-	//result[3] = down_cmd;
 
 	//续一个空中不能触发蹲的命令
 	/*if (left_zupt == 0 && right_zupt == 0 && down_wait_after_jump > 0)
@@ -222,8 +300,6 @@ int RunGame::getResultDown(int down)
 {
 	int isDown = -1;
 
-	int canva_down = ((down & 0x04) > 0 ? 1 : 0);
-	
 	if (last_down == 0 && down > 0)
 	{
 		isDown = MOTION_DOWN;
@@ -234,28 +310,16 @@ int RunGame::getResultDown(int down)
 
 		//down_count++;
 	}
-	/*
-	* down_wait_after_jump:避免前脚蹲后,接着后脚压下来的情况,当down_wait_after_jump == -1时候,判断蹲生效
-	* 当一直处于蹲的时候,额外加拖延时间,在这个时间不允许触发蹲。
-	*/
-
-	if (down == 0 && down_wait_after_jump >=0)
-	{
-		down_wait_after_jump--;
-	}
 
 	last_down = down;
 
-	last_canva_down = canva_down;
-
-
 	return isDown;
 
 }
 
 int RunGame::getResultJump(int jump)
 {
-	int isJump = 0;
+	int isJump = -1;
 
 	if (last_jump == 0 && jump == 1)
 	{
@@ -267,13 +331,6 @@ int RunGame::getResultJump(int jump)
 
 		jump_count++;
 	}
-	/*
-	* 跳之后不能立即接着蹲,用down_wait_after_jump来避免
-	*/
-	if (jump)
-	{
-		down_wait_after_jump = 20;
-	}
 
 	last_jump = jump;
 

+ 29 - 26
plugin/shoes_sdk/ios/Classes/src/SportFunction.cpp

@@ -60,31 +60,31 @@ void SportFunction::checkShoesData(deque<sport_data_struct>& shoes_data_vector)
 
 	//假定真正的触地一定伴随着压力的上升。
 
-	if (shoes_data_vector.back().zupt == 1 && len > 1)
-	{
-		int circle_len = 10 > len - 1 ? len - 1 : 10;
-
-		int front_min_press = shoes_data_vector.back().front_press;
-		int back_min_press = shoes_data_vector.back().back_press;
-
-		for (auto it = shoes_data_vector.rbegin(); it < shoes_data_vector.rbegin() + circle_len; it++)
-		{
-			if (it->front_press < front_min_press)
-			{
-				front_min_press = it->front_press;
-			}
-
-			if (it->back_press > back_min_press)
-			{
-				back_min_press = it->back_press;
-			}
-		}
-
-		if (!(shoes_data_vector.back().front_press - front_min_press > 500 || shoes_data_vector.front().front_press - back_min_press > 500))
-		{
-			shoes_data_vector.back().zupt = 0;
-		}
-	}
+	//if (shoes_data_vector.back().zupt == 1 && len > 1)
+	//{
+	//	int circle_len = 10 > len - 1 ? len - 1 : 10;
+
+	//	int front_min_press = shoes_data_vector.back().front_press;
+	//	int back_min_press = shoes_data_vector.back().back_press;
+
+	//	for (auto it = shoes_data_vector.rbegin(); it < shoes_data_vector.rbegin() + circle_len; it++)
+	//	{
+	//		if (it->front_press < front_min_press)
+	//		{
+	//			front_min_press = it->front_press;
+	//		}
+
+	//		if (it->back_press > back_min_press)
+	//		{
+	//			back_min_press = it->back_press;
+	//		}
+	//	}
+
+	//	if (!(shoes_data_vector.back().front_press - front_min_press > 500 || shoes_data_vector.front().front_press - back_min_press > 500))
+	//	{
+	//		shoes_data_vector.back().zupt = 0;
+	//	}
+	//}
 
 	//缓存最大Z轴值, 最小值
 	if (len > 1)
@@ -310,8 +310,9 @@ void SportFunction::Process(int time_stamp, int* right_pos, int* right_att, int*
 	checkShoesData(right_shoes_data_vector);
 	checkShoesData(left_shoes_data_vector);
 
+
 	//统计跳的数目
-	if (checkRopeSkip(left_shoes_data_vector, right_shoes_data_vector))
+	if (last_jump  != jump && jump == 1)
 	{
 		result[5] = ++jump_count;
 
@@ -319,6 +320,8 @@ void SportFunction::Process(int time_stamp, int* right_pos, int* right_att, int*
 
 	}
 
+	last_jump = jump;
+
 	if (left_shoes_data_vector.back().not_on_floor == 1 && right_shoes_data_vector.back().not_on_floor == 1
 		&& (left_shoes_data_vector.back().zupt == 1 || right_shoes_data_vector.back().zupt == 1)
 		&&  (abs(left_shoes_data_vector.front().time_stamp - right_shoes_data_vector.front().time_stamp)) < 30)

+ 8 - 8
plugin/shoes_sdk/ios/Classes/src/online_motion.cpp

@@ -62,7 +62,7 @@ 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;
@@ -109,11 +109,11 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 	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();
@@ -237,7 +237,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 
 	}
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷 微小锟戒动锟斤拷
+	//继续补充 微小变动的
 	int little_front_down = 0;
 
 
@@ -281,7 +281,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 
 	if (left_front_mag_canve_queue.size() > 9)
 	{
-		//1锟斤拷锟斤拷锟斤拷祝锟斤拷锟解到一锟斤拷锟斤拷傻牟锟斤拷锟轿�拷拙秃锟�
+		//1、补充蹲,检测到一个完成的波视为蹲就好
 
 		int left_top_index;
 		int left_foot_left_side_index, left_foot_right_side_index;
@@ -292,7 +292,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 		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    //锟斤拷锟街讹拷锟斤拷位锟矫诧拷要锟斤拷锟教�拷锟�
+			abs(left_top_index - right_top_index) < 4    //保持定点位置不要相差太多
 			&&left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_left_side_index] + 700
 			&& left_front_mag_canve_queue[left_top_index] > left_front_mag_canve_queue[left_foot_right_side_index] + 700
 			&& right_front_mag_canve_queue[right_top_index] > right_front_mag_canve_queue[right_foot_left_side_index] + 700
@@ -363,7 +363,7 @@ int online_motion::online_detect_down(int right_front_mag, int left_front_mag, i
 }
 
 /*
-* 锟斤拷獯ワ拷氐锟揭伙拷锟斤拷锟斤拷锟�
+* 检测触地的一个东西
 */
 
 void online_motion::push_press_queue(deque<int>& press_queue, int press, int queue_size)
@@ -427,7 +427,7 @@ int online_motion::online_detect_touch_floor(int right_front_mag, int left_front
 
 
 /*
-* 锟斤拷锟竭硷拷锟斤拷锟�
+* 在线检测跳
 */
 
 int online_motion::online_detect_jump(int right_front_mag, int left_front_mag, int right_back_mag, int  left_back_mag,