Skip to content

Commit

Permalink
Feature/auto testing (#12)
Browse files Browse the repository at this point in the history
* added #ifdef GNUPLOT_ENABLE around all gnuplot code

* removed ros1

* added secret

* remove foxy and disable fail  fast

* fix fail-fast??

* added checkout action to workflow

* locked mixin repo

* added rolling test
  • Loading branch information
EirikKolas authored Mar 8, 2024
1 parent 8537d37 commit 216624d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 34 deletions.
48 changes: 17 additions & 31 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
test_docker: # Iterates on all ROS 1 and ROS 2 distributions.
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ros_distribution:
- humble
Expand All @@ -31,11 +32,6 @@ jobs:
# https://ros.org/reps/rep-0003.html
# https://ros.org/reps/rep-2000.html
include:
# Noetic Ninjemys (May 2020 - May 2025)
#- docker_image: ubuntu:focal
# ros_distribution: noetic
# ros_version: 1

# Humble Hawksbill (May 2022 - May 2027)
- docker_image: ubuntu:jammy
ros_distribution: humble
Expand All @@ -47,58 +43,48 @@ jobs:
ros_version: 2

# Rolling Ridley (No End-Of-Life)
#- docker_image: ubuntu:jammy
# ros_distribution: rolling
# ros_version: 2
- docker_image: ubuntu:jammy
ros_distribution: rolling
ros_version: 2

container:
image: ${{ matrix.docker_image }}
steps:
- name: setup ROS environment


- name: Checkout repository
uses: actions/checkout@v2
- name: Setup ROS environment
uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ matrix.ros_distribution }}
- name: build and test ROS 1
if: ${{ matrix.ros_version == 1 }}
- name: Build and test ROS 2 packages
uses: ros-tooling/[email protected]
id: action_ros_ci_step
with:
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc", "coverage-gcc", "coverage-pytest"]
},
"test": {
"mixin": ["coverage-pytest"]
}
}
package-name: ${{ env.PACKAGES }}
target-ros1-distro: ${{ matrix.ros_distribution }}
- name: build and test ROS 2
if: ${{ matrix.ros_version == 2 }}
uses: ros-tooling/[email protected]
with:
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc", "coverage-gcc", "coverage-pytest"]
"mixin": ["coverage-gcc", "coverage-pytest"]
},
"test": {
"mixin": ["coverage-pytest"]
}
}
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml

package-name: ${{ env.PACKAGES }}
target-ros2-distro: ${{ matrix.ros_distribution }}

- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }} # only needed for private repos
token: ${{ secrets.CODECOV_TOKEN }}
files: ros_ws/lcov/total_coverage.info,ros_ws/coveragepy/.coverage
flags: unittests
name: codecov-umbrella
- uses: actions/upload-artifact@v1
with:
name: colcon-logs
name: Colcon-logs
path: ${{ steps.action_ros_ci_step.outputs.ros-workspace-directory-name }}/log
if: always() # upload the logs even when the build fails

Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fixes:
# For each package in your repo
# For each package in the repo
- "ros_ws/src/*/vortex-vkf/vortex-filtering/::"
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
6 changes: 6 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,9 +104,14 @@ 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));

(void)majorAxisLength;
(void)minorAxisLength;
(void)angle;
}

TEST(MultiVarGauss, mahalanobisDistanceIdentityCovariance)
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 216624d

Please sign in to comment.