这一定是一个明显而愚蠢的问题......我正在研究用BerryIMU连接的Raspberry Pi 3(9种自由方式)。我从Accelerometer获得RAW值,但这些值的含义是什么?
(x, y)
(-57, 573)
(-56, 567)
(-64, 571)
(-59, 580)
(-56, 569)
(-30, 579)
(-59, 569)
(-61, 567)
(-34, 575)
(-59, 587)
(-43, 573)
(-74, 579)
(-56, 568)
(-58, 569)
如果我很清楚,那就是x和y的加速度。但我不确定的是单位是什么? m /s²? (无法找到ozzmaker文档......)而且,这些值是在静止时拍摄的,我不确定这些值。我知道有噪声(我应该使用卡尔曼滤波器),为什么每次迭代的值都不相同。 如果这些值是以m /s²为单位的加速度,我正在尝试计算速度。以下是我目前的代码:
import smbus
import time
import math
from LSM9DS0 import *
import datetime
bus = smbus.SMBus(1)
def writeACC(register,value):
bus.write_byte_data(ACC_ADDRESS, register, value)
return -1
def readACCx():
acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_X_L_A)
acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_X_H_A)
acc_combined = (acc_l | acc_h <<8)
return acc_combined if acc_combined < 32768 else acc_combined - 65536
def readACCy():
acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_Y_L_A)
acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_Y_H_A)
acc_combined = (acc_l | acc_h <<8)
return acc_combined if acc_combined < 32768 else acc_combined - 65536
def readACCz():
acc_l = bus.read_byte_data(ACC_ADDRESS, OUT_Z_L_A)
acc_h = bus.read_byte_data(ACC_ADDRESS, OUT_Z_H_A)
acc_combined = (acc_l | acc_h <<8)
return acc_combined if acc_combined < 32768 else acc_combined - 65536
def millis():
current_milli_time = int(round(time.time() * 1000))
return current_milli_time
#initialise the accelerometer
writeACC(CTRL_REG1_XM, 0b01100111) #z,y,x axis enabled, continuos update, 100Hz data rate
writeACC(CTRL_REG2_XM, 0b00100000) #+/- 16G full scale
velocity = 0.0
prevAcc = 0
prevTime = millis()
while True:
#Read the accelerometer,gyroscope and magnetometer values
ACCx = readACCx()
ACCy = readACCy()
ACCz = readACCz()
currTime = millis()
velocity += (ACCx + prevAcc) / 2 * (currTime - prevTime) / 1000
prevAcc = ACCx
prevTime = currTime
print("Vx:", velocity)
time.sleep(0.25)
问题是,传感器静止时速度会增加。
感谢您的帮助。