校准 MPU6050

huangapple go评论70阅读模式
英文:

Calibrating MPU6050

问题

我正在使用 MPU 6050 和树莓派 Pico 制作一个IMU。
我已将加速度计的量程设置为+-2 g,但存在0.96 g的偏移,这严重限制了正侧的感测范围。
我编写了一个校准程序,它可以正常工作,其中我们显式地将偏移添加到数据中。

def calibrate(i2c):
    temp=0
    accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z=0,0,0,0,0,0

    for i in range(10000):
        temp += read_raw_data(i2c, TEMP_OUT_H) / 340.0 + 36.53
        accel_x += read_raw_data(i2c, ACCEL_XOUT_H) / 16384.0
        accel_y += read_raw_data(i2c, ACCEL_XOUT_H + 2) / 16384.0
        accel_z += read_raw_data(i2c, ACCEL_XOUT_H + 4) / 16384.0
        gyro_x += read_raw_data(i2c, GYRO_XOUT_H) / 131.0
        gyro_y += read_raw_data(i2c, GYRO_XOUT_H + 2) / 131.0
        gyro_z += read_raw_data(i2c, GYRO_XOUT_H + 4) / 131.0
    
    print('校准完成')
    
    t=temp/10000
    a_x=accel_x/10000
    a_y=accel_y/10000
    a_z=accel_z/10000
    g_x=gyro_x/10000
    g_y=gyro_y/10000
    g_z=gyro_z/10000

是否有方法可以校准传感器并仍然获得完整的范围?

英文:

I using a MPU 6050 and raspberry pi pico for making an IMU.
I have set the range of accelerometer as +- 2 g but there is a .96 g offset this severly limits the sensing range on the positive side.
I have written a calibration program which works fine in which we explicitly add the offsets to the data
`

def calibrate(i2c):
    temp=0
    accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z=0,0,0,0,0,0

    for i in range(10000):
        temp += read_raw_data(i2c, TEMP_OUT_H) / 340.0 + 36.53
        accel_x += read_raw_data(i2c, ACCEL_XOUT_H) / 16384.0
        accel_y += read_raw_data(i2c, ACCEL_XOUT_H + 2) / 16384.0
        accel_z += read_raw_data(i2c, ACCEL_XOUT_H + 4) / 16384.0
        gyro_x += read_raw_data(i2c, GYRO_XOUT_H) / 131.0
        gyro_y += read_raw_data(i2c, GYRO_XOUT_H + 2) / 131.0
        gyro_z += read_raw_data(i2c, GYRO_XOUT_H + 4) / 131.0
    
    print('calibration done')
    
    t=temp/10000
    a_x=accel_x/10000
    a_y=accel_y/10000
    a_z=accel_z/10000
    g_x=gyro_x/10000
    g_y=gyro_y/10000
    g_z=gyro_z/10000

is there any way in which i can calibrate the sensor and still get full range?

答案1

得分: 2

0.96 g是重力加速度,必须来自垂直轴(通常是z轴)。这不是传感器偏差。包括在加速度计加速度测量中的是重力加速度。所以答案是否定的。重力会占据部分测量范围。

要了解典型加速度计读数的感觉,请查看来自https://imuengine.io/resources/的样本数据集。以下是汽车数据集的前几个IMU条目,其中z轴通常指向下。将单位从m/s²转换为g,您将看到大致相同的1 g来自重力。

TimeFromStart (s)  AccelX (m/s^2)         AccelY (m/s^2)       AccelZ (m/s^2)      AngleRateX (rad/s)     AngleRateY (rad/s)      AngleRateZ (rad/s)
49.27              0.0065134831           0.1535978052         -9.8256081343       0.0033288721           0.0021099924            -0.000368629
49.28              -0.1163793611          0.1524602878         -9.7294434905       -0.0014737246          -0.001269474            -5.3143600000000004e-05
49.29              -0.1772884163          0.1816529664         -9.833201021        -0.0009057809          -0.0002318527           -0.0004045664

也可以测量“减去重力的加速度”,但需要传感器融合的一层。如果传感器倾斜,原始帖子中显示的方法将失效。如果这是您需要的内容,请随时发布详细要求的新问题。

英文:

The 0.96 g is gravitational acceleration and must be from the vertical axis (typically z-axis). This is not a sensor bias. Included in the accelerometer acceleration measurement is gravitational acceleration. And so the answer is no. Gravity will take up part of the measurement range.

To get a feel for typical accelerometer readings check out a sample dataset from https://imuengine.io/resources/. Copied here are the first few IMU entries from the automotive dataset where the z-axis nominally points down. Convert the units from m/s^2 to g's and you see the same approximate 1 g from gravity.

TimeFromStart (s)  AccelX (m/s^2)         AccelY (m/s^2)       AccelZ (m/s^2)      AngleRateX (rad/s)     AngleRateY (rad/s)      AngleRateZ (rad/s)
49.27              0.0065134831           0.1535978052         -9.8256081343       0.0033288721           0.0021099924            -0.000368629
49.28              -0.1163793611          0.1524602878         -9.7294434905       -0.0014737246          -0.001269474            -5.3143600000000004e-05
49.29              -0.1772884163          0.1816529664         -9.833201021        -0.0009057809          -0.0002318527           -0.0004045664

Measuring "acceleration minus gravity" is also possible but requires a layer of sensor fusion. The method shown in the original post falls apart if the sensor is tilted. Feel free to post a new question detailing the requirements if that is what you need then.

huangapple
  • 本文由 发表于 2023年6月15日 20:38:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76482568.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定