feat(pybot×actpred): R2 姿态反馈方案一——MPU6050 独立 IMU token 全链路
- pybot:recorder 逐帧落盘 imu.npy(T×8,roll,pitch,ax,ay,az,gx,gy,gz,与帧/动作同调用对齐);run_loop 对声明 imu_dim 的 predictor 以 predict(..., imu=) 调用(鸭子类型,旧两参调用向后兼容) - actpred:新增 --imu-dim;model 序列 [img×F, act×H, (IMU), PRED](imu_dim>0 时 F+H+2,IMU token 位于 PRED 前);dataset/train 读 imu.npy(缺失按零向量兜底);predict/ONNX/Hailo 三后端与 export/gen_calibration/dfc_compile/_npu_test 部署链适配 imu 输入 - 姿态按物理量程固定缩放归一化(imu_norm.py,训练/推理共用,零状态) - 测试:actpred 128 passed / pybot loop+recorder 28 passed
This commit is contained in:
1 parent
3e773debc9
commit
a2ba797410
22 files changed
+1236
-133
No files matched your search
+12
-5
@@ -36,10 +36,14 @@ import tempfile
|
||||
NET_NAME = "actpred_deploy"
|
||||
|
||||
|
||||
def start_nodes(frame_count: int) -> list:
|
||||
"""export_deploy.py 的输入命名约定:frame{i} × frame_count + action_history + pred_token"""
|
||||
return ([f"frame{i}" for i in range(frame_count)]
|
||||
+ ["action_history", "pred_token"])
|
||||
def start_nodes(frame_count: int, with_imu: bool = False) -> list:
|
||||
"""export_deploy.py 的输入命名约定:frame{i} × frame_count + action_history
|
||||
+ pred_token(R2 imu_dim>0 时末尾追加 imu)"""
|
||||
nodes = ([f"frame{i}" for i in range(frame_count)]
|
||||
+ ["action_history", "pred_token"])
|
||||
if with_imu:
|
||||
nodes.append("imu")
|
||||
return nodes
|
||||
|
||||
|
||||
def hailo(*args, venv_bin: str):
|
||||
@@ -118,6 +122,9 @@ def main():
|
||||
parser.add_argument("--frame-count", type=int, default=3,
|
||||
help="帧输入个数(与导出 ONNX 的 frame_len 一致,"
|
||||
"默认 3)")
|
||||
parser.add_argument("--with-imu", action="store_true",
|
||||
help="R2:导出 ONNX 含 imu 输入时开启(start nodes "
|
||||
"末尾追加 imu,与 export_deploy.py 命名一致)")
|
||||
parser.add_argument("--venv-bin", default="venv_dfc/bin",
|
||||
help="安装了 hailo-sdk 的 venv bin 目录")
|
||||
args = parser.parse_args()
|
||||
@@ -126,7 +133,7 @@ def main():
|
||||
if not os.path.exists(os.path.join(venv_bin, "hailo")):
|
||||
sys.exit(f"错误: {venv_bin}/hailo 不存在,请先安装 hailo-sdk")
|
||||
|
||||
nodes = start_nodes(args.frame_count)
|
||||
nodes = start_nodes(args.frame_count, args.with_imu)
|
||||
input_formats = ["NHWC"] * len(nodes)
|
||||
|
||||
workdir = tempfile.mkdtemp(prefix="dfc_")
|
||||
|
||||
Reference in new issue
Block a user