Files
half-steering-basic-framework/modules/algorithm/rls.h

26 lines
623 B
C
Raw Normal View History

#ifndef RLS_H
#define RLS_H
#include <stdint.h>
#define RLS_MAX_ORDER 4u
typedef struct
{
uint8_t order;
uint8_t initialized;
float lambda;
float theta[RLS_MAX_ORDER];
float covariance[RLS_MAX_ORDER][RLS_MAX_ORDER];
float gain[RLS_MAX_ORDER];
float last_prediction;
float last_error;
} RLSInstance;
void RLSInit(RLSInstance *rls, uint8_t order, float lambda, float init_covariance, const float *initial_theta);
float RLSPredict(const RLSInstance *rls, const float *x);
float RLSUpdate(RLSInstance *rls, const float *x, float y);
const float *RLSGetTheta(const RLSInstance *rls);
#endif