This commit is contained in:
Степанов Станислав 2024-11-09 01:02:34 +03:00
commit 582e2d3267
3 changed files with 70 additions and 0 deletions

22
Inc/KalmanFilter.h Normal file
View File

@ -0,0 +1,22 @@
//
// Created by villuton on 08.11.2024.
//
#ifndef KALMANFILTER_H
#define KALMANFILTER_H
#include "vector.h"
typedef struct {
float k;
float result;
float old;
}tSimpleKalman;
typedef struct {
tSimpleKalman x;
tSimpleKalman y;
tSimpleKalman z;
}tSimpleKalmanVect3;
#endif //KALMANFILTER_H

31
Src/KalmanFilter.c Normal file
View File

@ -0,0 +1,31 @@
//
// Created by villuton on 08.11.2024.
//
#include "KalmanFilter.h"
void SimpleKalmanInit(tSimpleKalman *env, float k){
env->k = k;
env->result = (float)0.0;
env->old = (float)0.0;
}
float SimpleKalman(tSimpleKalman *env,float current){
env->old = env->result;
env->result = env->k * current +(1-env->k)*env->old;
return env->result;
}
void SimpleKalmanVect3Init(tSimpleKalmanVect3 *env, float k){
SimpleKalmanInit(&env->x,k);
SimpleKalmanInit(&env->y,k);
SimpleKalmanInit(&env->z,k);
}
vector3 SimpleKalmanVect3(tSimpleKalmanVect3 *env,vector3 current){
vector3 result = {
SimpleKalman(&env->x,current.x),
SimpleKalman(&env->y,current.y),
SimpleKalman(&env->z,current.z)
};
return result;
}

17
modular.json Normal file
View File

@ -0,0 +1,17 @@
{
"dep": [
{
"type": "git",
"provider": "ficom_modules",
"repo": "BaseTypes"
}
],
"cmake": {
"inc_dirs": [
"Inc"
],
"srcs": [
"Src/**.c"
]
}
}