Skip to content

Commit 3f47c40

Browse files
committed
add animation simulation
1 parent f5952a4 commit 3f47c40

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

PathPlanning/LQRPlanner/LQRplanner.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import numpy as np
1111
import scipy.linalg as la
1212
import math
13+
import random
1314

1415
show_animation = True
1516

@@ -47,7 +48,6 @@ def LQRplanning(sx, sy, gx, gy):
4748

4849
# animation
4950
if show_animation:
50-
plt.cla()
5151
plt.plot(sx, sy, "or")
5252
plt.plot(gx, gy, "ob")
5353
plt.plot(rx, ry, "-r")
@@ -119,6 +119,28 @@ def LQR_control(A, B, x):
119119
def main():
120120
print(__file__ + " start!!")
121121

122+
ntest = 10
123+
area = 100.0
124+
125+
for i in range(ntest):
126+
sx = 6.0
127+
sy = 6.0
128+
gx = random.uniform(-area, area)
129+
gy = random.uniform(-area, area)
130+
131+
rx, ry = LQRplanning(sx, sy, gx, gy)
132+
133+
if show_animation:
134+
plt.plot(sx, sy, "or")
135+
plt.plot(gx, gy, "ob")
136+
plt.plot(rx, ry, "-r")
137+
plt.axis("equal")
138+
plt.pause(1.0)
139+
140+
141+
def main1():
142+
print(__file__ + " start!!")
143+
122144
sx = 6.0
123145
sy = 6.0
124146
gx = 10.0

0 commit comments

Comments
 (0)