From 08123b0d15395725741f73436a244e12359313cb Mon Sep 17 00:00:00 2001 From: Roger Labbe Date: Fri, 1 May 2015 07:05:53 -0700 Subject: [PATCH] Regenerated PDF --- 06_Multivariate_Kalman_Filters.ipynb | 3 +- Appendix_B_Symbols_and_Notations.ipynb | 7 +++- experiments/bicycle.py | 46 ++++++++++++++++++++++++++ experiments/euler.py | 26 +++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 experiments/bicycle.py create mode 100644 experiments/euler.py diff --git a/06_Multivariate_Kalman_Filters.ipynb b/06_Multivariate_Kalman_Filters.ipynb index b72a09f..7aa2921 100644 --- a/06_Multivariate_Kalman_Filters.ipynb +++ b/06_Multivariate_Kalman_Filters.ipynb @@ -388,7 +388,8 @@ "cell_type": "code", "execution_count": 11, "metadata": { - "collapsed": false + "collapsed": false, + "scrolled": true }, "outputs": [ { diff --git a/Appendix_B_Symbols_and_Notations.ipynb b/Appendix_B_Symbols_and_Notations.ipynb index 4e83e76..c049a21 100644 --- a/Appendix_B_Symbols_and_Notations.ipynb +++ b/Appendix_B_Symbols_and_Notations.ipynb @@ -102,7 +102,7 @@ " color: #1d3b84;\n", " font-size: 16pt;\n", " margin-bottom: 0em;\n", - " margin-top: 1.5em;\n", + " margin-top: 0.5em;\n", " display: block;\n", " white-space: nowrap;\n", " }\n", @@ -126,6 +126,11 @@ " overflow-y: scroll;\n", " max-height: 50000px;\n", " }\n", + " div.output_wrapper{\n", + " margin-top:0.2em;\n", + " margin-bottom:0.2em;\n", + "}\n", + "\n", " code{\n", " font-size: 70%;\n", " }\n", diff --git a/experiments/bicycle.py b/experiments/bicycle.py new file mode 100644 index 0000000..76efdb4 --- /dev/null +++ b/experiments/bicycle.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +""" +Created on Tue Apr 28 08:19:21 2015 + +@author: Roger +""" + + +from math import * +import numpy as np +import matplotlib.pyplot as plt + +wheelbase = 100 #inches + +vel = 20 *12 # fps to inches per sec +steering_angle = radians(1) +t = 1 # second +orientation = 0. # radians + +pos = np.array([0., 0.]) + + +for i in range(100): +#if abs(steering_angle) > 1.e-8: + dist = vel*t + turn_radius = tan(steering_angle) + radius = wheelbase / tan(steering_angle) + + arc_len = dist / (2*pi*radius) + + turn_angle = 2*pi * arc_len + + + cx = pos[0] - (sin(orientation) * radius) + cy = pos[1] + (cos(orientation) * radius) + + orientation = (orientation + turn_angle) % (2.0 * pi) + pos[0] = cx + (sin(orientation) * radius) + pos[1] = cy - (cos(orientation) * radius) + + plt.scatter(pos[0], pos[1]) + +plt.axis('equal') + + + \ No newline at end of file diff --git a/experiments/euler.py b/experiments/euler.py new file mode 100644 index 0000000..d9e6b2b --- /dev/null +++ b/experiments/euler.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +""" +Created on Tue Apr 21 18:40:47 2015 + +@author: Roger +""" + + + + +def dx(t, y): + return y + + +def euler(t0, tmax, y0, dx, step=1.): + t = t0 + y = y0 + while t < tmax: + f = dx(t,y) + y = y + step*dx(t, y) + t +=step + + return y + + +print(euler(0, 4, 1, dx, step=0.25)) \ No newline at end of file