跳转到内容

采集设备的 IMU 标定

大多数采集设备在相机旁边带有一个 IMU(惯性测量单元)。它是一颗小芯片,很容易被当作附加品。它不是。在头戴采集设备上,相机看不清的时候是 IMU 让跟踪继续下去,也是 IMU 让素材有了上、下和真实世界尺度的概念。

但 IMU 是一种有噪声、不完美的仪器。和相机一样,它必须标定:标定它本身、标定它与相机的关系、标定时间。本文三项都讲。它建立在相机标定指南的基础上。

IMU 由一个测量旋转速率的三轴陀螺仪和一个测量加速度(包括重力)的三轴加速度计组成。它输出数据的频率可以远高于相机拍帧的频率:例如,6C capture cap 以约 500 Hz 读取它的 IMU,而帧率是每秒 30 帧。

The IMU fills the gaps between camera frames A 200 millisecond timeline. The camera takes a frame every 33 milliseconds, at 30 frames per second. The IMU reports every 5 milliseconds, at 200 Hz, so several inertial measurements fall between each pair of frames and carry the motion across the gap. Camera30 fps IMU200 Hz between frames, only the IMU knows how the head moved 200 ms shown
Camera frames are tens of milliseconds apart. The IMU reports many times in between, so it carries the motion across each gap, and through blur.

这个频率就是关键。在帧与帧之间,只有 IMU 知道头部是怎样运动的。它让跟踪撑过快速转头、运动模糊和相机只看到一面白墙的时刻。它还测量重力,所以处理流程始终知道哪个方向是下。

它还解决了单台相机解决不了的一个问题:尺度。一台相机分不清近处的小物体和远处的大物体。与 IMU 结合,它就能分清。开源视觉惯性估计器 VINS-Mono 的作者说得很直白:一台相机加一个低成本 IMU 构成 “the minimum sensor suite for metric six degrees-of-freedom (DOF) state estimation”(意为:进行度量的六自由度(DOF)状态估计所需的最小传感器组合)。这就是为什么即使是单目头戴相机,旁边有一个标定良好的 IMU 也会有用得多。

手机和采集设备里用的那种低成本 MEMS(微机电系统)IMU 有两类误差。Tedaldi、Pretto 和 Menegatti(2014)指出 “low cost IMUs are affected by systematic error given by imprecise scaling factors and axes misalignments”(意为:低成本 IMU 受到由不精确的比例因子和轴不对准造成的系统误差的影响)。

系统误差是可重复的,所以标定可以测量并去除它们。系统误差有零偏、比例因子和轴不对准。

  • 零偏(bias):什么都没发生时,传感器也有读数。带有小零偏的陀螺仪,随时间积分后,会报告一个从未发生过的缓慢旋转。
  • 比例因子(scale factor):传感器在整个量程内读数偏高或偏低。
  • 轴不对准(axis misalignment):三个轴彼此之间或与外壳之间并不完全垂直,所以沿一个轴的运动会泄漏到其他轴上。
The three systematic IMU errors calibration removes Three panels. Bias: the measured output is offset from the true value, so the sensor reads something even at rest. Scale factor: the measured output grows at the wrong rate. Axis misalignment: the sensor's three axes are not quite square to each other or to the housing. offsetBiasreads non-zero at rest wrong slopeScale factorreads too high or low sensor axesvs true axesAxis misalignmentaxes not quite square truetruemeasured
The systematic errors calibration removes: a bias that reads something at rest, a scale factor that reads too high or low, and axes that are not quite square.

Meta 为它的 Aria 眼镜写的文档展示了真实的逐台 IMU 标定包含什么:对加速度计,是一个零偏偏移和一个 “3x3 rectification matrix for scale/cross-axis corrections”(意为:用于比例/交叉轴修正的 3x3 校正矩阵);对陀螺仪,是一个零偏、一个校正矩阵和一个 “G-sensitivity matrix”(意为:g 敏感度矩阵),因为陀螺仪对加速度也有轻微响应(Aria Gen 2 标定)。

随机误差无法去除,只能测量,好让软件知道该在多大程度上信任传感器。Kalibr 的 IMU 噪声模型对每个传感器使用两个数:白噪声,“an additive noise term that fluctuates very rapidly”(意为:一个波动非常快的加性噪声项);以及零偏随机游走,一个 “slowly varying sensor bias”(意为:缓慢变化的传感器零偏)。

在这两者之上,零偏还随温度变化:Kalibr 指出,它的噪声模型是在 “at constant temperature”(意为:恒定温度下)的静止传感器上测得的,没有包括 “bias variation caused by temperature changes”(意为:由温度变化引起的零偏变化)。一台在人头上戴了一小时而变热的采集设备,零偏已经不是它在工作台上时的零偏。

据我们所知,生产线可以在速率转台和温箱中标定 IMU:速率转台以已知速度旋转 IMU,温箱测出零偏随温度的变化。但有一个更便宜、每个实验室都已经有的参考:重力。

重力是一个免费的参考,在任何一个地点它的大小都是稳定的。加速度计保持静止时,无论朝向如何,都应该读出竖直向下的一个 g。让它在许多不同的姿态下保持静止,就可以解出会使这些读数互不一致的零偏、比例和不对准。

Multi-position IMU calibration: gravity is the reference The IMU is held still in many different attitudes: flat, upside down, on its sides and at angles. In every static pose the accelerometer must read exactly one g, straight down, which pins its bias, scale and misalignment. The rotations between poses then check the gyroscope. g at rest, every pose must read exactly one g, straight down held still in many attitudes, by hand or on a fixture
Gravity is a free, perfectly known reference. Held still in many attitudes, the accelerometer must read one g every time; the rotations between poses check the gyroscope.

Tedaldi、Pretto 和 Menegatti(2014)把这变成了一种完全不需要设备的方法。他们的流程 “only requires the sensor to be moved by hand and placed in a set of different, static positions”(意为:只需要用手移动传感器并把它放在一组不同的静止位置上)。软件自动检测静止区间,用它们标定加速度计,然后对各位姿之间的旋转做积分并与加速度计的结果对照,以此标定陀螺仪。它给出 “scale and misalignments factors for both the accelerometers and gyroscopes triads, while estimating the sensor biases”(意为:加速度计三轴组和陀螺仪三轴组的比例与不对准因子,同时估计传感器零偏)。

噪声数字的获得方法是:让 IMU 长时间完全静止,然后计算它的 Allan 偏差(Allan deviation),即平均读数的游移有多大,作为平均时长的函数。El-Sheimy、Hou 和 Niu(2008)描述了这种方法在惯性传感器上的应用,Kalibr 称它 “probably the most common and standardized procedure”(意为:可能是最常见、最标准化的流程)。

Reading IMU noise from an Allan deviation plot A log-log plot of Allan deviation against averaging time for a stationary IMU. The curve falls with slope minus one half where white noise dominates, flattens at a minimum called the bias instability, then rises with slope plus one half where bias random walk dominates. The white-noise density is read from the falling line at an averaging time of 1 second, and the random walk from the rising line at 3 seconds. white noise: read at τ = 1 s bias instability (the minimum) random walk: at τ = 3 s slope −½ slope +½ 0.010.1110100100010000 Averaging time τ (seconds, log scale) Allan deviation (log)
An Allan deviation plot from hours of the IMU sitting still. White noise is read on the falling line at 1 second, bias random walk on the rising line at 3 seconds, and the minimum is the bias instability.

在双对数图上,白噪声表现为斜率 −½ 的下降直线,零偏随机游走表现为斜率 +½ 的上升直线,两者之间的最低点是零偏不稳定性。Kalibr 的指南在平均时间 1 秒处读取白噪声,在 3 秒处从上升直线读取随机游走。

录制时间很长。Kalibr 的文档建议做一次 “~15-24 hour dataset recording of the IMU being stationary”(意为:约 15–24 小时的 IMU 静止数据集录制);allan_variance_ros 工具说 “You must record at least 3 hours of data.”(意为:你必须录制至少 3 小时的数据。)allan_variance_ros 这类工具计算出这张图,并把噪声参数直接写成 Kalibr 的格式。

接着 Kalibr 加了一条值得认真对待的警告。工作台上静止的 IMU 是最理想的情况:Kalibr 的模型来自一个 “does not undergo motion, and at constant temperature”(意为:不发生运动、且处于恒定温度下)的传感器。对最低成本的传感器,“increasing the noise model parameters by a factor of 10x or more may be necessary”(意为:可能需要把噪声模型参数增大到 10 倍或更多)。否则估计器会 “trust your IMU measurements too much”(意为:过于信任你的 IMU 测量值)。

只有软件准确知道两者是怎样安装的、它们的时钟准确是什么关系,IMU 才能帮到相机。这是两项标定。

空间上:从相机到 IMU 的旋转和平移,即外参。时间上:IMU 的时间戳与相机的时间戳之间的时间偏移。Qin 和 Shen(2018)解释了为什么第二项总是存在:“timestamps of each sensor typically suffer from triggering and transmission delays, leading to temporal misalignment (time offsets) among different sensors.”(意为:每个传感器的时间戳通常受到触发延迟和传输延迟的影响,导致不同传感器之间在时间上不对齐(时间偏移)。)

标准工具是 Kalibr,它依据 Furgale、Rehder 和 Siegwart(2013)把两项一起求解。它的时间标定默认开启。后来的一项扩展,Rehder 等(2016),可以同时标定多个 IMU,甚至标定其中的各个单轴。

做法很短。标定板固定不动,采集设备在它前面运动。Kalibr 的相机–IMU 指南要求你 “excite all IMU axes (rotation and translation)”(意为:激励 IMU 的所有轴(旋转和平移)),“keep the motion blur low”(意为:保持低运动模糊),在开始和结束时 “avoid shocks”(意为:避免冲击),并且 “ensure low jitter timestamps in same clock”(意为:确保时间戳抖动低且在同一个时钟下)。如果采集设备始终只是左右摇摆,求解器在其他轴上就没有可用的信息。

刚体运动解释了这条规则。相机和 IMU 在同一个刚体上,所以它们一起转动:相机看到的旋转和陀螺仪测到的旋转是同一个运动在两组坐标轴下的表示,把两者相比较就确定了相机与 IMU 之间的旋转。它们之间的平移,即杆臂 p,只出现在加速度计里,通过 ω × (ω × p) + α × p 这些项体现,其中 ω 是角速度,α 是角加速度。采集设备不旋转时,这些项为零。绕一个固定轴旋转时,ω 和 α 都沿着这个轴,所以 p 沿这个轴的任何分量都从两项中消失,无法恢复。在多个 IMU 与头部到腕部的外参一页上,把多个 IMU 联系在一起的也是这些项;在那里,Lee、Hanley 和 Bretl 引用更早的相机–IMU 工作指出 “motions such as constant acceleration or rotation along a single axis at a constant rate result in a failure mode”(意为:恒定加速度或绕单一轴匀速旋转之类的运动会导致失效模式)(Lee、Hanley 和 Bretl,2022)。

和相机一样,这些值会漂移,补救办法也一样:从每次录制重新估计它们。Li 和 Mourikis(2014)证明了相机–IMU 时间偏移可以在线估计,把它作为又一个未知量 “along with all other variables of interest”(意为:与所有其他关心的变量一起),并证明了它是 “locally identifiable, except in a small number of degenerate motion cases”(意为:局部可辨识的,少数退化运动情形除外)。现在它已内置于开源估计器中:OpenVINS 在它标定的内容中列出了相机到 IMU 的变换、时间偏移和惯性内参,“including g-sensitivity”(意为:包括 g 敏感度),而 Meta 的 Aria 处理服务按录制时段重新优化 IMU 的内参和外参。

让 IMU 容易标定的大部分因素,在设计采集设备时就决定了。

  • 刚性安装,紧挨相机。相机到 IMU 的标定假定两者之间从不发生相对运动。同一个刚性结构,两者之间不用软性安装。据我们所知,在布局允许的范围内让它们尽量靠近也有帮助。例如,The Open Robot Company 的 6C cap 把一个 IMU 放在 “centred behind each stereo pair”(意为:每个双目对后方居中的位置)。
  • 一个时钟。在硬件中,用同一个时钟、以稳定的速率给 IMU 和相机打时间戳。Kalibr 的相机–IMU 指南要求你 “ensure low jitter timestamps in same clock”(意为:确保时间戳抖动低且在同一个时钟下),因为时间戳的抖动会表现为标定误差。
  • 适合头部的量程和采样率。头部转得很快:Miller 等(2020)发现,日常活动中头部的峰值旋转速度接近 12.8 rad/s,约 730 °/s。选择在快速转头时不会削顶的陀螺仪量程,以及远高于帧率的采样率。例如,6C 以约 500 Hz 运行它的 IMU,陀螺仪量程为 ±1000 °/s。
  • 让它在热学上保持安静。据我们所知,最好在可能的情况下让它远离处理器和电池充电器,并且采集设备应在录制前预热,让零偏稳定下来。
  • 标定每一台设备,把结果与序列号一起存储,并按录制时段细化,和相机完全一样。