|
@@ -22,7 +22,7 @@ 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);
|
|
@@ -38,20 +38,20 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
|
|
|
jump = online_jump;
|
|
|
}*/
|
|
|
|
|
|
- //锟斤拷锟揭伙拷锟斤拷目锟斤拷锟斤拷锟斤拷莸锟絪hoes_data_vector 锟斤拷锟斤拷锟叫o拷 头锟斤拷锟斤拷锟角达拷锟斤拷时锟斤拷锟斤拷息
|
|
|
+ //存放一步的空中数据到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);
|
|
|
|
|
|
- //锟斤拷锟斤拷全锟斤拷位锟矫o拷选锟斤拷前锟斤拷锟斤拷转锟斤拷为锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟绞憋拷锟侥凤拷锟津,讹拷锟斤拷锟斤拷锟阶�拷锟轿�10锟斤拷
|
|
|
- //hoes_data_vector锟斤拷锟斤拷锟叫�拷锟斤拷洗锟斤拷锟斤拷锟斤拷荩锟斤拷锟斤拷姆锟斤拷锟斤拷锟叫�拷锟斤拷锟铰际憋拷锟侥凤拷锟津,诧拷锟斤拷锟斤拷锟斤拷锟斤拷戏时锟斤拷姆锟斤拷锟斤拷锟揭�拷锟阶�拷锟斤拷锟斤拷锟较凤拷姆锟斤拷锟�
|
|
|
- //step_data_vector 锟斤拷位锟斤拷锟窖撅拷选锟斤拷锟斤拷戏锟侥凤拷锟斤拷锟剿o拷位锟斤拷锟斤拷锟斤拷锟轿伙拷疲锟斤拷锟斤拷锟斤拷锟斤拷left_step_data_vector[0]锟斤拷位锟斤拷偏锟斤拷
|
|
|
+ //计算全局位置,选择当前的旋转量为这一步即将离地时候的方向,额外的旋转量为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);
|
|
|
|
|
|
- //锟斤拷锟斤拷为锟剿脚憋拷锟斤拷锟阶观测,锟斤拷锟斤拷全锟斤拷位锟斤拷为0
|
|
|
+ //这里为了脚本容易观测,设置全局位置为0
|
|
|
if (left_step_data_vector.front().zupt == 0)
|
|
|
{
|
|
|
memset(left_global_pos, 0, 3 * sizeof(float));
|
|
@@ -63,15 +63,15 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
|
|
|
}
|
|
|
|
|
|
|
|
|
- //锟叫讹拷锟斤拷锟筋触锟斤拷
|
|
|
+ //判断命令触发
|
|
|
int left_cmd = -1;
|
|
|
if (left_step_data_vector.size() > 1 && left_step_data_vector.front().zupt == 1)
|
|
|
{
|
|
|
std::cout << left_step_data_vector.back().pos_x << ", " << left_step_data_vector.back().pos_y << endl;
|
|
|
- //锟杰匡拷锟斤拷戏只要锟叫匡拷锟叫碉拷锟斤拷锟捷o拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷戏一锟斤拷锟斤拷要锟斤拷锟绞憋拷锟斤拷卸暇秃茫锟斤拷锟斤拷锟斤拷锟揭�拷锟斤拷锟斤拷锟较�
|
|
|
+ //跑酷游戏只要有空中的数据(不想其他游戏一样需要落地时候判断就好),就需要进行游戏
|
|
|
if (left_step_data_vector.back().zupt || left_step_data_vector.back().pitch < 0.3f)
|
|
|
{
|
|
|
- //锟斤拷锟斤拷懿锟斤拷锟斤拷锟斤拷锟斤拷睢o拷锟斤拷硬要锟斤拷锟斤拷埽锟斤拷锟矫达拷偷鹊锟斤拷锟斤拷锟斤拷氐锟绞憋拷锟斤拷锟斤拷卸锟斤拷锟�
|
|
|
+ //垫脚跑不触发命令。如果硬要垫脚跑,那么就等到他触地的时候再判断了
|
|
|
float max_val = left_step_data_vector.front().pos_x;
|
|
|
|
|
|
for (int i = 0; i < left_step_data_vector.size(); i++)
|
|
@@ -81,7 +81,7 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
|
|
|
max_val = left_step_data_vector[i].pos_x;
|
|
|
}
|
|
|
}
|
|
|
- //锟斤拷效锟斤拷锟斤拷为0.23m
|
|
|
+ //有效距离为0.23m
|
|
|
if (max_val - left_step_data_vector.back().pos_x > 0.23f)
|
|
|
{
|
|
|
left_cmd = MOTION_LEFT;
|
|
@@ -164,26 +164,23 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
|
|
|
{
|
|
|
addMotionCount(DOWN_COUNT);
|
|
|
|
|
|
- down_wait_after_jump = 20;
|
|
|
-
|
|
|
result[3] = MOTION_DOWN;
|
|
|
|
|
|
- wait_down = 0;
|
|
|
}
|
|
|
//std::cout << "test_down" << endl;
|
|
|
//if (wait_down == 1 && acc_valid == 1)
|
|
|
//if (wait_down == 10)
|
|
|
- if(down)
|
|
|
- {
|
|
|
+ //if(down)
|
|
|
+ //{
|
|
|
|
|
|
- addMotionCount(DOWN_COUNT);
|
|
|
+ // addMotionCount(DOWN_COUNT);
|
|
|
|
|
|
- down_wait_after_jump = 20;
|
|
|
+ // down_wait_after_jump = 20;
|
|
|
|
|
|
- result[3] = MOTION_DOWN;
|
|
|
+ // result[3] = MOTION_DOWN;
|
|
|
|
|
|
- wait_down = 0;
|
|
|
- }
|
|
|
+ // wait_down = 0;
|
|
|
+ //}
|
|
|
|
|
|
|
|
|
if (wait_down > 0)
|
|
@@ -196,13 +193,13 @@ void RunGame::Process(int time_stamp, int* right_pos, int* right_att, int* right
|
|
|
result[2] = jump_cmd;
|
|
|
//result[3] = down_cmd;
|
|
|
|
|
|
- //锟斤拷一锟斤拷锟斤拷锟叫诧拷锟杰达拷锟斤拷锟阶碉拷锟斤拷锟斤拷
|
|
|
+ //续一个空中不能触发蹲的命令
|
|
|
/*if (left_zupt == 0 && right_zupt == 0 && down_wait_after_jump > 0)
|
|
|
{
|
|
|
down_wait_after_jump = 10;
|
|
|
}*/
|
|
|
|
|
|
- //锟狡诧拷
|
|
|
+ //计步
|
|
|
if (last_left_zupt == 0 && left_zupt == 1 && unzuptValid(max_acc_unzupt_left, min_acc_unzupt_left))
|
|
|
{
|
|
|
addMotionCount(STEP_COUNT);
|
|
@@ -229,7 +226,7 @@ int RunGame::getResultDown(int down)
|
|
|
|
|
|
if (last_down == 0 && down > 0)
|
|
|
{
|
|
|
- isDown = 1;
|
|
|
+ isDown = MOTION_DOWN;
|
|
|
|
|
|
addMotionCount(DOWN_COUNT);
|
|
|
|
|
@@ -238,8 +235,8 @@ int RunGame::getResultDown(int down)
|
|
|
//down_count++;
|
|
|
}
|
|
|
/*
|
|
|
- * down_wait_after_jump:锟斤拷锟斤拷前锟脚蹲后,斤拷锟脚猴拷锟窖癸拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷down_wait_after_jump == -1时锟斤拷锟叫断讹拷锟斤拷效
|
|
|
- * 锟斤拷一直锟斤拷锟节蹲碉拷时锟津,讹拷锟斤拷锟斤拷锟斤拷锟绞憋拷洌�拷锟斤拷锟斤拷时锟戒不锟斤拷锟斤拷锟斤拷锟阶★拷
|
|
|
+ * down_wait_after_jump:避免前脚蹲后,接着后脚压下来的情况,当down_wait_after_jump == -1时候,判断蹲生效
|
|
|
+ * 当一直处于蹲的时候,额外加拖延时间,在这个时间不允许触发蹲。
|
|
|
*/
|
|
|
|
|
|
if (down == 0 && down_wait_after_jump >=0)
|
|
@@ -271,7 +268,7 @@ int RunGame::getResultJump(int jump)
|
|
|
jump_count++;
|
|
|
}
|
|
|
/*
|
|
|
- * 锟斤拷之锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟脚蹲o拷锟斤拷down_wait_after_jump锟斤拷锟斤拷锟斤拷
|
|
|
+ * 跳之后不能立即接着蹲,用down_wait_after_jump来避免
|
|
|
*/
|
|
|
if (jump)
|
|
|
{
|