ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
ekf.h
Go to the documentation of this file.
1// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15
16#ifndef _ekf_h_
17#define _ekf_h_
18
19#include <stdint.h>
20#include <stdbool.h>
21#include <math.h>
22#include <stdint.h>
23#include <mat.h>
24
29class ekf {
30public:
31
38 ekf(int x, int w);
39
40
44 virtual ~ekf();
51 virtual void Process(float *u, float dt);
52
53
58 virtual void Init() = 0;
63 int NUMX;
68 int NUMW;
69
74
83
88
93
102 void RungeKutta(dspm::Mat &x, float *u, float dt);
103
104 // System Dependent methods:
105
115 virtual dspm::Mat StateXdot(dspm::Mat &x, float *u);
121 virtual void LinearizeFG(dspm::Mat &x, float *u) = 0;
122 //
123
124 // System independent methods
125
131 virtual void CovariancePrediction(float dt);
132
142 virtual void Update(dspm::Mat &H, float *measured, float *expected, float *R);
152 virtual void UpdateRef(dspm::Mat &H, float *measured, float *expected, float *R);
153
157 float *HP;
161 float *Km;
162
163public:
164 // Additional universal helper methods
172 static dspm::Mat quat2rotm(float q[4]);
173
181 static dspm::Mat rotm2quat(dspm::Mat &R);
182
190 static dspm::Mat quat2eul(const float q[4]);
198 static dspm::Mat eul2rotm(float xyz[3]);
199
207 static dspm::Mat rotm2eul(dspm::Mat &rotm);
208
217 static dspm::Mat dFdq(dspm::Mat &vector, dspm::Mat &quat);
218
227 static dspm::Mat dFdq_inv(dspm::Mat &vector, dspm::Mat &quat);
228
236 static dspm::Mat SkewSym4x4(float *w);
237
238 // q product
239 // Rl = [q(1) - q(2) - q(3) - q(4); ...
240 // q(2) q(1) - q(4) q(3); ...
241 // q(3) q(4) q(1) - q(2); ...
242 // q(4) - q(3) q(2) q(1); ...
243
251 static dspm::Mat qProduct(float *q);
252
253};
254
255#endif // _ekf_h_
Matrix.
Definition mat.h:30
virtual dspm::Mat StateXdot(dspm::Mat &x, float *u)
Definition ekf.cpp:411
int NUMW
Definition ekf.h:68
static dspm::Mat rotm2quat(dspm::Mat &R)
Definition ekf.cpp:305
static dspm::Mat dFdq(dspm::Mat &vector, dspm::Mat &quat)
Definition ekf.cpp:367
virtual void LinearizeFG(dspm::Mat &x, float *u)=0
dspm::Mat & F
Definition ekf.h:78
static dspm::Mat dFdq_inv(dspm::Mat &vector, dspm::Mat &quat)
Definition ekf.cpp:389
virtual void Process(float *u, float dt)
Definition ekf.cpp:53
ekf(int x, int w)
Definition ekf.cpp:19
virtual ~ekf()
Definition ekf.cpp:41
static dspm::Mat quat2rotm(float q[4])
Definition ekf.cpp:209
float * HP
Definition ekf.h:157
virtual void CovariancePrediction(float dt)
Definition ekf.cpp:139
int NUMX
Definition ekf.h:63
static dspm::Mat eul2rotm(float xyz[3])
Definition ekf.cpp:251
static dspm::Mat rotm2eul(dspm::Mat &rotm)
Definition ekf.cpp:279
dspm::Mat & G
Definition ekf.h:82
virtual void Update(dspm::Mat &H, float *measured, float *expected, float *R)
Definition ekf.cpp:149
void RungeKutta(dspm::Mat &x, float *u, float dt)
Definition ekf.cpp:60
static dspm::Mat quat2eul(const float q[4])
Definition ekf.cpp:230
dspm::Mat & X
Definition ekf.h:73
virtual void UpdateRef(dspm::Mat &H, float *measured, float *expected, float *R)
Definition ekf.cpp:189
dspm::Mat & Q
Definition ekf.h:92
static dspm::Mat qProduct(float *q)
Definition ekf.cpp:112
virtual void Init()=0
dspm::Mat & P
Definition ekf.h:87
float * Km
Definition ekf.h:161
static dspm::Mat SkewSym4x4(float *w)
Definition ekf.cpp:81
float x[1024]
Definition test_fir.c:10