Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
96129 views
1
# -*- coding: utf-8 -*-
2
"""
3
Created on Tue Apr 28 08:19:21 2015
4
5
@author: Roger
6
"""
7
8
9
from math import *
10
import numpy as np
11
import matplotlib.pyplot as plt
12
from matplotlib.patches import Polygon
13
14
wheelbase = 100 #inches
15
16
vel = 20 *12 # fps to inches per sec
17
steering_angle = radians(1)
18
t = 1 # second
19
orientation = 0. # radians
20
21
pos = np.array([0., 0.]
22
23
for i in range(100):
24
#if abs(steering_angle) > 1.e-8:
25
turn_radius = tan(steering_angle)
26
radius = wheelbase / tan(steering_angle)
27
28
dist = vel*t
29
arc_len = dist / (2*pi*radius)
30
31
turn_angle = 2*pi * arc_len
32
33
34
cx = pos[0] - radius * sin(orientation)
35
cy = pos[1] + radius * cos(orientation)
36
37
orientation = (orientation + turn_angle) % (2.0 * pi)
38
pos[0] = cx + (sin(orientation) * radius)
39
pos[1] = cy - (cos(orientation) * radius)
40
41
plt.scatter(pos[0], pos[1])
42
43
plt.axis('equal')
44
45
46
47
48
49