步频估计
首先,将步频估计出来,速度 = 步频*步长,距离=步数*步长
下面展示了如何识别出下肢的站立相和摆动相,并附上相关python代码,可用ChatGPT转成C代码。
如上图所示,要将上升沿与下降沿识别出来,上升沿中包含了一些低噪声,下降沿中包了部分 高噪声,代码如下,挺繁琐的,无语。。。。。。
def filter():
T_detection = []
peak = max(w_2)*1.3
count_low =0
count_high =0
high_switch=0
low_switch=1
high_statrt =0
low_statrt =0
high_label = 0
for i in range(len(w_2)):
# 如果当前值小于11000
if w_2[i] < 11000:
if low_switch == 1:
low_statrt = 1
count_low += 1
high_switch = 0
high_label = 0 ###########################
# 在low_statrt为1时,确保每轮都有数据
if count_high < 15 and high_statrt == 1:
high_label = 1 ###########################
count_high += 1 # 计数器增加
elif count_high >= 15 and high_statrt == 1:
low_switch = 1
high_statrt = 0
count_high = 0
# 如果当前值不小于11000
else:
if high_switch == 1:
high_statrt = 1
high_label = 1 ###########################
count_high += 1
low_switch = 0
# 在high_statrt为1时,确保每轮都有数据
if count_low < 15 and low_statrt == 1:
high_label = 0 ###########################
count_low += 1 # 计数器增加
elif count_low >= 15 and low_statrt == 1:
high_switch = 1
low_statrt = 0
count_low = 0
if high_label == 1:
T_detection.append(peak) # 添加0到列表
else:
T_detection.append(0) # 添加0到列表
步长估计
根据“Using the ADXL202 in Pedometer and Personal Navigation Applications”文章提到的公式:
where:
Amin is the minimum acceleration measured in the Zaxis in a single stride.
Amax is the maximum acceleration measured in the Zaxis in a single stride.
n is the number of steps walked
K is a constant for unit conversion (i.e., feet or meterstraveled).
讲一下标准的来源:
在行走时,只有当脚离开地面时,膝盖才会弯曲。因此,我们可以把腿看作是一个固定长度的杠杆,而脚是在地上的。图1说明了在行走时,臀部和上半身是如何垂直移动的。通过相似角度的几何形状,我们知道:
所以,可得:
其中,Bounce是臀部(或上半身)的垂直位移(Z轴)。
弹跳(Z轴位移)可以计算为Z轴加速度的第二个积分。是一个小角度,很难测量,因为在行走时所有轴都有很多冲击。我们已经通过经验证明,我们可以简单地使用的一个常数,而没有一个很大的精度损失。实际上,我们可以通过:
实验结果
拟合的行走轨迹 (真实路线近似是矩形)