轨迹平滑md
更新时间:2026-07-29
简介
对手部/末端执行器的运动(动作/位姿)序列做平滑与离群点去除,AIHC 自研,纯 numpy、离线 CPU、无模型依赖,是 7-DoF 动作链路(HandActionCompute → TrajectorySmooth → AtomicActionSegment)中的中间处理环节。
功能描述
• 平滑:支持 savgol(Savitzky-Golay)、moving_average、gaussian 三种方法
• 去离群:velocity / zscore / none,异常帧用相邻好帧线性插值替换
• 形状保持:输出序列与输入形状一致 [N, D]
• 依赖友好:savgol 需 scipy,缺失时自动回退 moving_average
算子参数
输入
| 输入 | 含义 |
|---|---|
| sequence | 运动/位姿序列,每行形状 [N, D],元素类型 list<list |
输出
| 输出 | 含义 |
|---|---|
| result | 平滑并去离群后的序列,形状与输入一致(list<list |
参数
| 参数名称 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| method | str | savgol | 平滑方法,可选 savgol/moving_average/gaussian |
| window | int | 5 | 平滑窗口长度(建议奇数;savgol 要求奇数且 > polyorder) |
| polyorder | int | 2 | savgol 多项式阶数(仅 method=savgol 时使用) |
| outlier_method | str | velocity | 离群检测,可选 velocity/zscore/none |
| outlier_threshold | float | 3.0 | 离群阈值(标准差倍数) |
调用示例
Python
1from __future__ import annotations
2import os
3import daft
4from daft import col
5from daft.aihc.common.udf import aihc_udf
6from daft.aihc.functions.embodied.trajectory_smooth import TrajectorySmooth
7
8if __name__ == "__main__":
9 if os.getenv("DAFT_RUNNER", "native") == "ray":
10 import ray
11 ray.init(dashboard_host="0.0.0.0", ignore_reinit_error=True)
12 daft.set_runner_ray()
13 daft.set_execution_config(min_cpu_per_task=0)
14
15 samples = {"sequence": [[[0.0,0.0,0.0],[0.1,0.0,0.0],[0.2,0.0,0.0],[0.3,0.0,0.0],[0.4,0.0,0.0]]]}
16 ds = daft.from_pydict(samples)
17 ds = ds.with_column(
18 "smoothed",
19 aihc_udf(
20 TrajectorySmooth,
21 construct_args={"method":"savgol","window":5,"polyorder":2,"outlier_method":"velocity","outlier_threshold":3.0},
22 num_cpus=1, concurrency=1, batch_size=8,
23 )(col("sequence")),
24 )
25 ds.show()
评价此篇文章
