diff --git a/complementary_filter/test/BUILD.bazel b/complementary_filter/test/BUILD.bazel deleted file mode 100644 index 6049dac..0000000 --- a/complementary_filter/test/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_cc//cc:defs.bzl", "cc_test") - -cc_test( - name = "complementary_filter_test", - timeout = "short", - srcs = ["complementary_filter_test.cpp"], - deps = [ - "//complementary_filter", - "@boost_ut", - ], -) diff --git a/complementary_filter/test/complementary_filter_test.cpp b/complementary_filter/test/complementary_filter_test.cpp deleted file mode 100644 index 321ee03..0000000 --- a/complementary_filter/test/complementary_filter_test.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "complementary_filter/complementary_filter.hpp" - -#include - -#include - -auto main() -> int -{ - using ::boost::ut::expect; - using ::boost::ut::test; - - test("complementary filter test") = [] { - using namespace mp_units::si::unit_symbols; - - // NOLINTBEGIN(readability-magic-numbers) - { - auto lowpass = complementary_filter::lowpass<20 * Hz, 5 * ms>{}; - [[maybe_unused]] const auto [y0, yd0] = lowpass(1.0 * rad); - } - - { - auto highpass = complementary_filter::highpass<20 * Hz, 5 * ms>{}; - [[maybe_unused]] const auto [y0, z0] = highpass(1.0 * rad); - } - // NOLINTEND(readability-magic-numbers) - }; -} diff --git a/complementary_filter/BUILD.bazel b/filter/BUILD.bazel similarity index 62% rename from complementary_filter/BUILD.bazel rename to filter/BUILD.bazel index 3f33eb7..72ed1a1 100644 --- a/complementary_filter/BUILD.bazel +++ b/filter/BUILD.bazel @@ -1,8 +1,8 @@ load("@rules_cc//cc:defs.bzl", "cc_library") cc_library( - name = "complementary_filter", - hdrs = ["complementary_filter.hpp"], + name = "filter", + hdrs = ["filter.hpp"], visibility = ["//:__subpackages__"], deps = ["@mp_units"], ) diff --git a/complementary_filter/complementary_filter.hpp b/filter/filter.hpp similarity index 98% rename from complementary_filter/complementary_filter.hpp rename to filter/filter.hpp index a300689..6623bd1 100644 --- a/complementary_filter/complementary_filter.hpp +++ b/filter/filter.hpp @@ -6,7 +6,7 @@ // Low and high pass filters // https://gitlab.com/mechmotum/row_filter/-/blob/master/row_filter/complementary.py -namespace complementary_filter { +namespace filter { namespace mp = mp_units; namespace si = mp_units::si; @@ -133,4 +133,4 @@ struct highpass } }; -} // namespace complementary_filter +} // namespace filter diff --git a/filter/test/BUILD.bazel b/filter/test/BUILD.bazel new file mode 100644 index 0000000..53f2912 --- /dev/null +++ b/filter/test/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_cc//cc:defs.bzl", "cc_test") + +cc_test( + name = "filter_test", + timeout = "short", + srcs = ["filter_test.cpp"], + deps = [ + "//filter", + "@boost_ut", + ], +) diff --git a/filter/test/filter_test.cpp b/filter/test/filter_test.cpp new file mode 100644 index 0000000..fe2e227 --- /dev/null +++ b/filter/test/filter_test.cpp @@ -0,0 +1,30 @@ +#include "filter/filter.hpp" + +#include + +#include + +using namespace mp_units::si::unit_symbols; + +// NOLINTBEGIN(readability-magic-numbers) +constexpr auto cutoff_freq = 20 * Hz; +constexpr auto sample_period = 5 * ms; +// NOLINTEND(readability-magic-numbers) + +auto main() -> int +{ + using ::boost::ut::expect; + using ::boost::ut::test; + + test("high pass filter invocable") = [] { + auto highpass = filter::highpass{}; + [[maybe_unused]] const auto [y0, z0] = highpass(1.0 * rad); + [[maybe_unused]] const auto _ = y0.number(); + }; + + test("low pass filter invocable") = [] { + auto lowpass = filter::lowpass{}; + [[maybe_unused]] const auto [y0, yd0] = lowpass(1.0 * rad); + [[maybe_unused]] const auto _ = y0.number(); + }; +}