@@ -47,21 +47,22 @@ Ekf::~Ekf() {}
4747
4848void Ekf::correct (const Measurement & measurement)
4949{
50- FB_DEBUG (" ---------------------- Ekf::correct ----------------------\n " <<
51- " State is:\n " <<
52- state_ <<
53- " \n "
54- " Topic is:\n " <<
55- measurement.topic_name_ <<
56- " \n "
57- " Measurement is:\n " <<
58- measurement.measurement_ <<
59- " \n "
60- " Measurement topic name is:\n " <<
61- measurement.topic_name_ <<
62- " \n\n "
63- " Measurement covariance is:\n " <<
64- measurement.covariance_ << " \n " );
50+ FB_DEBUG (
51+ " ---------------------- Ekf::correct ----------------------\n " <<
52+ " State is:\n " <<
53+ state_ <<
54+ " \n "
55+ " Topic is:\n " <<
56+ measurement.topic_name_ <<
57+ " \n "
58+ " Measurement is:\n " <<
59+ measurement.measurement_ <<
60+ " \n "
61+ " Measurement topic name is:\n " <<
62+ measurement.topic_name_ <<
63+ " \n\n "
64+ " Measurement covariance is:\n " <<
65+ measurement.covariance_ << " \n " );
6566
6667 // We don't want to update everything, so we need to build matrices that only
6768 // update the measured parts of our state vector. Throughout prediction and
@@ -73,11 +74,13 @@ void Ekf::correct(const Measurement & measurement)
7374 if (measurement.update_vector_ [i]) {
7475 // Handle nan and inf values in measurements
7576 if (std::isnan (measurement.measurement_ (i))) {
76- FB_DEBUG (" Value at index " << i <<
77- " was nan. Excluding from update.\n " );
77+ FB_DEBUG (
78+ " Value at index " << i <<
79+ " was nan. Excluding from update.\n " );
7880 } else if (std::isinf (measurement.measurement_ (i))) {
79- FB_DEBUG (" Value at index " << i <<
80- " was inf. Excluding from update.\n " );
81+ FB_DEBUG (
82+ " Value at index " << i <<
83+ " was inf. Excluding from update.\n " );
8184 } else {
8285 update_indices.push_back (i);
8386 }
@@ -117,10 +120,11 @@ void Ekf::correct(const Measurement & measurement)
117120 // than exclude the measurement or make up a covariance, just take
118121 // the absolute value.
119122 if (measurement_covariance_subset (i, i) < 0 ) {
120- FB_DEBUG (" WARNING: Negative covariance for index " <<
121- i << " of measurement (value is" <<
122- measurement_covariance_subset (i, i) <<
123- " ). Using absolute value...\n " );
123+ FB_DEBUG (
124+ " WARNING: Negative covariance for index " <<
125+ i << " of measurement (value is" <<
126+ measurement_covariance_subset (i, i) <<
127+ " ). Using absolute value...\n " );
124128
125129 measurement_covariance_subset (i, i) =
126130 ::fabs (measurement_covariance_subset(i, i));
@@ -133,9 +137,10 @@ void Ekf::correct(const Measurement & measurement)
133137 // measurement can be completely without error, so add a small
134138 // amount in that case.
135139 if (measurement_covariance_subset (i, i) < 1e-9 ) {
136- FB_DEBUG (" WARNING: measurement had very small error covariance for index " <<
137- update_indices[i] <<
138- " . Adding some noise to maintain filter stability.\n " );
140+ FB_DEBUG (
141+ " WARNING: measurement had very small error covariance for index " <<
142+ update_indices[i] <<
143+ " . Adding some noise to maintain filter stability.\n " );
139144
140145 measurement_covariance_subset (i, i) = 1e-9 ;
141146 }
@@ -148,12 +153,13 @@ void Ekf::correct(const Measurement & measurement)
148153 state_to_measurement_subset (i, update_indices[i]) = 1 ;
149154 }
150155
151- FB_DEBUG (" Current state subset is:\n " <<
152- state_subset << " \n Measurement subset is:\n " <<
153- measurement_subset << " \n Measurement covariance subset is:\n " <<
154- measurement_covariance_subset <<
155- " \n State-to-measurement subset is:\n " <<
156- state_to_measurement_subset << " \n " );
156+ FB_DEBUG (
157+ " Current state subset is:\n " <<
158+ state_subset << " \n Measurement subset is:\n " <<
159+ measurement_subset << " \n Measurement covariance subset is:\n " <<
160+ measurement_covariance_subset <<
161+ " \n State-to-measurement subset is:\n " <<
162+ state_to_measurement_subset << " \n " );
157163
158164 // (1) Compute the Kalman gain: K = (PH') / (HPH' + R)
159165 Eigen::MatrixXd pht =
@@ -182,8 +188,9 @@ void Ekf::correct(const Measurement & measurement)
182188 }
183189
184190 // (2) Check Mahalanobis distance between mapped measurement and state.
185- if (checkMahalanobisThreshold (innovation_subset, hphr_inverse,
186- measurement.mahalanobis_thresh_ ))
191+ if (checkMahalanobisThreshold (
192+ innovation_subset, hphr_inverse,
193+ measurement.mahalanobis_thresh_ ))
187194 {
188195 // (3) Apply the gain to the difference between the state and measurement: x
189196 // = x + K(z - Hx)
@@ -218,9 +225,10 @@ void Ekf::predict(
218225{
219226 const double delta_sec = filter_utilities::toSec (delta);
220227
221- FB_DEBUG (" ---------------------- Ekf::predict ----------------------\n " <<
222- " delta is " << filter_utilities::toSec (delta) << " \n " <<
223- " state is " << state_ << " \n " );
228+ FB_DEBUG (
229+ " ---------------------- Ekf::predict ----------------------\n " <<
230+ " delta is " << filter_utilities::toSec (delta) << " \n " <<
231+ " state is " << state_ << " \n " );
224232
225233 double roll = state_ (StateMemberRoll);
226234 double pitch = state_ (StateMemberPitch);
@@ -377,11 +385,12 @@ void Ekf::predict(
377385 transfer_function_jacobian_ (StateMemberYaw, StateMemberRoll) = dFY_dR;
378386 transfer_function_jacobian_ (StateMemberYaw, StateMemberPitch) = dFY_dP;
379387
380- FB_DEBUG (" Transfer function is:\n " <<
381- transfer_function_ << " \n Transfer function Jacobian is:\n " <<
382- transfer_function_jacobian_ << " \n Process noise covariance is:\n " <<
383- process_noise_covariance_ << " \n Current state is:\n " <<
384- state_ << " \n " );
388+ FB_DEBUG (
389+ " Transfer function is:\n " <<
390+ transfer_function_ << " \n Transfer function Jacobian is:\n " <<
391+ transfer_function_jacobian_ << " \n Process noise covariance is:\n " <<
392+ process_noise_covariance_ << " \n Current state is:\n " <<
393+ state_ << " \n " );
385394
386395 Eigen::MatrixXd * process_noise_covariance = &process_noise_covariance_;
387396
@@ -414,9 +423,10 @@ void Ekf::predict(
414423 // Handle wrapping
415424 wrapStateAngles ();
416425
417- FB_DEBUG (" Predicted state is:\n " <<
418- state_ << " \n Current estimate error covariance is:\n " <<
419- estimate_error_covariance_ << " \n " );
426+ FB_DEBUG (
427+ " Predicted state is:\n " <<
428+ state_ << " \n Current estimate error covariance is:\n " <<
429+ estimate_error_covariance_ << " \n " );
420430
421431 // (3) Project the error forward: P = J * P * J' + Q
422432 estimate_error_covariance_ =
0 commit comments