gtsam/python/gtsam_examples/ImuFactorExample.py

33 lines
898 B
Python
Raw Normal View History

2016-01-27 05:19:25 +08:00
"""
A script validating the ImuFactor inference.
2016-01-27 05:19:25 +08:00
"""
2016-01-27 06:41:55 +08:00
import math
2016-01-27 05:19:25 +08:00
import matplotlib.pyplot as plt
import numpy as np
2016-01-27 06:41:55 +08:00
from mpl_toolkits.mplot3d import Axes3D
import gtsam
from gtsam_utils import plotPose3
from PreintegrationExample import PreintegrationExample
2016-01-27 06:41:55 +08:00
class ImuFactorExample(PreintegrationExample):
2016-01-27 05:19:25 +08:00
def run(self):
# simulate the loop up to the top
2016-01-27 13:37:22 +08:00
T = self.timeForOneLoop
pim = gtsam.PreintegratedImuMeasurements(self.params, self.actualBias)
2016-01-27 13:37:22 +08:00
for i, t in enumerate(np.arange(0, T, self.dt)):
2016-01-27 09:37:38 +08:00
measuredOmega = self.runner.measuredAngularVelocity(t)
measuredAcc = self.runner.measuredSpecificForce(t)
2016-01-27 13:37:22 +08:00
if i % 25 == 0:
self.plotImu(t, measuredOmega, measuredAcc)
self.plotGroundTruthPose(t)
2016-01-27 06:41:55 +08:00
plt.ioff()
plt.show()
2016-01-27 05:19:25 +08:00
if __name__ == '__main__':
ImuFactorExample().run()