Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Simulating Gyroscope with ARW, BI, and Spectral Density Using Physical BMI270 IMU Data

    Simulating Gyroscope with ARW, BI, and Spectral Density Using Physical BMI270 IMU Data

    jimit007
    New Poster
    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!

    1 REPLY 1

    BSTRobin
    Community Moderator
    Community Moderator

    Hi jimit007,

    We have not conducted any analysis of third-party code. You can consult the third-party author for more information on code implementation.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist