Skip to content

Commit

Permalink
[TUTO][FIX] Fix compilation error when VISP_HAVE_DISPLAY is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
LAGNEAU Romain committed Sep 16, 2024
1 parent cc066c8 commit 0a5ef8d
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions tutorial/particle-filter/tutorial-pf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,32 @@ int main(const int argc, const char *argv[])
double dtUKF = vpTime::measureTimeMs() - tUKF;
//! [UKF_filtering]

// Get the filtered states
vpColVector XestPF = pfFilter.computeFilteredState();

Check warning on line 744 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L744

Added line #L744 was not covered by tests
vpColVector XestUKF = ukf.getXest();

// Compute satistics
vpColVector cX_GT = cMw * object_pos;

Check warning on line 748 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L748

Added line #L748 was not covered by tests
vpColVector wX_UKF(4, 1.);
vpColVector wX_PF(4, 1.);
for (unsigned int i = 0; i < 3; ++i) {
wX_PF[i] = XestPF[i];
wX_UKF[i] = XestUKF[i];

Check warning on line 753 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L752-L753

Added lines #L752 - L753 were not covered by tests
}
vpColVector cX_PF = cMw * wX_PF;
vpColVector cX_UKF = cMw * wX_UKF;
vpColVector error_PF = cX_PF - cX_GT;
vpColVector error_UKF = cX_UKF - cX_GT;

Check warning on line 758 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L755-L758

Added lines #L755 - L758 were not covered by tests

// Log statistics
std::cout << " [Particle Filter method] " << std::endl;
std::cout << " Norm of the error = " << error_PF.frobeniusNorm() << " m^2" << std::endl;

Check warning on line 762 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L762

Added line #L762 was not covered by tests
std::cout << " Fitting duration = " << dtPF << " ms" << std::endl;

std::cout << " [Unscented Kalman Filter method] " << std::endl;
std::cout << " Norm of the error = " << error_UKF.frobeniusNorm() << " m^2" << std::endl;

Check warning on line 766 in tutorial/particle-filter/tutorial-pf.cpp

View check run for this annotation

Codecov / codecov/patch

tutorial/particle-filter/tutorial-pf.cpp#L766

Added line #L766 was not covered by tests
std::cout << " Fitting duration = " << dtUKF << " ms" << std::endl;

//! [Update_displays]
#ifdef VISP_HAVE_DISPLAY
//! [Noisy_pose]
Expand All @@ -763,29 +789,15 @@ int main(const int argc, const char *argv[])
plot.plot(0, 0, object_pos[0], object_pos[1]);

// Plot the PF filtered state
vpColVector XestPF = pfFilter.computeFilteredState();
plot.plot(0, 1, XestPF[0], XestPF[1]);


// Plot the UKF filtered state
vpColVector XestUKF = ukf.getXest();
plot.plot(0, 2, XestUKF[0], XestUKF[1]);

// Plot the noisy pose
plot.plot(0, 3, wXnoisy, wYnoisy);

vpColVector cX_GT = cMw * object_pos;
vpColVector wX_UKF(4, 1.);
vpColVector wX_PF(4, 1.);
for (unsigned int i = 0; i < 3; ++i) {
wX_PF[i] = XestPF[i];
wX_UKF[i] = XestUKF[i];
}
vpColVector cX_PF = cMw * wX_PF;
vpColVector cX_UKF = cMw * wX_UKF;
vpColVector error_PF = cX_PF - cX_GT;
vpColVector error_UKF = cX_UKF - cX_GT;

// Plot the PF filtered state error
plotError.plot(0, 0, t, error_PF.frobeniusNorm());

Expand Down Expand Up @@ -829,15 +841,6 @@ int main(const int argc, const char *argv[])
//! [Update_renderer]
#endif
//! [Update_displays]

// Log statistics
std::cout << " [Particle Filter method] " << std::endl;
std::cout << " Norm of the error = " << error_PF.frobeniusNorm() << " m^2" << std::endl;
std::cout << " Fitting duration = " << dtPF << " ms" << std::endl;

std::cout << " [Unscented Kalman Filter method] " << std::endl;
std::cout << " Norm of the error = " << error_UKF.frobeniusNorm() << " m^2" << std::endl;
std::cout << " Fitting duration = " << dtUKF << " ms" << std::endl;
}
//! [Simu_loop]
std::cout << "Press Enter to quit..." << std::endl;
Expand Down

0 comments on commit 0a5ef8d

Please sign in to comment.