# -*- coding: utf-8 -*-
# @Author : 十年
# @Site : https://gitee.com/chshao/aiplotest
# @CSDN : https://blog.csdn.net/m0_37576542?type=blog
# @File : Allan.py
# @Description : Allan方差计算
import math
import numpy as np
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt
class Allan(object):
@staticmethod
def fitAllanPic(tau, av, title, xlabel, ylabel, picName=''):
# 绘制Allan方差曲线图
plt.clf()
plt.loglog(tau, av, marker="o")
plt.grid(True, which="both", ls="-")
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.legend(['x', 'y', 'z'])
plt.savefig(picName)
# plt.show()
def allan(self, data: DataFrame, fs):
"""
@summary: 计算allan方差、随机游走噪声
@param data: imu原始数据
@param fs: imu输出频率
@return:
"""
# 开始计算allan方差----------------------------------------------------------------------------------------------
data = np.asarray(data, dtype=float)
data[:, 0:3] = data[:, 0:3] * 180 / math.pi
data_int = np.cumsum(data, axis=0) / fs # 1/freq=dt, p.78 (4.6)
N = len(data_int)
taunum = math.floor(np.log((N - 1) / 3) / np.log(2)) # how many kind of tau
allan_a = np.empty((taunum + 1, 6))
for k in range(0, 6):
for i in range(taunum + 1):
n = 2 ** i # data number in one box is qrow with 2 square to reduce the counter
# use matrix [] added and col.27 mean to replace sumation in p.78 (4.9)
temp2 &#
Allan方差计算(python实现源码)
最新推荐文章于 2023-02-21 22:32:55 发布