-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.py
More file actions
34 lines (27 loc) · 756 Bytes
/
simulation.py
File metadata and controls
34 lines (27 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import matplotlib.pyplot as plt
from DubinsCar import DubinsCar
from Environment import Environment
def gen1(d):
return np.radians(10)
def randomDubins():
car = DubinsCar(theta=np.radians(45), speed=10)
x, y = np.zeros(100), np.zeros(100)
for i in xrange(100):
angle = np.radians(np.random.randint(0, 180))
angle *= np.random.choice([-1, 1])
car.sim_for_dt(angle)
x[i] = car.x
y[i] = car.y
plt.plot(x, y)
plt.axis('square')
plt.show()
def testEnvironment():
env = Environment()
# env = Environment(regulator=gen1)
env.car.speed = 20
env.simUntilCollision()
env.plotPath()
if __name__ == '__main__':
# randomDubins()
testEnvironment()