姿态RMSE是什么?
- User
姿态RMSE是什么?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
姿态RMSE是什么?
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
在机器人、SLAM、AR/VR、自动驾驶等涉及 位姿(pose)估计 的领域里,我们常常要衡量算法输出的位姿与“真实值”之间的误差。
最常见、最直观的指标之一就是 RMSE:Root Mean Square Error(均方根误差)。
把它用在位姿上时,大家通常会说 Pose RMSE(姿态 RMSE)。
一个完整的位姿通常包含
• 位置(translation) → 三维向量 t = [x, y, z]^T
• 姿态/朝向(rotation) → 四元数 q、旋转矩阵 R、或者欧拉角 (roll, pitch, yaw) 表示
因此,衡量误差时需要同时考虑 平移误差 和 旋转误差,有时候也会把两者拆开说:
– Translation RMSE(位置 RMSE)
– Rotation RMSE(姿态/角度 RMSE)
假设我们有 N 帧(或 N 个关键帧):
‖eᵢᵗ‖₂² = ‖tᵢ − ˆtᵢ‖₂²
RMSEₜ = √( (1/N) Σ_{i=1}^{N} ‖eᵢᵗ‖₂² )
某些论文还会把两部分加权组合成一个 整体位姿 RMSE:
RMSE_pose = √( RMSEₜ² + w·RMSEᵣ² )
其中 w 用来把“角度误差”转换成与“米”同量纲的数(例如 w = (baseline length)²)。
• 对大误差更敏感:平方后放大离群点
• 可微 → 方便优化
• 与统计学中的均方差一致,易于与其他指标对比
import numpy as np
import transforms3d # pip install transforms3d
def pose_rmse(gt_Rs, gt_ts, est_Rs, est_ts):
"""gt_Rs, est_Rs: (N, 3, 3) 旋转矩阵数组
gt_ts, est_ts: (N, 3) 平移向量数组"""
N = len(gt_Rs)
# 平移 RMSE
trans_err = gt_ts - est_ts
rmse_t = np.sqrt(np.mean(np.sum(trans_err**2, axis=1)))
# 旋转 RMSE(角度法)
angles = []
for Rg, Re in zip(gt_Rs, est_Rs):
dR = Rg @ Re.T
angle = np.arccos(np.clip((np.trace(dR) - 1) / 2.0, -1.0, 1.0))
angles.append(angle)
rmse_r = np.sqrt(np.mean(np.array(angles)**2))
return rmse_t, rmse_r
# 示例调用
N = 100
gt_Rs = np.repeat(np.eye(3)[None, :, :], N, axis=0)
est_Rs = gt_Rs.copy()
gt_ts = np.zeros((N,3))
est_ts = np.random.randn(N,3) * 0.01 # ~1cm误差
rmse_t, rmse_r = pose_rmse(gt_Rs, gt_ts, est_Rs, est_ts)
print("Translation RMSE (m):", rmse_t)
print("Rotation RMSE (rad):", rmse_r)
姿态 RMSE = “把每一帧或每一个采样点的位置 & 角度误差平方后平均再开根号”
它让我们用一个(或两个)数字就能量化整个轨迹的位姿精度,是评估 SLAM/定位/跟踪算法的常用基准指标。