让我们看看可以用您的示例数据做什么。
免责声明:我没有阅读您的硬件规格(tl;dr :))
为了方便起见,我将在 Mathematica 中解决这个问题。相关算法(不多)将作为链接提供。
第一个观察结果是您的所有测量在时间上都是等距的,这对于简化方法和算法是最方便的。我们将在方便时表示“时间”或“刻度”(测量值),因为它们是等价的。
让我们首先按轴绘制您的位置,看看问题出在哪里:
(* This is Mathematica code, don't mind, I am posting this only for
future reference *)
ListPlot[Transpose@(Take[p1[[All, 2 ;; 4]]][[1 ;;]]),
PlotRange -> All,
AxesLabel -> {Style["Ticks", Medium, Bold],
Style["Position (X,Y,Z)", Medium, Bold]}]

现在,有两个观察结果:
- 您的移动开始于第 1000 点
- 您的移动不是从 {0,0,0} 开始
因此,我们将稍微转换您的数据,减去零位置并从第 950 点开始。
ListLinePlot[
Drop[Transpose@(x - Array[Mean@(x[[1 ;; 1000]]) &, Length@x]), {}, 950],
PlotRange -> All,
AxesLabel -> {Style["Ticks", Medium, Bold],
Style["Position (X,Y,Z)", Medium, Bold]}]

由于曲线有足够的噪声来破坏计算,我们将其与高斯核进行卷积以对其进行去噪:
kern = Table[Exp[-n^2/100]/Sqrt[2. Pi], {n, -10, 10}];
t = Take[p1[[All, 1]]];
x = Take[p1[[All, 2 ;; 4]]];
x1 = ListConvolve[kern, #] & /@
Drop[Transpose@(x - Array[Mean@(x[[1 ;; 1000]]) &, Length@x]), {},
950];

所以你可以在下面看到原始和平滑的轨迹:


现在我们准备好对速度和加速度进行导数了。我们将对一阶和二阶导数使用四阶近似值。我们还将像以前一样使用高斯核对它们进行平滑:
Vel = ListConvolve[kern, #] & /@
Transpose@
Table[Table[(-x1[[axis, i + 2]] + x1[[axis, i - 2]] -
8 x1[[axis, i - 1]] +
8 x1[[axis, i + 1]])/(12 (t[[i + 1]] - t[[i]])), {axis, 1, 3}],
{i, 3, Length[x1[[1]]] - 2}];
Acc = ListConvolve[kern, #] & /@
Transpose@
Table[Table[(-x1[[axis, i + 2]] - x1[[axis, i - 2]] +
16 x1[[axis, i - 1]] + 16 x1[[axis, i + 1]] -
30 x1[[axis, i]])/(12 (t[[i + 1]] - t[[i]])^2), {axis, 1, 3}],
{i, 3, Length[x1[[1]]] - 2}];
我们绘制它们:
Show[ListLinePlot[Vel,PlotRange->All,
AxesLabel->{Style["Ticks",Medium,Bold],
Style["Velocity (X,Y,Z)",Medium,Bold]}],
ListPlot[Vel,PlotRange->All]]
Show[ListLinePlot[Acc,PlotRange->All,
AxesLabel->{Style["Ticks",Medium,Bold],
Style["Acceleation (X,Y,Z)",Medium,Bold]}],
ListPlot[Acc,PlotRange->All]]

现在,我们还有速度和加速度模数:
ListLinePlot[Norm /@ (Transpose@Vel),
AxesLabel -> {Style["Ticks", Medium, Bold],
Style["Speed Module", Medium, Bold]},
Filling -> Axis]
ListLinePlot[Norm /@ (Transpose@Acc),
AxesLabel -> {Style["Ticks", Medium, Bold],
Style["Acceleration Module", Medium, Bold]},
Filling -> Axis]

和航向,作为速度的方向:
Show[Graphics3D[
{Line@(Normalize/@(Transpose@Vel)),
Opacity[.7],Sphere[{0,0,0},.7]},
Epilog->Inset[Framed[Style["Heading",20],
Background->LightYellow],{Right,Bottom},{Right,Bottom}]]]

我认为这足以让你开始。如果您在计算特定参数时需要帮助,请告诉我。
!
编辑
举个例子,假设你想计算手不休息时的平均速度。因此,我们选择所有速度大于截止值的点,例如 5,并计算平均值:
Mean@Select[Norm /@ (Transpose@Vel), # > 5 &]
-> 148.085
该量级的单位取决于您的时间单位,但我没有看到它们在任何地方指定。
请注意,截止速度不是“直观的”。您可以通过绘制平均速度与截止速度来搜索适当的值:
ListLinePlot[
Table[Mean@Select[Norm /@ (Transpose@Vel), # > h &], {h, 1, 30}],
AxesLabel -> {Style["Cutoff Speed", Medium, Bold],
Style["Mean Speed", Medium, Bold]}]

所以你看到 5 是一个合适的值。