Python Simulation Randomness - - FIXED


I've been running sims online, but have found it faster and easier to script by running locally. I've been working wirh currently.

I've noticed when I run the script 1x locally - the generated kml paths are the same. When I try multiple runs like this:

I get results, but they are all duplicate, and very different than the online sim (generally much better position), when I use duplicate input motion params.

I'm using this file, but changed the data to: motion_def-long_drive.csv and line 74 changed to run 10x.

When I run this online (5x), I get these results (RED) vs ref (GREEN) path:

When I run local (10x), I get these results:
Difficult to see, but reference path is same, results are MUCH better, and all 10 runs are identical.

Here are my sensor settings:


I once I had all this typed up, I found the error.

looks like I had copy and pasted a bit from that had some sneaky changes:

    #### IMU model, typical for IMU381
    imu_err = {'gyro_b': np.array([0.0, 0.0, 0.0]),
               'gyro_arw': np.array([0.25, 0.25, 0.25]) * 0.0,
               'gyro_b_stability': np.array([3.5, 3.5, 3.5]) * 0.0,
               'gyro_b_corr': np.array([100.0, 100.0, 100.0]),
               'accel_b': np.array([0.0e-3, 0.0e-3, 0.0e-3]),
               'accel_vrw': np.array([0.03119, 0.03009, 0.04779]) * 0.0,
               'accel_b_stability': np.array([4.29e-5, 5.72e-5, 8.02e-5]) * 0.0,
               'accel_b_corr': np.array([200.0, 200.0, 200.0]),
               'mag_std': np.array([0.2, 0.2, 0.2]) * 0.0

Watch those * 0.0's !! looks like someone added a tolerance fudger to the base errors and nulled them for that demo - this seems to have the effect of using a perfect gyro with some accel errors only.

With that fixed everything run as expected...

I'll leave this here for anyone that had the same issue.

Hi Adam,

Thank you for sharing.

Free integration with sensor error will diverge quickly. Those *0.0s is a switch to see what will happen when you turn on/off each error source.
Indeed, numerical accuracy alone will cause differences from the reference trajectory after a long time. You can see that from the results you got from a local run.

Log in to reply