2016-01-27 05:19:25 +08:00
|
|
|
"""
|
2016-01-28 04:03:26 +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
|
2016-01-27 07:43:46 +08:00
|
|
|
from gtsam_utils import plotPose3
|
2016-01-28 04:03:26 +08:00
|
|
|
from PreintegrationExample import PreintegrationExample
|
2016-01-27 06:41:55 +08:00
|
|
|
|
2016-01-28 04:03:26 +08:00
|
|
|
class ImuFactorExample(PreintegrationExample):
|
2016-01-27 05:19:25 +08:00
|
|
|
|
|
|
|
|
def run(self):
|
2016-01-27 07:43:46 +08:00
|
|
|
# simulate the loop up to the top
|
2016-01-27 13:37:22 +08:00
|
|
|
T = self.timeForOneLoop
|
2016-01-28 04:03:26 +08:00
|
|
|
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:
|
2016-01-28 04:03:26 +08:00
|
|
|
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()
|