I'm currently working on a state estimation project that relies on IMU data. While I have access to a physical IMU, I'd like to simulate gyroscope data with specific parameters, including Angle Random Walk (ARW) and Bias Instability (BI). I already have a pseudocode that incorporates ARW and BI parameters, but I'm struggling to integrate Spectral Density into the simulation.
Could someone help me modify my existing code to include the Spectral Density parameter and complete the gyroscope simulation? Here's the code snippet I've been working with:
https://gist.github.com/michaelwro/126de51e3d2bcaeda3fb5609aa19f0e5[sudo code link]1
# Pseudocode for modeling a noisy gyro sensor
# Created By: MicWro Engr
# 'w' variables are supposed to be the Greek letter omega, used to denote the angular rate
# Remember: variance = (std_dev)^2
# Gyro model:
# w_meas = w_true + bias + noise
# I obtained these values from my own gyro sensor! Details can be found at: https://mwrona.com/posts/gyro-noise-analysis/
# This Mathworks post is really useful: https://www.mathworks.com/help/fusion/ug/inertial-sensor-noise-analysis-using-allan-variance.html
import numpy as np
dt = 0.01 # [sec] sample rate
# Gyro bias parameters
w_bias = -0.01 # This is the constant offset in rate measurements. Also acts as the integrator's initial condition
bias_coef = 1.31e-4 # Bias instability coefficient
bias_var = ((2 * bias_coef**2) / np.pi) * np.log(2) # bias instability variance
# Angle random walk (AWR) parameters
arw_coef = 4.54e-4 # ARW coefficient
arw_var = arw_coef**2 / dt # [rad/sqrt(sec)] ARW variance
# simulation loop
while True:
# obtain an actual rate from ground truth simulation
w_actual = GroundTruth(...)
# simulate bias instability noise
w_bias += dt * np.random.normal(0, np.sqrt(bias_var)) # (mean, std_dev)
# simulate angle random walk noise
w_arw = np.random.normal(0, np.sqrt(arw_var))
# simulated gyro measurement
w_meas = w_actual + w_bias + w_arw
Any guidance, code examples, or explanations would be greatly appreciated. Thank you for your assistance!