tracking/math: Move the generic low pass filters to a/math

This commit is contained in:
Ryan Pavlik 2022-02-22 14:37:15 -06:00
parent dfb1b8d469
commit a0e2df4cf0
9 changed files with 33 additions and 32 deletions

View file

@ -44,6 +44,9 @@ add_library(
math/m_imu_3dof.h
math/m_imu_pre.c
math/m_imu_pre.h
math/m_lowpass_float.hpp
math/m_lowpass_float_vector.hpp
math/m_lowpass_integer.hpp
math/m_optics.c
math/m_permutation.c
math/m_permutation.h
@ -99,9 +102,6 @@ add_library(
tracking/t_imu_fusion.hpp
tracking/t_imu.cpp
tracking/t_imu.h
tracking/t_lowpass_vector.hpp
tracking/t_lowpass.hpp
tracking/t_lowpass_integer.hpp
tracking/t_tracking.h
)
target_link_libraries(

View file

@ -1,10 +1,10 @@
// Copyright 2019, Collabora, Ltd.
// Copyright 2019, 2022, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Low-pass IIR filter
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
* @ingroup aux_tracking
* @ingroup aux_math
*/
#pragma once
@ -20,7 +20,7 @@
#include <type_traits>
namespace xrt::auxiliary::tracking {
namespace xrt::auxiliary::math {
namespace detail {
/*!
@ -176,4 +176,4 @@ private:
detail::LowPassIIR<Scalar, Scalar> impl_;
};
} // namespace xrt::auxiliary::tracking
} // namespace xrt::auxiliary::math

View file

@ -1,10 +1,10 @@
// Copyright 2019, Collabora, Ltd.
// Copyright 2019, 2022, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Low-pass IIR filter on vectors
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
* @ingroup aux_tracking
* @ingroup aux_math
*/
#pragma once
@ -13,12 +13,12 @@
#error "This header is C++-only."
#endif
#include "tracking/t_lowpass.hpp"
#include "math/m_lowpass_float.hpp"
#include <Eigen/Core>
namespace xrt::auxiliary::tracking {
namespace xrt::auxiliary::math {
/*!
* A very simple low-pass filter, using a "one-pole infinite impulse response"
@ -98,4 +98,4 @@ private:
detail::LowPassIIR<Vector, Scalar> impl_;
};
} // namespace xrt::auxiliary::tracking
} // namespace xrt::auxiliary::math

View file

@ -4,7 +4,7 @@
* @file
* @brief Low-pass IIR filter for integers
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
* @ingroup aux_tracking
* @ingroup aux_math
*/
#pragma once
@ -22,7 +22,7 @@
#include <stdexcept>
#include <cassert>
namespace xrt::auxiliary::tracking {
namespace xrt::auxiliary::math {
namespace detail {
@ -166,4 +166,4 @@ private:
detail::IntegerLowPassIIR<Scalar, Scalar> impl_;
};
} // namespace xrt::auxiliary::tracking
} // namespace xrt::auxiliary::math

View file

@ -180,14 +180,17 @@ lib_aux_math = static_library(
'math/m_imu_3dof.h',
'math/m_imu_pre.c',
'math/m_imu_pre.h',
'math/m_lowpass_float.hpp',
'math/m_lowpass_float_vector.hpp',
'math/m_lowpass_integer.hpp',
'math/m_optics.c',
'math/m_permutation.c',
'math/m_permutation.h',
'math/m_predict.c',
'math/m_predict.h',
'math/m_quatexpmap.cpp',
'math/m_relation_history.h',
'math/m_relation_history.cpp',
'math/m_relation_history.h',
'math/m_space.cpp',
'math/m_space.h',
'math/m_vec2.h',
@ -207,8 +210,6 @@ tracking_srcs = [
'tracking/t_imu.h',
'tracking/t_imu_fusion.hpp',
'tracking/t_imu.cpp',
'tracking/t_lowpass.hpp',
'tracking/t_lowpass_vector.hpp',
'tracking/t_tracking.h',
]
tracking_deps = [eigen3]

View file

@ -13,8 +13,8 @@
#error "This header is C++-only."
#endif
#include "tracking/t_lowpass.hpp"
#include "tracking/t_lowpass_vector.hpp"
#include "math/m_lowpass_float.hpp"
#include "math/m_lowpass_float_vector.hpp"
#include "math/m_api.h"
#include "util/u_time.h"
#include "util/u_debug.h"
@ -187,7 +187,7 @@ private:
* user-caused acceleration, and do not reflect the direction of
* gravity.
*/
LowPassIIRVectorFilter<3, double> accel_filter_{200 /* hz cutoff frequency */};
math::LowPassIIRVectorFilter<3, double> accel_filter_{200 /* hz cutoff frequency */};
/*!
* @brief Even-lower low pass filter on the length of the acceleration
@ -197,7 +197,7 @@ private:
* Over time, the length of the accelerometer data will average out to
* be the acceleration due to gravity.
*/
LowPassIIRFilter<double> gravity_filter_{1 /* hz cutoff frequency */};
math::LowPassIIRFilter<double> gravity_filter_{1 /* hz cutoff frequency */};
uint64_t last_accel_timestamp_{0};
uint64_t last_gyro_timestamp_{0};
double gyro_min_squared_length_{1.e-8};

View file

@ -17,8 +17,8 @@ foreach(
tests_id_ringbuffer
tests_input_transform
tests_json
tests_lowpass
tests_lowpass_int
tests_lowpass_float
tests_lowpass_integer
tests_pacing
tests_quatexpmap
tests_rational
@ -35,7 +35,7 @@ endforeach()
target_link_libraries(tests_cxx_wrappers PRIVATE xrt-interfaces)
target_link_libraries(tests_history_buf PRIVATE aux_math)
target_link_libraries(tests_input_transform PRIVATE st_oxr xrt-interfaces xrt-external-openxr)
target_link_libraries(tests_lowpass PRIVATE aux_tracking)
target_link_libraries(tests_lowpass_int PRIVATE aux_tracking)
target_link_libraries(tests_lowpass_float PRIVATE aux_math)
target_link_libraries(tests_lowpass_integer PRIVATE aux_math)
target_link_libraries(tests_quatexpmap PRIVATE aux_math)
target_link_libraries(tests_rational PRIVATE aux_math)

View file

@ -6,16 +6,16 @@
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
*/
#include <tracking/t_lowpass.hpp>
#include <math/m_lowpass_float.hpp>
#include "catch/catch.hpp"
using xrt::auxiliary::tracking::LowPassIIRFilter;
using xrt::auxiliary::math::LowPassIIRFilter;
static constexpr float InitialState = 300;
static constexpr timepoint_ns InitialTime = 12345;
static constexpr timepoint_ns StepSize = U_TIME_1MS_IN_NS * 20;
TEMPLATE_TEST_CASE("t_lowpass", "", float, double)
TEMPLATE_TEST_CASE("LowPassIIRFilter", "", float, double)
{
LowPassIIRFilter<TestType> filter(100);

View file

@ -6,16 +6,16 @@
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
*/
#include <tracking/t_lowpass_integer.hpp>
#include <math/m_lowpass_integer.hpp>
#include "catch/catch.hpp"
using xrt::auxiliary::math::Rational;
using xrt::auxiliary::tracking::IntegerLowPassIIRFilter;
using xrt::auxiliary::math::IntegerLowPassIIRFilter;
static constexpr uint16_t InitialState = 300;
TEMPLATE_TEST_CASE("t_lowpass_integer", "", int32_t, uint32_t)
TEMPLATE_TEST_CASE("IntegerLowPassIIRFilter", "", int32_t, uint32_t)
{
IntegerLowPassIIRFilter<TestType> filter(Rational<TestType>{1, 2});