@@ -55,14 +55,11 @@ def calc_dynamic_window(x, config):
55
55
x [3 ] + config .max_accel * config .dt ,
56
56
x [4 ] - config .max_dyawrate * config .dt ,
57
57
x [4 ] + config .max_dyawrate * config .dt ]
58
- # print(Vs, Vd)
59
58
60
59
# [vmin,vmax, yawrate min, yawrate max]
61
60
dw = [max (Vs [0 ], Vd [0 ]), min (Vs [1 ], Vd [1 ]),
62
61
max (Vs [2 ], Vd [2 ]), min (Vs [3 ], Vd [3 ])]
63
62
64
- #print(dw)
65
-
66
63
return dw
67
64
68
65
@@ -76,7 +73,6 @@ def calc_trajectory(xinit, v, y, config):
76
73
traj = np .vstack ((traj , x ))
77
74
time += config .dt
78
75
79
- # print(len(traj))
80
76
return traj
81
77
82
78
@@ -98,7 +94,7 @@ def calc_final_input(x, u, dw, config, goal, ob):
98
94
speed_cost = config .speed_cost_gain * \
99
95
(config .max_speed - traj [- 1 , 3 ])
100
96
ob_cost = calc_obstacle_cost (traj , ob , config )
101
- #print(ob_cost)
97
+ # print(ob_cost)
102
98
103
99
final_cost = to_goal_cost + speed_cost + ob_cost
104
100
@@ -110,9 +106,6 @@ def calc_final_input(x, u, dw, config, goal, ob):
110
106
min_u = [v , y ]
111
107
best_traj = traj
112
108
113
- # print(min_u)
114
- # input()
115
-
116
109
return min_u , best_traj
117
110
118
111
@@ -144,8 +137,8 @@ def calc_to_goal_cost(traj, goal, config):
144
137
145
138
goal_magnitude = math .sqrt (goal [0 ]** 2 + goal [1 ]** 2 )
146
139
traj_magnitude = math .sqrt (traj [- 1 , 0 ]** 2 + traj [- 1 , 1 ]** 2 )
147
- dot_product = (goal [0 ]* traj [- 1 , 0 ]) + (goal [1 ]* traj [- 1 , 1 ])
148
- error = dot_product / (goal_magnitude * traj_magnitude )
140
+ dot_product = (goal [0 ] * traj [- 1 , 0 ]) + (goal [1 ] * traj [- 1 , 1 ])
141
+ error = dot_product / (goal_magnitude * traj_magnitude )
149
142
error_angle = math .acos (error )
150
143
cost = config .to_goal_cost_gain * error_angle
151
144
@@ -197,7 +190,7 @@ def main():
197
190
x = motion (x , u , config .dt )
198
191
traj = np .vstack ((traj , x )) # store state history
199
192
200
- #print(traj)
193
+ # print(traj)
201
194
202
195
if show_animation :
203
196
plt .cla ()
@@ -218,7 +211,9 @@ def main():
218
211
print ("Done" )
219
212
if show_animation :
220
213
plt .plot (traj [:, 0 ], traj [:, 1 ], "-r" )
221
- plt .show ()
214
+ plt .pause (0.0001 )
215
+
216
+ plt .show ()
222
217
223
218
224
219
if __name__ == '__main__' :
0 commit comments