37 kalman::QLast, kalman::SplitQ) {
41 kalman::QLastWithSplitInnovation) {
43 using JacobianType =
typename MeasurementType::JacobianType;
44 unique_ptr<TestData> data(
new TestData);
45 GIVEN(
"an identity state") {
46 WHEN(
"filtering in an identity measurement") {
47 Quaterniond xformedMeas = data->
xform(Quaterniond::Identity());
49 THEN(
"the transformed measurement should equal the measurement") {
51 REQUIRE(xformedMeas.isApprox(Quaterniond::Identity()));
53 MeasurementType kalmanMeas{xformedMeas, data->imuVariance};
54 AND_THEN(
"residual should be zero") {
55 CAPTURE(kalmanMeas.getResidual(data->
state));
56 REQUIRE(kalmanMeas.getResidual(data->
state)
57 .isApproxToConstant(0.));
60 JacobianType jacobian = kalmanMeas.getJacobian(data->
state);
61 AND_THEN(
"the jacobian should be finite") {
62 INFO(
"jacobian\n" << jacobian);
63 REQUIRE(jacobian.allFinite());
64 AND_THEN(
"the jacobian should not be zero") {
65 REQUIRE_FALSE(jacobian.isApproxToConstant(0));
68 data->
state, data->processModel, kalmanMeas);
69 AND_THEN(
"computed deltaz should be zero") {
70 CAPTURE(correctionInProgress.deltaz.transpose());
72 correctionInProgress.deltaz.isApproxToConstant(0.));
74 CAPTURE(correctionInProgress.stateCorrection.transpose());
75 AND_THEN(
"state correction should be finite") {
76 REQUIRE(correctionInProgress.stateCorrectionFinite);
77 AND_THEN(
"state correction should be zero") {
78 REQUIRE(correctionInProgress.stateCorrection
79 .isApproxToConstant(0.));
85 WHEN(
"filtering in a small positive rotation about y") {
86 Quaterniond smallPositiveRotationAboutY(
87 AngleAxisd(SMALL_VALUE, Vector3d::UnitY()));
89 CAPTURE(smallPositiveRotationAboutY);
90 Quaterniond xformedMeas = data->
xform(smallPositiveRotationAboutY);
93 THEN(
"the transformed measurement should equal the measurement") {
94 REQUIRE(xformedMeas.isApprox(smallPositiveRotationAboutY));
96 MeasurementType kalmanMeas{xformedMeas, data->imuVariance};
97 smallPositiveYChecks(data.get(), kalmanMeas);
101 GIVEN(
"a state rotated about y") {
102 Quaterniond stateRotation(AngleAxisd(M_PI / 4., Vector3d::UnitY()));
104 WHEN(
"filtering in a small positive rotation about y") {
105 Quaterniond smallPositiveRotationAboutY =
107 Quaterniond(AngleAxisd(SMALL_VALUE, Vector3d::UnitY()));
108 CAPTURE(SMALL_VALUE);
109 CAPTURE(smallPositiveRotationAboutY);
110 Quaterniond xformedMeas = data->
xform(smallPositiveRotationAboutY);
111 CAPTURE(xformedMeas);
113 THEN(
"the transformed measurement should equal the measurement") {
114 REQUIRE(xformedMeas.isApprox(smallPositiveRotationAboutY));
117 MeasurementType kalmanMeas{xformedMeas, data->imuVariance};
118 smallPositiveYChecks(data.get(), kalmanMeas);
122 GIVEN(
"a state rotated about x") {
123 Quaterniond stateRotation(AngleAxisd(M_PI / 4., Vector3d::UnitX()));
125 WHEN(
"filtering in a small positive rotation about y") {
126 Quaterniond smallPositiveRotationAboutY =
128 Quaterniond(AngleAxisd(SMALL_VALUE, Vector3d::UnitY()));
129 CAPTURE(SMALL_VALUE);
130 CAPTURE(smallPositiveRotationAboutY);
131 Quaterniond xformedMeas = data->
xform(smallPositiveRotationAboutY);
132 CAPTURE(xformedMeas);
134 THEN(
"the transformed measurement should equal the measurement") {
135 REQUIRE(xformedMeas.isApprox(smallPositiveRotationAboutY));
138 MeasurementType kalmanMeas{xformedMeas, data->imuVariance};
139 smallPositiveYChecks(data.get(), kalmanMeas);
void setQuaternion(Eigen::Quaterniond const &quaternion)
Intended for startup use.
CorrectionInProgress< StateType, MeasurementType > beginCorrection(StateType &state, ProcessModelType &processModel, MeasurementType &meas)
CATCH_TYPELIST_DESCRIBED_TESTCASE("identity calibration output","[.][ekf]", kalman::SplitQ, kalman::QLastWithSplitInnovation)
Eigen::Quaterniond xform(Eigen::Quaterniond const &quat)