Skip to content

Commit

Permalink
GPS toggle und .kmz
Browse files Browse the repository at this point in the history
  • Loading branch information
balzer82 committed Jul 2, 2014
1 parent b581875 commit ee42b19
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 1,594 deletions.
188 changes: 95 additions & 93 deletions .ipynb_checkpoints/Extended-Kalman-Filter-CTRV-checkpoint.ipynb

Large diffs are not rendered by default.

1,389 changes: 1 addition & 1,388 deletions 2014-03-26-000-Data.csv

Large diffs are not rendered by default.

Binary file modified Extended-Kalman-Filter-CTRV-State-Estimates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
188 changes: 95 additions & 93 deletions Extended-Kalman-Filter-CTRV.ipynb

Large diffs are not rendered by default.

Binary file modified Extended-Kalman-Filter-CTRV.kmz
Binary file not shown.
46 changes: 26 additions & 20 deletions Extended-Kalman-Filter-CTRV.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# <markdowncell>

# Situation covered: You have an velocity sensor which measures the vehicle speed ($v$) in heading direction ($\psi$) and a yaw rate sensor ($\dot \psi$) which both have to fused with the position ($x$ & $y$) from a GPS sensor.
# Situation covered: You have a velocity sensor, which measures the vehicle speed ($v$) in heading direction ($\psi$) and a yaw rate sensor ($\dot \psi$) which both have to fused with the position ($x$ & $y$) from a GPS sensor.

# <headingcell level=2>

Expand Down Expand Up @@ -237,6 +237,8 @@
# <markdowncell>

# Matrix $J_H$ is the Jacobian of the Measurement function $h$ with respect to the state. Function $h$ can be used to compute the predicted measurement from the predicted state.
#
# If a GPS measurement is available, the following function maps the state to the measurement.

# <codecell>

Expand All @@ -251,12 +253,9 @@
JHs=hs.jacobian(state)
JHs

# <codecell>
# <markdowncell>

JH = np.matrix([[1.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 1.0]])
# If no GPS measurement is available, simply set the corresponding values in $J_h$ to zero.

# <headingcell level=2>

Expand Down Expand Up @@ -444,6 +443,17 @@
[float(x[3])],
[float(x[4])]])

if GPS[filterstep]:
JH = np.matrix([[1.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 1.0]])
else:
JH = np.matrix([[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 1.0]])

S = JH*P*JH.T + R
K = (P*JH.T) * np.linalg.inv(S)

Expand Down Expand Up @@ -481,7 +491,7 @@

# <headingcell level=3>

# Uncertainty
# Uncertainties

# <codecell>

Expand Down Expand Up @@ -689,7 +699,7 @@

# <codecell>

from simplekml import Kml, Model, AltitudeMode, Orientation, Scale
from simplekml import Kml, Model, AltitudeMode, Orientation, Scale, Style, Color

# <codecell>

Expand All @@ -708,34 +718,30 @@
# Create the track
trk = kml.newgxtrack(name="EKF", altitudemode=AltitudeMode.clamptoground,
description="State Estimation from Extended Kalman Filter with CTRV Model")
gps = kml.newgxtrack(name="GPS", altitudemode=AltitudeMode.clamptoground,
description="Original GPS Measurements")

# Attach the model to the track
trk.model = model_car
gps.model = model_car

trk.model.link.href = car_dae
gps.model.link.href = car_dae

# Add all the information to the track
trk.newwhen(car["when"])
trk.newgxcoord(car["coord"])

gps.newwhen(car["when"][::5])
gps.newgxcoord((car["gps"][::5]))

# Style of the Track
trk.iconstyle.icon.href = ""
trk.labelstyle.scale = 1
trk.linestyle.width = 4
trk.linestyle.color = '7fff0000'

gps.iconstyle.icon.href = ""
gps.labelstyle.scale = 0
gps.linestyle.width = 3
gps.linestyle.color = '7fffffff'
# Add GPS measurement marker
fol = kml.newfolder(name="GPS Measurements")
sharedstyle = Style()
sharedstyle.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png'

for m in range(len(latitude)):
if GPS[m]:
pnt = fol.newpoint(coords = [(longitude[m],latitude[m])])
pnt.style = sharedstyle

# Saving
#kml.save("Extended-Kalman-Filter-CTRV.kml")
Expand Down

0 comments on commit ee42b19

Please sign in to comment.