feat: remove FPS global define from libpasada

This commit is contained in:
2026-05-19 22:46:28 +02:00
parent 29019f61e5
commit b333712d9c
9 changed files with 14 additions and 45 deletions

View File

@@ -2,7 +2,6 @@
// Created by david on 28.02.2026.
//
#include <gtest/gtest.h>
#include "library.h"
#include "iir_filter.h"
#include "npy.hpp"
#include <utility>
@@ -10,16 +9,6 @@
#include <string>
#include <filesystem>
// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world from test1.cpp");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
printf("asdf");
hello();
}
TEST(HelloTest, Load_npy_matrix) {
// "C:\\Users\\david\\Documents\\src\\libpasada\\cmake-build-debug\\google-tests"
std::cout << std::filesystem::current_path() << std::endl;

View File

@@ -151,9 +151,7 @@ TEST(SignalTest, RunningQuality_t2) {
std::vector<double> signal = fetch_y_axis(acc);
#if (FPS != 60)
#error "FPS must currently be 60, as highpass taps are pre-computed for that value"
#endif
double fps = 60.0;
// TODO: SQI: cehck input file
// TODO: SQI: print debug values corr,idx, checkedSsf
@@ -174,20 +172,20 @@ TEST(SignalTest, RunningQuality_t2) {
//std::cerr << "before stage 2" << std::endl;
// Stage 2: sum slope function
SsfFilter f_ssf(FPS);
SsfFilter f_ssf(fps);
auto ssf = apply_filter(f_ssf, y_neg);
//std::cerr << "before stage 3" << std::endl;
// Stage 3: threshold detection
DebugSsfStepDetectorThreshold f_ssd_thr(FPS);
DebugSsfStepDetectorThreshold f_ssd_thr(fps);
auto ssf_threshold = apply_filter(f_ssd_thr, ssf);
//std::cerr << "before writing results 1 and doing step detection" << std::endl;
npy_save("test2/ssf_t3_ssf_threshold.npy", ssf_threshold);
SsfStepDetector f_ssd(FPS);
SsfStepDetector f_ssd(fps);
auto steps = apply_filter(f_ssd, ssf);
//std::cerr << "before writing results 2" << std::endl;

View File

@@ -11,14 +11,16 @@
TEST(StepDetector, t1_sub_sample_resolution) {
npy::npy_data s = npy::read_npy<double>("test4/step_150a.npy");
double fps = 60.0;
std::vector<double> signal = fetch_y_axis(s);
const size_t N = signal.size();
const size_t N_INIT = SsfStepDetector::initial_samples(FPS);
const size_t N_INIT = SsfStepDetector::initial_samples(fps);
StepDetector det(FPS, nullptr, true);
StepDetector det(fps, nullptr, true);
// initialize: feed for priming the filters
det.primeFilters(FPS, signal);
det.primeFilters(fps, signal);
// feed for actual test
for (size_t i = 0; i < N; i++) {

View File

@@ -19,9 +19,7 @@ TEST(HelloTest, Zong_SSF_Test5_a1) {
std::vector<double> signal = fetch_y_axis(acc, 2); // (ts, x, y, z) entries -> fetch 'y'
#if (FPS != 60)
#error "FPS must currently be 60, as highpass taps are pre-computed for that value"
#endif
double fps = 60.0;
// Butterworth filter: order=5, fc=0.5, fs=60, btype='highpass'
std::vector b {0.91875845, -4.59379227, 9.18758454, -9.18758454, 4.59379227, -0.91875845};
@@ -40,13 +38,13 @@ TEST(HelloTest, Zong_SSF_Test5_a1) {
//std::cerr << "before stage 2" << std::endl;
// Stage 2: sum slope function
SsfFilter f_ssf(FPS);
SsfFilter f_ssf(fps);
auto ssf = apply_filter(f_ssf, y_neg);
//std::cerr << "before stage 3" << std::endl;
// Stage 3: threshold detection
DebugSsfStepDetectorThreshold f_ssd_thr(FPS);
DebugSsfStepDetectorThreshold f_ssd_thr(fps);
auto ssf_threshold = apply_filter(f_ssd_thr, ssf);
//std::cerr << "before writing results 1 and doing step detection" << std::endl;
@@ -55,7 +53,7 @@ TEST(HelloTest, Zong_SSF_Test5_a1) {
npy_save("test5/ssf_a1_ssf.npy", ssf);
npy_save("test5/ssf_a1_ssf_threshold.npy", ssf_threshold);
SsfStepDetector f_ssd(FPS);
SsfStepDetector f_ssd(fps);
auto steps = apply_filter(f_ssd, ssf);
//std::cerr << "before writing results 2" << std::endl;

View File

@@ -1,7 +1,6 @@
project(Pasada_Lib)
SET(PASADA_SRC
library.cpp
iir_filter.cpp
ssf_filter.cpp
pd_signal.cpp

View File

@@ -1,6 +0,0 @@
#ifndef LIBPASADA_LIBRARY_H
#define LIBPASADA_LIBRARY_H
void hello();
#endif // LIBPASADA_LIBRARY_H

View File

@@ -8,7 +8,7 @@
#include "iir_filter.h"
#include <deque>
#define FPS 60
/** max step rate detected: defines the length of "refractory period" which ignores additional, spurious edges in accelerometer */
#define MAX_BPM 300
/**

View File

@@ -1,7 +0,0 @@
#include "library.h"
#include <iostream>
void hello() {
std::cout << "Hello, World!" << std::endl;
}

View File

@@ -13,10 +13,6 @@ StepDetector::StepDetector(double fps, StepListener *listener, bool debug) :
debug(debug)
{}
#if (FPS != 60)
#error "FPS must currently be 60, as highpass taps are pre-computed for that value"
#endif
void StepDetector::filter(std::vector<float> values) {
// TODO: later on, we should use a vector projection towards gravity
auto s1 = (double) values[1]; // take y-axis value for now