Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
96129 views
1
2
"""Copyright 2015 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
import math
21
from numpy.random import randn
22
23
24
25
def GetRadar(dt):
26
""" Simulate radar range to object at 1K altidue and moving at 100m/s.
27
Adds about 5% measurement noise. Returns slant range to the object.
28
Call once for each new measurement at dt time from last call.
29
"""
30
31
if not hasattr (GetRadar, "posp"):
32
GetRadar.posp = 0
33
34
vel = 100 + .5 * randn()
35
alt = 1000 + 10 * randn()
36
pos = GetRadar.posp + vel*dt
37
38
v = 0 + pos* 0.05*randn()
39
slant_range = math.sqrt (pos**2 + alt**2) + v
40
GetRadar.posp = pos
41
42
return slant_range
43
44
45
if __name__ == "__main__":
46
for i in range (100):
47
print(GetRadar (0.1))
48
49