kidd3166 před 1 rokem
rodič
revize
cfbbd32d45

+ 5 - 2
lib/pages/run/run_start.dart

@@ -209,8 +209,8 @@ class _PageState extends LifecycleState<RunStartPage> with TickerProviderStateMi
     AMapFlutterLocation.updatePrivacyAgree(true);
     AMapFlutterLocation.setApiKey(KEY_ANDROID, KEY_IOS);
 
-    _startLocation();
     await _addStepCount(true);
+    _startLocation();
   }
 
   _playAudio(List<String> audios) {
@@ -528,7 +528,10 @@ class _PageState extends LifecycleState<RunStartPage> with TickerProviderStateMi
     // }));
 
     if (Platform.isAndroid) {
-      await Permission.activityRecognition.request();
+      bool permissions = await Permission.activityRecognition.isGranted;
+      if (!permissions) {
+        return;
+      }
     }
 
     addSubscription(Pedometer.stepDetectionStream.listen((event) {

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

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

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

@@ -191,6 +191,24 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 	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)
 {
+
+	//由于刚触地的时候,会偶尔丢掉触地信号的关键帧,现在在线补充一下
+	
+	int online_zupt = extract_motion.online_detect_touch_floor( right_front_press,  left_front_press, right_back_press,  left_back_press);
+
+	if (online_zupt & 0x01)
+	{
+		std::cout << "test :: left_zupt" << endl;
+		left_zupt = 1;
+	}
+	if (online_zupt & 0x02)
+	{
+		std::cout << "test :: right_zupt" << endl;
+		right_zupt = 1;
+	}
+
+
+
 	//缓存一步内的空中数据
 	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);
@@ -217,6 +235,8 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 			//根据过往记录的位置点来,来优化
 			//ProcessResult(left_global_pos, left_step_data_vector, left_global_pos_vector, LEFT_FOOT);
 
+			addMotionCount(STEP_COUNT);
+
 			left_cmd_step_data_vector = left_step_data_vector;
 
 			float dy = left_step_data_vector.back().pos_y - left_step_data_vector.front().pos_y;
@@ -243,6 +263,8 @@ void FingerGuessing::Process(int time_stamp, int* right_pos, int* right_att, int
 			//根据过往记录的位置点来,来优化
 			//ProcessResult(right_global_pos, right_step_data_vector, right_global_pos_vector, RIGHT_FOOT);
 
+			addMotionCount(STEP_COUNT);
+
 			right_cmd_step_data_vector = right_step_data_vector;
 
 			float dy = right_step_data_vector.back().pos_y - right_step_data_vector.front().pos_y;

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

@@ -44,25 +44,25 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 	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)
 {
-	//锟斤拷锟斤拷一锟斤拷锟节的匡拷锟斤拷锟斤拷锟斤拷
+	//缓存一步内的空中数据
 	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);
 
-	//锟斤拷锟斤拷锟脚革拷锟斤拷氐锟斤拷锟斤拷锟�
+	//补充后脚跟落地的问题
 
 	left_back_press_vector.push_back(left_back_press);
 
 	if(left_back_press_vector.size()> 10)
 	{
-		//锟斤拷示锟叫达拷锟斤拷锟斤拷锟斤拷时锟津,达拷锟斤拷锟斤拷锟�, 锟角诧拷锟斤拷为锟劫达拷锟斤拷
+		//表示有触地命令时候,触发检测, 是不是为假触地
 		left_back_press_vector.pop_front();
 		auto max_point = std::max_element(left_back_press_vector.begin(), left_back_press_vector.end());
 		auto min_point = std::min_element(left_back_press_vector.begin(), left_back_press_vector.end());
@@ -99,7 +99,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 
 	if (right_back_press_vector.size() > 10)
 	{
-		//锟斤拷示锟叫达拷锟斤拷锟斤拷锟斤拷时锟津,达拷锟斤拷锟斤拷锟�, 锟角诧拷锟斤拷为锟劫达拷锟斤拷
+		//表示有触地命令时候,触发检测, 是不是为假触地
 		right_back_press_vector.pop_front();
 		auto max_point = std::max_element(right_back_press_vector.begin(), right_back_press_vector.end());
 		auto min_point = std::min_element(right_back_press_vector.begin(), right_back_press_vector.end());
@@ -181,7 +181,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 		}
 	}
 
-	//通锟斤拷锟斤拷锟劫度★拷锟皆硷拷vector锟窖撅拷锟斤拷锟斤拷锟剿匡拷锟叫碉拷锟斤拷锟斤拷锟斤拷锟斤拷位锟叫讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟斤拷锟斤拷锟斤拷锟斤拷时锟叫断碉拷效锟斤拷锟斤拷锟斤拷时锟斤拷为锟剿等猴拷锟绞碉拷RSSI
+	//通过加速度、以及vector已经缓存了空中的数据来定位判断命令所需的时间戳,这个时间戳是起延时判断的效果,延时是为了等合适的RSSI
 	if (left_step_data_vector.size() > 4 && left_step_data_vector.front().zupt == 1 && left_step_data_vector.back().zupt == 1
 		&& (left_back_press_detect_time == 0 || left_back_press_detect_time == 50))
 	{
@@ -214,7 +214,7 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 
 	}
 
-	/*锟斤拷蛹锟斤拷俣裙锟斤拷锟斤拷锟�
+	/*添加加速度过滤器
 	for (int i = 1; i < 3; i++)
 	{
 		for (int k = 0; k < 3; k++)
@@ -271,11 +271,11 @@ void JumpHouse::Process(int time_stamp, int* right_pos, int* right_att, int* rig
 
 	count++;
 
-	//锟斤拷锟斤拷锟斤拷锟斤拷
+	//重置命令
 	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 < 20 && left_press_valid > 0)
 	{

+ 12 - 12
plugin/shoes_sdk/ios/Classes/src/Tricycle.cpp

@@ -37,7 +37,7 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	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)
 {
-	//1锟斤拷确锟斤拷锟斤拷始锟侥凤拷锟斤拷
+	//1、确定初始的方向
 
 
 	if (left_acc_z_queue.size() > 10)
@@ -83,8 +83,8 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 	float cur_right_heading = right_att[0] * 0.0001f;
 
 
-	//锟斤拷锟斤拷锟绞硷拷锟斤拷锟�
-	if (left_zupt_count > 50 && right_zupt_count > 50)
+	//计算初始方向
+	if (left_zupt_count > 100 && right_zupt_count > 100)
 	{
 		left_foot_init_heading = cur_left_heading;
 		right_foot_init_heading = cur_right_heading;
@@ -113,10 +113,10 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 	float game_heading_offset = (left_heading_offset + right_heading_offset) * 0.5f;
 
-	//std::cout << "前锟斤拷锟斤拷锟斤拷 锟斤拷" << game_heading_offset / PI * 180.0f<<endl;
+	//std::cout << "前进度数 :" << game_heading_offset / PI * 180.0f<<endl;
 
-	//2锟斤拷锟斤拷锟斤拷锟酵放碉拷锟斤拷
-	//锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟姐,锟斤拷锟斤拷么锟叫讹拷双锟斤拷同时锟斤拷锟截o拷锟斤拷锟斤拷锟斤拷锟斤拷0.5S锟斤拷锟揭的达拷小锟斤拷锟饺达拷锟斤拷锟斤拷锟脚号碉拷同时锟斤拷锟斤拷
+	//2、控制释放道具
+	//先设置一个触发命令的时间点,即怎么判定双脚同时触地,现在设置0.5S左右的大小来等待触地信号的同时到达
 
 	int down_prop = -1;
 
@@ -127,13 +127,13 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 		left_jump_status = 1;
 		right_jump_status = 1;
 
-		//统锟斤拷锟斤拷
+		//统计跳
 		addMotionCount(JUMP_COUNT);
 
-		std::cout << "锟斤拷锟斤拷锟叫筹拷锟斤拷锟斤拷" << endl;
+		std::cout << "过程中出现跳" << endl;
 	}
 
-	//统锟狡诧拷锟斤拷
+	//统计步数
 	if (left_zupt && last_left_zupt == 0)
 	{
 		result[0] = MOTION_LEFT_ON_FLOOR;
@@ -163,14 +163,14 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 			prop_status = up_prop;
 
-			std::cout << "锟较诧拷 锟斤拷锟斤拷锟斤拷品" << endl;
+			std::cout << "上层 发放物品" << endl;
 		}
 		else if (left_jump_status == 1 && right_jump_status == 1)
 		{
 			if (abs(left_pos_offset) < 100 && abs(right_pos_offset) < 100 && prop_status == 1)
 			{
 				up_prop = 1;
-				std::cout << "锟斤拷为锟较革拷状态锟斤拷 锟较层发锟斤拷锟斤拷品锟斤拷锟斤拷锟斤拷 锟斤拷锟揭诧拷锟� 锟较层发锟斤拷锟斤拷品" << endl;
+				std::cout << "因为上个状态是 上层发放物品,所以 这次也是 上层发放物品" << endl;
 			}
 			else if (abs(left_pos_offset) < 80 && abs(right_pos_offset) < 80)
 			{
@@ -178,7 +178,7 @@ void Tricycle::Process(int time_stamp, int* right_pos, int* right_att, int* righ
 
 				prop_status = 0;
 
-				std::cout << "锟铰诧拷 锟斤拷锟斤拷锟斤拷品" << endl;
+				std::cout << "下层 发放物品" << endl;
 			}
 			else
 			{

+ 1 - 1
pubspec.yaml

@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
 # Read more about iOS versioning at
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.5.2+15202
+version: 1.5.2+15203
 
 environment:
   sdk: ">=2.16.0 <3.0.0"