Skip to content

Commit

Permalink
added #ifdef GNUPLOT_ENABLE around all gnuplot code
Browse files Browse the repository at this point in the history
  • Loading branch information
EirikKolas committed Mar 8, 2024
1 parent c9094af commit ace2c4c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ jobs:
# https://ros.org/reps/rep-2000.html
include:
# Noetic Ninjemys (May 2020 - May 2025)
# - docker_image: ubuntu:focal
# ros_distribution: noetic
# ros_version: 1

# Foxy Fitzroy (May 2020 - May 2023)
- docker_image: ubuntu:focal
ros_distribution: noetic
ros_version: 1
ros_distribution: foxy
ros_version: 2

# Humble Hawksbill (May 2022 - May 2027)
- docker_image: ubuntu:jammy
Expand Down
3 changes: 2 additions & 1 deletion vortex-filtering/test/dynamic_model_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ TEST(DynamicModel, sampleSimpleModel)
EXPECT_TRUE(isApproxEqual(approx_gauss.mean(), true_gauss.mean(), 0.1));
EXPECT_TRUE(isApproxEqual(true_gauss.cov(), true_gauss.cov(), 0.1));

#ifdef GNUPLOT_ENABLE
// Plot

Gnuplot gp;
gp << "set xrange [-10:10]\nset yrange [-10:10]\n";
gp << "set style circle radius 0.05\n";
Expand All @@ -63,6 +63,7 @@ TEST(DynamicModel, sampleSimpleModel)
gp << "set object 1 ellipse center " << cov_ellipse.x() << "," << cov_ellipse.y() << " size " << 3 * cov_ellipse.a() << "," << 3 * cov_ellipse.b()
<< " angle " << cov_ellipse.angle_deg() << "fs empty border lc rgb 'cyan'\n";
gp << "replot\n";
#endif
}

} // namespace simple_dynamic_model_test
Expand Down
2 changes: 2 additions & 0 deletions vortex-filtering/test/ekf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ TEST_F(EKFTestCVModel, convergence)
}
time.pop_back();

#ifdef GNUPLOT_ENABLE
Gnuplot gp;
gp << "set terminal qt size 1600,1000\n"; // Modified to make plot larger
gp << "set multiplot layout 2,1\n";
Expand All @@ -126,4 +127,5 @@ TEST_F(EKFTestCVModel, convergence)
gp.send1d(std::make_tuple(time, x_true_u));
gp.send1d(std::make_tuple(time, x_est_u));
gp << "unset multiplot\n";
#endif
}
3 changes: 3 additions & 0 deletions vortex-filtering/test/numerical_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class NumericalIntegration : public ::testing::Test {

void plot_result(std::string title = "ERK convergence")
{
#ifdef GNUPLOT_ENABLE
// Plot first state and true solution against time
Gnuplot gp;
gp << "set terminal wxt size 1200,800\n";
Expand All @@ -87,6 +88,8 @@ class NumericalIntegration : public ::testing::Test {
gp << "plot '-' with lines title 'True', '-' with lines title 'Approx'\n";
gp.send1d(std::make_tuple(t, vortex::plotting::extract_state_series(x_exact, 0)));
gp.send1d(std::make_tuple(t, vortex::plotting::extract_state_series(x_est, 0)));
#endif
(void)title;
}
};

Expand Down
2 changes: 2 additions & 0 deletions vortex-filtering/test/probability_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ TEST(MultiVarGauss, sample)
double minorAxisLength = cov_ellipse.minor_axis();
double angle = cov_ellipse.angle_deg();

#ifdef GNUPLOT_ENABLE
Gnuplot gp;
gp << "set xrange [-10:10]\nset yrange [-10:10]\n";
gp << "set style circle radius 0.05\n";
Expand All @@ -103,6 +104,7 @@ TEST(MultiVarGauss, sample)
gp << "set object 1 ellipse center " << true_mean(0) << "," << true_mean(1) << " size " << majorAxisLength << "," << minorAxisLength << " angle " << angle
<< "fs empty border lc rgb 'cyan'\n";
gp << "replot\n";
#endif

EXPECT_TRUE(isApproxEqual(mean, true_mean, 0.5));
EXPECT_TRUE(isApproxEqual(cov, true_cov, 0.5));
Expand Down
4 changes: 3 additions & 1 deletion vortex-filtering/test/ukf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ TEST_F(UKFtest, Convergence)
double tol = 1e-1;

// Plot results
Gnuplot gp;

std::vector<double> x_est_mean, z_est_mean, x_est_std, x_p_std, x_m_std;
for (int i = 0; i < n_steps; i++) {
Expand All @@ -116,6 +115,8 @@ TEST_F(UKFtest, Convergence)
x_m_std.push_back(x_est.at(i).mean()(0) - std::sqrt(x_est.at(i).cov()(0, 0))); // x_est - std
}

#ifdef GNUPLOT_ENABLE
Gnuplot gp;
gp << "set terminal wxt size 1200,800\n";
gp << "set title 'UKF convergence'\n";
gp << "set xlabel 'Time [s]'\n";
Expand All @@ -130,6 +131,7 @@ TEST_F(UKFtest, Convergence)
gp.send1d(std::make_tuple(time, x_true));
gp.send1d(std::make_tuple(time, x_est_mean));
gp.send1d(std::make_tuple(time, z_meas));
#endif

// Check convergence

Expand Down

0 comments on commit ace2c4c

Please sign in to comment.