|
@@ -2,63 +2,6 @@
|
|
|
|
|
|
#include "BuildHouse.h"
|
|
|
|
|
|
-bool isUpDeque(deque<dualPressData>& dual_press,int &min_index, int deque_size)
|
|
|
-{
|
|
|
- if (dual_press.size() != deque_size)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- int max_left_val = dual_press.front().left_press;
|
|
|
- int max_right_val = dual_press.front().right_press;
|
|
|
-
|
|
|
- int max_left_index = 0;
|
|
|
- int max_right_index = 0;
|
|
|
-
|
|
|
- int min_left_val = dual_press.front().left_press;
|
|
|
- int min_right_val = dual_press.front().right_press;
|
|
|
-
|
|
|
- int min_left_index = 0;
|
|
|
- int min_right_index = 0;
|
|
|
-
|
|
|
-
|
|
|
- for (int i = 0; i < dual_press.size(); i++)
|
|
|
- {
|
|
|
- if (max_left_val < dual_press[i].left_press)
|
|
|
- {
|
|
|
- max_left_val = dual_press[i].left_press;
|
|
|
- max_left_index = i;
|
|
|
- }
|
|
|
- if (max_right_val < dual_press[i].right_press)
|
|
|
- {
|
|
|
- max_right_val = dual_press[i].right_press;
|
|
|
- max_right_index = i;
|
|
|
- }
|
|
|
-
|
|
|
- if (min_left_val > dual_press[i].left_press)
|
|
|
- {
|
|
|
- min_left_val = dual_press[i].left_press;
|
|
|
- min_left_index = i;
|
|
|
- }
|
|
|
- if (min_right_val > dual_press[i].right_press)
|
|
|
- {
|
|
|
- min_right_val = dual_press[i].right_press;
|
|
|
- min_right_index = i;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (max_left_val - min_left_val > 50 && max_left_index > min_left_index &&
|
|
|
- max_right_val - min_right_val > 50 && max_right_index > min_right_index)
|
|
|
- {
|
|
|
- min_index = max(min_left_index, min_right_index);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
bool isValidAcc(deque<dualAccData>& dual_acc, int start_index, int thresh_hold)
|
|
|
{
|
|
|
int left_max_val = dual_acc[start_index].left_acc;
|
|
@@ -97,161 +40,10 @@ bool isValidAcc(deque<dualAccData>& dual_acc, int start_index, int thresh_hold)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-int isUptrendDeque(deque<dualPressData> &dual_press_front,int deque_size)
|
|
|
-{
|
|
|
- int min_index = deque_size - 1;
|
|
|
-
|
|
|
|
|
|
|
|
|
- if (deque_size > 4)
|
|
|
- {
|
|
|
- while (min_index > 3)
|
|
|
- {
|
|
|
- if ((dual_press_front[min_index].left_press < dual_press_front[min_index - 1].left_press
|
|
|
- || dual_press_front[min_index].left_press < dual_press_front[min_index - 2].left_press
|
|
|
- || dual_press_front[min_index].left_press < dual_press_front[min_index - 3].left_press) &&
|
|
|
- (dual_press_front[min_index].right_press < dual_press_front[min_index - 1].right_press
|
|
|
- || dual_press_front[min_index].right_press < dual_press_front[min_index - 2].right_press
|
|
|
- || dual_press_front[min_index].right_press < dual_press_front[min_index - 3].right_press))
|
|
|
- /* && dual_press_front[min_index].left_press > 10000
|
|
|
- && dual_press_front[min_index].right_press > 10000)*/
|
|
|
- {
|
|
|
- min_index--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if( dual_press_front[deque_size - 1].left_press - dual_press_front[min_index].left_press < -2000
|
|
|
- && dual_press_front[deque_size - 1].right_press - dual_press_front[min_index].right_press < -2000)
|
|
|
- {
|
|
|
-
|
|
|
- return 1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
-void setUptrendDequeFront(deque<dualPressData>& dual_press_front, deque<dualPressData>& front_press_left, deque<dualPressData>& front_press_right, int deque_size)
|
|
|
-{
|
|
|
- if (dual_press_front.size() == deque_size)
|
|
|
- {
|
|
|
- int left_min_index = 0, left_max_index = 0;
|
|
|
- int right_min_index = 0, right_max_index = 0;
|
|
|
-
|
|
|
- int left_min_press = dual_press_front.front().left_press;
|
|
|
- int right_min_press = dual_press_front.front().right_press;
|
|
|
-
|
|
|
- int left_max_press = left_min_press, right_max_press = right_min_press;
|
|
|
- int i = 0;
|
|
|
- std::for_each(dual_press_front.begin(), dual_press_front.end(), [&](dualPressData value) {
|
|
|
- if (left_min_press > value.left_press) {
|
|
|
- left_min_index = i; left_min_press = value.left_press;
|
|
|
- }
|
|
|
- if (right_min_press > value.right_press) {
|
|
|
- right_min_index = i; right_min_press = value.right_press;
|
|
|
- }
|
|
|
- if (left_max_press < value.left_press) {
|
|
|
- left_max_index = i; left_max_press = value.left_press;
|
|
|
- }
|
|
|
- if (right_max_press < value.right_press) {
|
|
|
- right_max_index = i; right_max_press = value.right_press;
|
|
|
- }
|
|
|
- i++;
|
|
|
- });
|
|
|
-
|
|
|
- if (right_max_index > right_min_index && right_max_press > right_min_press)
|
|
|
- {
|
|
|
- //缓存上升区域
|
|
|
- if (front_press_right.size() == 0)
|
|
|
- {
|
|
|
- for (int i = right_min_index; i < dual_press_front.size(); i++)
|
|
|
- {
|
|
|
- front_press_right.push_back(dual_press_front[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- front_press_right.push_back(dual_press_front.back());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- front_press_right.clear();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (left_max_index > left_min_index && left_max_press > left_min_press)
|
|
|
- {
|
|
|
- //缓存上升区域
|
|
|
- if (front_press_left.size() == 0)
|
|
|
- {
|
|
|
- for (int i = left_min_index; i < dual_press_front.size(); i++)
|
|
|
- {
|
|
|
- front_press_left.push_back(dual_press_front[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- front_press_left.push_back(dual_press_front.back());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- front_press_left.clear();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void detect_concave_curve_left(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
|
|
|
-{
|
|
|
- //1、寻找最小值
|
|
|
- int k = dual_press_back.size() - 1;
|
|
|
-
|
|
|
- right_size_index = k;
|
|
|
-
|
|
|
- while (k > 1)
|
|
|
- {
|
|
|
- if (dual_press_back[k].left_press > dual_press_back[k - 1].left_press
|
|
|
- || dual_press_back[k].left_press > dual_press_back[k - 2].left_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- min_index = k;
|
|
|
-
|
|
|
- int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
|
|
|
-
|
|
|
- while (k > 1)
|
|
|
- {
|
|
|
- if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press
|
|
|
- || dual_press_back[k].left_press < dual_press_back[k - 2].left_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- left_size_index = k;
|
|
|
-}
|
|
|
-
|
|
|
-void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
|
|
|
+void detect_cancave_curve_top(deque<int>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
|
|
|
{
|
|
|
//1、寻找最小值
|
|
|
int k = dual_press_back.size() - 1;
|
|
@@ -260,9 +52,9 @@ void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& m
|
|
|
|
|
|
while (k > 2)
|
|
|
{
|
|
|
- if (dual_press_back[k].left_press < dual_press_back[k - 1].left_press - 50
|
|
|
- || dual_press_back[k].left_press < dual_press_back[k - 2].left_press
|
|
|
- || dual_press_back[k].left_press < dual_press_back[k - 3].left_press)
|
|
|
+ if (dual_press_back[k] < dual_press_back[k - 1] + 50
|
|
|
+ || dual_press_back[k] < dual_press_back[k - 2]
|
|
|
+ || dual_press_back[k] < dual_press_back[k - 3])
|
|
|
{
|
|
|
k--;
|
|
|
}
|
|
@@ -276,67 +68,12 @@ void detect_concave_curve_left_top(deque<dualPressData>& dual_press_back, int& m
|
|
|
|
|
|
max_index = k;
|
|
|
|
|
|
- while (k > 2)
|
|
|
- {
|
|
|
- if (dual_press_back[k].left_press >= dual_press_back[k - 1].left_press
|
|
|
- || dual_press_back[k].left_press > dual_press_back[k - 2].left_press
|
|
|
- || dual_press_back[k].left_press > dual_press_back[k - 3].left_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- left_size_index = k;
|
|
|
-
|
|
|
- int distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
|
|
|
-
|
|
|
- while (k < max_index)
|
|
|
- {
|
|
|
- if (distance > abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press))
|
|
|
- {
|
|
|
- distance = abs(dual_press_back[k].left_press - dual_press_back[right_size_index].left_press);
|
|
|
-
|
|
|
- left_size_index = k;
|
|
|
- }
|
|
|
- k++;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int& max_index, int& right_size_index, int& left_size_index)
|
|
|
-{
|
|
|
- //1、寻找最小值
|
|
|
- int k = dual_press_back.size() - 1;
|
|
|
-
|
|
|
- right_size_index = k;
|
|
|
-
|
|
|
- while (k > 2)
|
|
|
- {
|
|
|
- if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press+50
|
|
|
- || dual_press_back[k].right_press < dual_press_back[k - 2].right_press
|
|
|
- || dual_press_back[k].right_press < dual_press_back[k - 3].right_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- max_index = k;
|
|
|
-
|
|
|
|
|
|
while (k > 2)
|
|
|
{
|
|
|
- if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press -50
|
|
|
- || dual_press_back[k].right_press > dual_press_back[k - 2].right_press
|
|
|
- || dual_press_back[k].right_press > dual_press_back[k - 3].right_press)
|
|
|
+ if (dual_press_back[k] > dual_press_back[k - 1] - 50
|
|
|
+ || dual_press_back[k] > dual_press_back[k - 2]
|
|
|
+ || dual_press_back[k] > dual_press_back[k - 3])
|
|
|
{
|
|
|
k--;
|
|
|
}
|
|
@@ -349,13 +86,13 @@ void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int&
|
|
|
|
|
|
left_size_index = k;
|
|
|
|
|
|
- int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
|
|
|
+ int distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
|
|
|
|
|
|
while (k < max_index)
|
|
|
{
|
|
|
- if (distance > abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press))
|
|
|
+ if (distance > abs(dual_press_back[k] - dual_press_back[right_size_index]))
|
|
|
{
|
|
|
- distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
|
|
|
+ distance = abs(dual_press_back[k] - dual_press_back[right_size_index]);
|
|
|
|
|
|
left_size_index = k;
|
|
|
}
|
|
@@ -363,47 +100,7 @@ void detect_concave_curve_right_top(deque<dualPressData>& dual_press_back, int&
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void detect_concave_curve_right(deque<dualPressData>& dual_press_back, int& min_index, int& right_size_index, int& left_size_index)
|
|
|
-{
|
|
|
- //1、寻找最小值
|
|
|
- int k = dual_press_back.size() - 1;
|
|
|
-
|
|
|
- right_size_index = k;
|
|
|
-
|
|
|
- while (k > 1)
|
|
|
- {
|
|
|
- if (dual_press_back[k].right_press > dual_press_back[k - 1].right_press
|
|
|
- || dual_press_back[k].right_press > dual_press_back[k - 2].right_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- min_index = k;
|
|
|
-
|
|
|
- int distance = abs(dual_press_back[k].right_press - dual_press_back[right_size_index].right_press);
|
|
|
|
|
|
- while (k > 1)
|
|
|
- {
|
|
|
- if (dual_press_back[k].right_press < dual_press_back[k - 1].right_press
|
|
|
- || dual_press_back[k].right_press < dual_press_back[k - 2].right_press)
|
|
|
- {
|
|
|
- k--;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- left_size_index = k;
|
|
|
-}
|
|
|
|
|
|
int mid_window_val(deque<int>& press_deque, int mid_window_size)
|
|
|
{
|
|
@@ -423,6 +120,30 @@ int mid_window_val(deque<int>& press_deque, int mid_window_size)
|
|
|
return press_deque_temp[0];
|
|
|
}
|
|
|
|
|
|
+int BuildHouse::back_press_up_trend(deque<int>& left_press_deque, deque<int>& right_press_deque)
|
|
|
+{
|
|
|
+ if (left_press_deque.size() > 20)
|
|
|
+ {
|
|
|
+ int i = left_press_deque.size() - 1;
|
|
|
+
|
|
|
+ while (i > 10 && (left_press_deque[i] >= left_press_deque[i - 1] || left_press_deque[i] >= left_press_deque[i - 2]
|
|
|
+ || left_press_deque[i] >= left_press_deque[i - 3]) &&
|
|
|
+ (right_press_deque[i] >= right_press_deque[i - 1] || right_press_deque[i] >= right_press_deque[i - 2]
|
|
|
+ || right_press_deque[i] >= right_press_deque[i - 3])
|
|
|
+ && left_press_deque[i] > 12000 && right_press_deque[i] > 12000)
|
|
|
+ {
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (left_press_deque.back() > left_press_deque[i] + 1000&& right_press_deque.back() > right_press_deque[i] + 1000)
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
void BuildHouse::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)
|
|
@@ -440,7 +161,7 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
left_press_filter_window.push_back(left_back_press);
|
|
|
right_press_filter_window.push_back(right_back_press);
|
|
|
|
|
|
-
|
|
|
+ //采用最小值滤波, 较好的过滤毛刺
|
|
|
if (left_press_filter_window.size() > 5)
|
|
|
{
|
|
|
left_press_filter_window.pop_front();
|
|
@@ -451,18 +172,20 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
|
|
|
}
|
|
|
|
|
|
- dual_press_back.push_back({ left_back_press, right_back_press ,time_stamp });
|
|
|
|
|
|
- dual_press_front.push_back({ left_front_press , right_front_press , time_stamp });
|
|
|
|
|
|
- if (dual_press_front.size() > 40)
|
|
|
+
|
|
|
+ left_front_press_queue.push_back(left_front_press); left_back_press_queue.push_back(left_back_press);
|
|
|
+ right_front_press_queue.push_back(right_front_press); right_back_press_queue.push_back(right_back_press);
|
|
|
+
|
|
|
+ if (left_back_press_queue.size() > 40)
|
|
|
{
|
|
|
- dual_press_front.pop_front();
|
|
|
+ left_back_press_queue.pop_front(); right_back_press_queue.pop_front();
|
|
|
}
|
|
|
|
|
|
- if (dual_press_back.size() > 40)
|
|
|
+ if (left_front_press_queue.size() > 40)
|
|
|
{
|
|
|
- dual_press_back.pop_front();
|
|
|
+ left_front_press_queue.pop_front(); right_front_press_queue.pop_front();
|
|
|
}
|
|
|
|
|
|
if (dual_acc.size() > 10)
|
|
@@ -471,7 +194,7 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (dual_press_front.size() == 40)
|
|
|
+ if (left_front_press_queue.size() == 40)
|
|
|
{
|
|
|
/*
|
|
|
* 检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
|
|
@@ -480,48 +203,50 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
|
|
|
int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
|
|
|
|
|
|
- detect_concave_curve_left_top(dual_press_front, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
|
|
|
+ detect_cancave_curve_top(left_front_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
|
|
|
|
|
|
int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
|
|
|
|
|
|
- detect_concave_curve_right_top(dual_press_front, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
|
|
|
+ detect_cancave_curve_top(right_front_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
|
|
|
|
|
|
- int left_dist = 500, right_dist = 500;
|
|
|
+ int left_dist = 1000, right_dist = 1000;
|
|
|
|
|
|
if (wait_press_top_unvalid > 0)
|
|
|
{
|
|
|
left_dist = max(left_dist, left_front_press_top);
|
|
|
right_dist = max(right_dist, right_front_press_top);
|
|
|
}
|
|
|
+
|
|
|
+ bool acc_valid = isValidAcc(dual_acc, 0, 512);
|
|
|
//检测到前脚压力双脚都呈现了凸曲线,那么判断为前脚下蹲
|
|
|
if (abs(left_max_index - right_max_index) < 6 &&
|
|
|
- dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -right_dist
|
|
|
- && dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -right_dist
|
|
|
- && dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -left_dist
|
|
|
- && dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -left_dist
|
|
|
+ right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -right_dist
|
|
|
+ && right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -right_dist
|
|
|
+ && left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -left_dist
|
|
|
+ && left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -left_dist
|
|
|
&& right_foot_right_side_index - right_foot_left_side_index < 31
|
|
|
&& left_foot_right_side_index - left_foot_left_side_index < 31
|
|
|
- && isValidAcc(dual_acc, 0, 512)
|
|
|
+ && acc_valid
|
|
|
//&& abs(dual_press_front[right_max_index].right_press - dual_press_front[left_max_index].left_press) < 8000//经验值
|
|
|
)
|
|
|
{
|
|
|
// 还要检测双凸曲线的顶点,如果还处于上一个双凸曲线的有效时间内,则顶点值与左右的差值需要大于上一个双凸曲线,才能判断有效的双凸曲线
|
|
|
// 记录上一个双凸曲线的差值
|
|
|
- if (dual_press_front[right_foot_right_side_index].right_press - dual_press_front[right_max_index].right_press < -1000
|
|
|
- && dual_press_front[right_foot_left_side_index].right_press - dual_press_front[right_max_index].right_press < -1000
|
|
|
- && dual_press_front[left_foot_right_side_index].left_press - dual_press_front[left_max_index].left_press < -1000
|
|
|
- && dual_press_front[left_foot_left_side_index].left_press - dual_press_front[left_max_index].left_press < -1000)
|
|
|
+ if (right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -1000
|
|
|
+ && right_front_press_queue[right_foot_left_side_index] - right_front_press_queue[right_max_index] < -1000
|
|
|
+ && left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -1000
|
|
|
+ && left_front_press_queue[left_foot_left_side_index] - left_front_press_queue[left_max_index] < -1000)
|
|
|
{
|
|
|
- int right_dist = dual_press_front[right_max_index].right_press - dual_press_front[right_foot_right_side_index].right_press;
|
|
|
+ int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
|
|
|
|
|
|
- right_dist = min(right_dist, dual_press_front[right_max_index].right_press - dual_press_front[right_foot_left_side_index].right_press);
|
|
|
+ right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
|
|
|
|
|
|
//right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
|
|
|
right_front_press_top = 0.5 * right_dist;
|
|
|
|
|
|
- int left_dist = dual_press_front[left_max_index].left_press - dual_press_front[left_foot_right_side_index].left_press;
|
|
|
+ int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
|
|
|
|
|
|
- left_dist = min(left_dist, dual_press_front[left_max_index].left_press - dual_press_front[left_foot_left_side_index].left_press);
|
|
|
+ left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
|
|
|
|
|
|
//left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
|
|
|
left_front_press_top = 0.5 * left_dist;
|
|
@@ -533,136 +258,97 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
front_down = 1;
|
|
|
}
|
|
|
|
|
|
- //int i = dual_press_front.size() - 1;
|
|
|
- //for (; i > dual_press_front.size() - 15; i--)
|
|
|
- //{
|
|
|
- // /*if (dual_press_front[i].left_press > dual_press_front[i - 1].left_press
|
|
|
- // && dual_press_back[i].left_press > dual_press_back[i - 1].left_press
|
|
|
- // && dual_press_front[i].right_press > dual_press_front[i - 1].right_press
|
|
|
- // && dual_press_back[i].right_press > dual_press_back[i - 1].right_press)*/
|
|
|
- // if ((dual_press_front[i].left_press < dual_press_front[i - 1].left_press || dual_press_front[i].left_press < dual_press_front[i - 2].left_press)
|
|
|
- // && (dual_press_front[i].right_press < dual_press_front[i - 1].right_press || dual_press_front[i].right_press < dual_press_front[i - 2].right_press))
|
|
|
- // {
|
|
|
- // continue;
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // break;
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- ////曲线有在15个数据处于上升曲线,则判断为前蹲
|
|
|
- //if (
|
|
|
- // dual_press_front.back().left_press < dual_press_front[i].left_press - 1200
|
|
|
- // && dual_press_front.back().right_press < dual_press_front[i].right_press - 1200)
|
|
|
- //{
|
|
|
- // front_down = 1;
|
|
|
- //}
|
|
|
- //延续前蹲的操作
|
|
|
- /* if (last_front_down == 1 &&
|
|
|
- (dual_press_front[39].left_press < dual_press_front[38].left_press || dual_press_front[39].left_press < dual_press_front[37].left_press)
|
|
|
- && (dual_press_front[39].right_press < dual_press_front[38].right_press || dual_press_front[39].right_press < dual_press_front[37].right_press))
|
|
|
+ if ( left_front_press_queue[left_foot_right_side_index] - left_front_press_queue[left_max_index] < -2000
|
|
|
+ && right_front_press_queue[right_foot_right_side_index] - right_front_press_queue[right_max_index] < -2000
|
|
|
+ && left_foot_right_side_index - left_max_index < 30 && right_foot_right_side_index - right_max_index < 30
|
|
|
+ )
|
|
|
{
|
|
|
- front_down = 1;
|
|
|
- }*/
|
|
|
- }
|
|
|
|
|
|
- int back_down = 0;
|
|
|
- if (dual_press_back.size()==40)
|
|
|
- {
|
|
|
- int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
|
|
|
+ int right_dist = right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_right_side_index];
|
|
|
|
|
|
- detect_concave_curve_left_top(dual_press_back, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
|
|
|
+ right_dist = min(right_dist, right_front_press_queue[right_max_index] - right_front_press_queue[right_foot_left_side_index]);
|
|
|
|
|
|
- int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
|
|
|
+ //right_front_press_top = dual_press_front[right_max_index].right_press - 0.5 * right_dist;
|
|
|
+ right_front_press_top = 0.5 * right_dist;
|
|
|
|
|
|
- detect_concave_curve_right_top(dual_press_back, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
|
|
|
+ int left_dist = left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_right_side_index];
|
|
|
|
|
|
+ left_dist = min(left_dist, left_front_press_queue[left_max_index] - left_front_press_queue[left_foot_left_side_index]);
|
|
|
|
|
|
- int special_down = 0;
|
|
|
+ //left_front_press_top = dual_press_front[left_max_index].left_press - 0.5 * left_dist;
|
|
|
+ left_front_press_top = 0.5 * left_dist;
|
|
|
|
|
|
- //同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
|
|
|
- if (
|
|
|
- abs(left_max_index - right_max_index) < 11 &&
|
|
|
- dual_press_back[right_foot_right_side_index].right_press - dual_press_back[right_max_index].right_press < -1000
|
|
|
- && dual_press_back[right_foot_left_side_index].right_press - dual_press_back[right_max_index].right_press < -1000
|
|
|
- && dual_press_back[left_foot_right_side_index].left_press - dual_press_back[left_max_index].left_press < -1000
|
|
|
- && dual_press_back[left_foot_left_side_index].left_press - dual_press_back[left_max_index].left_press < -1000
|
|
|
-
|
|
|
- && dual_press_back[right_max_index].right_press > 7500 && dual_press_back[left_max_index].left_press > 7500
|
|
|
-
|
|
|
- )
|
|
|
- {
|
|
|
- back_down = 1;
|
|
|
- //special_down = 1;
|
|
|
+ wait_press_top_unvalid = 60;
|
|
|
+
|
|
|
+ front_down = 1;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- //尝试降采样来一次
|
|
|
-
|
|
|
- if (dual_press_back.size() == 40)
|
|
|
+ int back_down = 0;
|
|
|
+ if (left_back_press_queue.size()>=20 )
|
|
|
{
|
|
|
+ back_down = back_press_up_trend(left_back_press_queue, right_back_press_queue);
|
|
|
|
|
|
- deque<dualPressData> dual_press_back_temp;
|
|
|
-
|
|
|
- for (int i = 0; i < dual_press_back.size(); i+=3)
|
|
|
+ if (back_down)
|
|
|
{
|
|
|
- dual_press_back_temp.push_back(dual_press_back[i]);
|
|
|
- }
|
|
|
+ //记录最大值
|
|
|
+ if (wait_back_press_top_unvalid == 0)
|
|
|
+ {
|
|
|
+ wait_back_press_top_unvalid = 60;
|
|
|
|
|
|
+ left_back_press_top = left_back_press_queue.back();
|
|
|
+ right_back_press_top = right_back_press_queue.back();
|
|
|
|
|
|
- int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (left_back_press_top > left_back_press_queue.back() || right_back_press_top > right_back_press_queue.back())
|
|
|
+ {
|
|
|
+ back_down = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wait_back_press_top_unvalid = 60;
|
|
|
|
|
|
- detect_concave_curve_left_top(dual_press_back_temp, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
|
|
|
+ left_back_press_top = left_back_press_queue.back();
|
|
|
+ right_back_press_top = right_back_press_queue.back();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
|
|
|
+ //int left_max_index, left_foot_right_side_index, left_foot_left_side_index;
|
|
|
|
|
|
- detect_concave_curve_right_top(dual_press_back_temp, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
|
|
|
+ //detect_cancave_curve_top(left_back_press_queue, left_max_index, left_foot_right_side_index, left_foot_left_side_index);
|
|
|
|
|
|
+ //int right_max_index, right_foot_right_side_index, right_foot_left_side_index;
|
|
|
|
|
|
- int special_down = 0;
|
|
|
+ //detect_cancave_curve_top(right_back_press_queue, right_max_index, right_foot_right_side_index, right_foot_left_side_index);
|
|
|
|
|
|
- //同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
|
|
|
- if (
|
|
|
- abs(left_max_index - right_max_index) < 11 &&
|
|
|
- dual_press_back_temp[right_foot_right_side_index].right_press - dual_press_back_temp[right_max_index].right_press < -1500
|
|
|
- && dual_press_back_temp[right_foot_left_side_index].right_press - dual_press_back_temp[right_max_index].right_press < -1000
|
|
|
- && dual_press_back_temp[left_foot_right_side_index].left_press - dual_press_back_temp[left_max_index].left_press < -1500
|
|
|
- && dual_press_back_temp[left_foot_left_side_index].left_press - dual_press_back_temp[left_max_index].left_press < -1000
|
|
|
|
|
|
- && dual_press_back_temp[right_max_index].right_press > 7500 && dual_press_back_temp[left_max_index].left_press > 7500
|
|
|
+ //int special_down = 0;
|
|
|
|
|
|
- )
|
|
|
- {
|
|
|
- back_down = 1;
|
|
|
- //special_down = 1;
|
|
|
- }
|
|
|
+ ////同样的检测双凹曲线,但是这个曲线应当为√曲线,左低右高
|
|
|
+ //if (
|
|
|
+ // abs(left_max_index - right_max_index) < 11 &&
|
|
|
+ // right_back_press_queue[right_foot_right_side_index] - right_back_press_queue[right_max_index] < -1500
|
|
|
+ // && right_back_press_queue[right_foot_left_side_index] - right_back_press_queue[right_max_index] < -1500
|
|
|
+ // && left_back_press_queue[left_foot_right_side_index] - left_back_press_queue[left_max_index] < -1500
|
|
|
+ // && left_back_press_queue[left_foot_left_side_index] - left_back_press_queue[left_max_index] < -1500
|
|
|
+ // && right_back_press_queue[right_max_index] > 12000 && left_back_press_queue[left_max_index] > 12000
|
|
|
+ // )
|
|
|
+ //{
|
|
|
+ // back_down = 1;
|
|
|
+ //}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /*if (front_down == 1)
|
|
|
- {
|
|
|
- front_down_cmd_wait_time = 10;
|
|
|
- }*/
|
|
|
-
|
|
|
- if (front_down_cmd_wait_time > 0)
|
|
|
+ if (wait_back_press_top_unvalid > 0)
|
|
|
{
|
|
|
- front_down = 1;
|
|
|
- //result[0] = MOTION_DOWN;
|
|
|
+ wait_back_press_top_unvalid--;
|
|
|
}
|
|
|
|
|
|
- //if (back_down == 1)
|
|
|
- //{
|
|
|
- // back_down_cmd_wait_time = 10;
|
|
|
- //}
|
|
|
|
|
|
- if(back_down_cmd_wait_time > 0)
|
|
|
- {
|
|
|
- back_down = 1;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
if (wait_press_top_unvalid > 0)
|
|
|
{
|
|
@@ -674,53 +360,8 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
wait_press_top_unvalid--;
|
|
|
}
|
|
|
|
|
|
- if (wait_back_press_top_unvalid > 0)
|
|
|
- {
|
|
|
- wait_back_press_top_unvalid--;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( dual_press_front.size()==40)
|
|
|
- {
|
|
|
- int size = dual_press_front.size()-1;
|
|
|
-
|
|
|
- deque<dualPressData>::iterator left_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
|
|
|
- [](const dualPressData& val1, const dualPressData& val2) { return val1.left_press < val2.left_press; });
|
|
|
-
|
|
|
- deque<dualPressData>::iterator left_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
|
|
|
- [](const dualPressData& val1, const dualPressData& val2) { return val1.left_press < val2.left_press; });
|
|
|
-
|
|
|
- deque<dualPressData>::iterator right_max_it = std::max_element(dual_press_front.begin() + 20, dual_press_front.end(),
|
|
|
- [](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
|
|
|
-
|
|
|
- deque<dualPressData>::iterator right_min_it = std::min_element(dual_press_front.begin() + 20, dual_press_front.end(),
|
|
|
- [](const dualPressData& val1, const dualPressData& val2) { return val1.right_press < val2.right_press; });
|
|
|
-
|
|
|
- //如果判断上一个任意下蹲情况,当前发现是前脚眼里上升,则视为前脚下蹲状态
|
|
|
- /*if (left_max_it - left_min_it > 0 && left_max_it->left_press - left_min_it->left_press > 50
|
|
|
- && right_max_it - right_min_it > 0 && right_max_it->right_press - right_min_it->right_press > 50)
|
|
|
- {
|
|
|
- if (last_front_down == 1 || last_down == 1)
|
|
|
- {
|
|
|
- front_down = 1;
|
|
|
- }
|
|
|
-
|
|
|
- }*/
|
|
|
-
|
|
|
- /*if((dual_press_front[size].left_press > dual_press_front[size - 1].left_press || dual_press_front[size].left_press > dual_press_front[size - 2].left_press)
|
|
|
- && (dual_press_front[size].right_press > dual_press_front[size - 1].right_press || dual_press_front[size].right_press > dual_press_front[size - 2].right_press))
|
|
|
- {
|
|
|
- if (last_front_down == 1 || last_down == 1)
|
|
|
- {
|
|
|
- front_down = 1;
|
|
|
- }
|
|
|
- }*/
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if ((front_down == 1 || back_down == 1) && (last_down == 0 && last_front_down == 0) && cmd_wait_time == 0)
|
|
|
+ //if((front_down == 1 || back_down == 1))
|
|
|
{
|
|
|
result[0] = MOTION_DOWN;
|
|
|
|
|
@@ -729,53 +370,19 @@ void BuildHouse::Process(int time_stamp, int* right_pos, int* right_att, int* ri
|
|
|
cmd_wait_time = 20;
|
|
|
}
|
|
|
|
|
|
- /*if (( back_down == 1))
|
|
|
- {
|
|
|
- result[0] = MOTION_DOWN;
|
|
|
- }*/
|
|
|
-
|
|
|
+ //处于蹲的倒计时,倒计时就不要工作了
|
|
|
if (!(front_down == 1 || back_down == 1) && cmd_wait_time > 0)
|
|
|
{
|
|
|
cmd_wait_time--;
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //if (cmd_wait_time > 0)
|
|
|
- //{
|
|
|
- // cmd_wait_time--;
|
|
|
-
|
|
|
- // back_down_continue_time++;
|
|
|
-
|
|
|
- //}
|
|
|
-
|
|
|
- if (front_down_cmd_wait_time > 0)
|
|
|
- {
|
|
|
- front_down_cmd_wait_time--;
|
|
|
-
|
|
|
- front_down_continue_time++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- front_down_continue_time = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (front_down_continue_time == 30)
|
|
|
- {
|
|
|
- front_down_continue_time = 0;
|
|
|
- front_down_cmd_wait_time = 0;
|
|
|
- front_down = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (back_down_cmd_wait_time > 0)
|
|
|
- {
|
|
|
- back_down_cmd_wait_time--;
|
|
|
- back_down_continue_time++;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
last_down = back_down;
|
|
|
|
|
|
last_front_down = front_down;
|
|
|
+
|
|
|
+
|
|
|
+ //result[1] = left_back_press;
|
|
|
+ //result[2] = right_back_press;
|
|
|
|
|
|
}
|