Branch data Line data Source code
1 : : #pragma once
2 : :
3 : : #include "i_us_processor.hpp"
4 : : #include "us_types.hpp"
5 : : #include <cstddef>
6 : :
7 : : namespace ultrasonic {
8 : :
9 : : /**
10 : : * @brief Concrete implementation of IUsProcessor for statistical filtering of ultrasonic samples.
11 : : * @internal
12 : : */
13 : : class UsProcessor : public IUsProcessor
14 : : {
15 : : public:
16 : : /** @internal */
17 : 3 : UsProcessor() = default;
18 : 17 : ~UsProcessor() override = default;
19 : :
20 : : /** @copydoc IUsProcessor::process() */
21 : : Reading process(const Reading *pings, uint8_t total_pings, const UsConfig &cfg) override;
22 : :
23 : : private:
24 : : /** @internal */
25 : : float reduce_median(float *v, std::size_t n);
26 : :
27 : : /** @internal */
28 : : float reduce_dominant_cluster(float *v, std::size_t n);
29 : :
30 : : /** @internal */
31 : : float get_std_dev(const float *samples, uint8_t count);
32 : : };
33 : :
34 : : } // namespace ultrasonic
|