Skip to content

Commit d2ab014

Browse files
committed
code clean up
1 parent d8cd25b commit d2ab014

File tree

2 files changed

+8
-55
lines changed

2 files changed

+8
-55
lines changed

PathPlanning/ModelPredictiveTrajectoryGenerator/model_predictive_trajectory_generator.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
h = np.array([0.5, 0.02, 0.02]).T # parameter sampling distance
1717
cost_th = 0.1
1818

19-
show_animation = False
19+
show_animation = True
2020

2121

2222
def plot_arrow(x, y, yaw, length=1.0, width=0.5, fc="r", ec="k"): # pragma: no cover
@@ -91,8 +91,7 @@ def selection_learning_param(dp, p, k0, target):
9191
return mina
9292

9393

94-
def show_trajectory(target, xc, yc):
95-
94+
def show_trajectory(target, xc, yc): # pragma: no cover
9695
plt.clf()
9796
plot_arrow(target.x, target.y, target.yaw)
9897
plt.plot(xc, yc, "-r")
@@ -142,35 +141,16 @@ def test_optimize_trajectory():
142141

143142
x, y, yaw, p = optimize_trajectory(target, k0, init_p)
144143

145-
show_trajectory(target, x, y)
146-
# plt.plot(x, y, "-r")
147-
plot_arrow(target.x, target.y, target.yaw)
148-
plt.axis("equal")
149-
plt.grid(True)
150-
plt.show()
151-
152-
153-
def test_trajectory_generate():
154-
s = 5.0 # [m]
155-
k0 = 0.0
156-
km = np.deg2rad(30.0)
157-
kf = np.deg2rad(-30.0)
158-
159-
# plt.plot(xk, yk, "xr")
160-
# plt.plot(t, kp)
161-
# plt.show()
162-
163-
x, y = motion_model.generate_trajectory(s, km, kf, k0)
164-
165-
plt.plot(x, y, "-r")
166-
plt.axis("equal")
167-
plt.grid(True)
168-
plt.show()
144+
if show_animation:
145+
show_trajectory(target, x, y)
146+
plot_arrow(target.x, target.y, target.yaw)
147+
plt.axis("equal")
148+
plt.grid(True)
149+
plt.show()
169150

170151

171152
def main():
172153
print(__file__ + " start!!")
173-
# test_trajectory_generate()
174154
test_optimize_trajectory()
175155

176156

PathPlanning/RRTDubins/rrt_dubins.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,33 +74,6 @@ def Planning(self, animation=False):
7474
path = self.gen_final_course(lastIndex)
7575
return path
7676

77-
def choose_parent(self, newNode, nearinds):
78-
if not nearinds:
79-
return newNode
80-
81-
dlist = []
82-
for i in nearinds:
83-
dx = newNode.x - self.nodeList[i].x
84-
dy = newNode.y - self.nodeList[i].y
85-
d = math.sqrt(dx ** 2 + dy ** 2)
86-
theta = math.atan2(dy, dx)
87-
if self.check_collision_extend(self.nodeList[i], theta, d):
88-
dlist.append(self.nodeList[i].cost + d)
89-
else:
90-
dlist.append(float("inf"))
91-
92-
mincost = min(dlist)
93-
minind = nearinds[dlist.index(mincost)]
94-
95-
if mincost == float("inf"):
96-
print("mincost is inf")
97-
return newNode
98-
99-
newNode.cost = mincost
100-
newNode.parent = minind
101-
102-
return newNode
103-
10477
def pi_2_pi(self, angle):
10578
return (angle + math.pi) % (2 * math.pi) - math.pi
10679

0 commit comments

Comments
 (0)