Regenerated PDF
This commit is contained in:
46
experiments/bicycle.py
Normal file
46
experiments/bicycle.py
Normal file
@@ -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')
|
||||
|
||||
|
||||
|
||||
26
experiments/euler.py
Normal file
26
experiments/euler.py
Normal file
@@ -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))
|
||||
Reference in New Issue
Block a user