2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 6 See LICENSE for the license information 8 A script validating the Preintegration of IMU measurements 14 import matplotlib.pyplot
as plt
17 from mpl_toolkits.mplot3d
import Axes3D
27 """Create default parameters with Z *up* and realistic noise parameters""" 29 kGyroSigma = math.radians(0.5) / 60
30 kAccelSigma = 0.1 / 60
31 params.setGyroscopeCovariance(
32 kGyroSigma ** 2 * np.identity(3, float))
33 params.setAccelerometerCovariance(
34 kAccelSigma ** 2 * np.identity(3, float))
35 params.setIntegrationCovariance(
36 0.0000001 ** 2 * np.identity(3, float))
39 def __init__(self, twist=None, bias=None, dt=1e-2):
40 """Initialize with given twist, a pair(angularVelocityVector, velocityVector).""" 51 W = np.array([0, -math.radians(30), 0])
52 V = np.array([2, 0, 0])
68 accBias = np.array([0, 0.1, 0])
69 gyroBias = np.array([0, 0, 0])
75 fig, self.
axes = plt.subplots(4, 3)
76 fig.set_tight_layout(
True)
78 def plotImu(self, t, measuredOmega, measuredAcc):
82 omega_b = self.scenario.omega_b(t)
83 for i, (label, color)
in enumerate(zip(self.
labels, self.
colors)):
85 ax.scatter(t, omega_b[i], color=
'k', marker=
'.')
86 ax.scatter(t, measuredOmega[i], color=color, marker=
'.')
87 ax.set_xlabel(
'angular velocity ' + label)
90 acceleration_n = self.scenario.acceleration_n(t)
91 for i, (label, color)
in enumerate(zip(self.
labels, self.
colors)):
93 ax.scatter(t, acceleration_n[i], color=color, marker=
'.')
94 ax.set_xlabel(
'acceleration in nav ' + label)
97 acceleration_b = self.scenario.acceleration_b(t)
98 for i, (label, color)
in enumerate(zip(self.
labels, self.
colors)):
100 ax.scatter(t, acceleration_b[i], color=color, marker=
'.')
101 ax.set_xlabel(
'acceleration in body ' + label)
104 actual = self.runner.actualSpecificForce(t)
105 for i, (label, color)
in enumerate(zip(self.
labels, self.
colors)):
107 ax.scatter(t, actual[i], color=
'k', marker=
'.')
108 ax.scatter(t, measuredAcc[i], color=color, marker=
'.')
109 ax.set_xlabel(
'specific force ' + label)
113 actualPose = self.scenario.pose(t)
115 t = actualPose.translation()
122 plt.pause(time_interval)
126 for i, t
in enumerate(np.arange(0, T, self.
dt)):
127 measuredOmega = self.runner.measuredAngularVelocity(t)
128 measuredAcc = self.runner.measuredSpecificForce(t)
130 self.
plotImu(t, measuredOmega, measuredAcc)
132 pim = self.runner.integrate(t, self.
actualBias,
True)
133 predictedNavState = self.runner.predict(pim, self.
actualBias)
134 plot_pose3(POSES_FIG, predictedNavState.pose(), 0.1)
140 if __name__ ==
'__main__':
def plotImu(self, t, measuredOmega, measuredAcc)
def __init__(self, twist=None, bias=None, dt=1e-2)
static boost::shared_ptr< PreintegrationParams > MakeSharedU(double g=9.81)
def plot_pose3(fignum, pose, axis_length=0.1, P=None, axis_labels=('X axis', 'Y axis', 'Z axis'))
def plotGroundTruthPose(self, t, scale=0.3, time_interval=0.01)