Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
96131 views
1
# -*- coding: utf-8 -*-
2
"""Copyright 2014 Roger R Labbe Jr.
3
4
filterpy library.
5
http://github.com/rlabbe/filterpy
6
7
Documentation at:
8
https://filterpy.readthedocs.org
9
10
Supporting book at:
11
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
12
13
This is licensed under an MIT license. See the readme.MD file
14
for more information.
15
"""
16
17
from __future__ import (absolute_import, division, print_function,
18
unicode_literals)
19
20
from numpy import array
21
import matplotlib.pyplot as plt
22
from filterpy.hinfinity import HInfinityFilter
23
24
25
26
27
def test_Hinfinity():
28
dt = 0.1
29
f = HInfinityFilter(2, 1, 0, gamma=.4)
30
31
f.F = array([[1., dt],
32
[0., 1.]])
33
34
f.H = array([[0., 1.]])
35
f.x = array([[0., 0.]]).T
36
#f.G = array([[dt**2 / 2, dt]]).T
37
38
f.P = 0.01
39
f.W = array([[0.0003, 0.005],
40
[0.0050, 0.100]])/ 1000
41
42
f.V = 0.01
43
f.Q = 0.01
44
45
xs = []
46
vs = []
47
48
for i in range(1,40):
49
f.update (5)
50
print(f.x.T)
51
xs.append(f.x[0,0])
52
vs.append(f.x[1,0])
53
f.predict()
54
55
plt.subplot(211)
56
plt.plot(xs)
57
plt.subplot(212)
58
plt.plot(vs)
59
60
if __name__ == "__main__":
61
test_Hinfinity()
62