@@ -162,29 +162,29 @@ namespace RobotLocalization
162162
163163 innovationSubset = (measurementSubset - stateSubset);
164164
165- // (2) Check Mahalanobis distance between mapped measurement and state.
166- if ( checkMahalanobisThreshold (innovationSubset, hphrInv, measurement. mahalanobisThresh_ ) )
165+ // Wrap angles in the innovation
166+ for ( size_t i = 0 ; i < updateSize; ++i )
167167 {
168- // (3) Apply the gain to the difference between the state and measurement: x = x + K(z - Hx)
169- // Wrap angles in the innovation
170- for ( size_t i = 0 ; i < updateSize; ++i )
168+ if (updateIndices[i] == StateMemberRoll ||
169+ updateIndices[i] == StateMemberPitch ||
170+ updateIndices[i] == StateMemberYaw )
171171 {
172- if (updateIndices[i] == StateMemberRoll ||
173- updateIndices[i] == StateMemberPitch ||
174- updateIndices[i] == StateMemberYaw)
172+ while (innovationSubset (i) < -PI)
175173 {
176- while (innovationSubset (i) < -PI)
177- {
178- innovationSubset (i) += TAU;
179- }
180-
181- while (innovationSubset (i) > PI)
182- {
183- innovationSubset (i) -= TAU;
184- }
174+ innovationSubset (i) += TAU;
185175 }
186- }
187176
177+ while (innovationSubset (i) > PI)
178+ {
179+ innovationSubset (i) -= TAU;
180+ }
181+ }
182+ }
183+
184+ // (2) Check Mahalanobis distance between mapped measurement and state.
185+ if (checkMahalanobisThreshold (innovationSubset, hphrInv, measurement.mahalanobisThresh_ ))
186+ {
187+ // (3) Apply the gain to the difference between the state and measurement: x = x + K(z - Hx)
188188 state_.noalias () += kalmanGainSubset * innovationSubset;
189189
190190 // (4) Update the estimate error covariance using the Joseph form: (I - KH)P(I - KH)' + KRK'
0 commit comments