@@ -276,30 +276,34 @@ def draw_path_to_goal(self, map_):
276
276
end_pos = self .path_coordinates [i + 1 ], width = 4 )
277
277
278
278
def move_robot (self , position , map_ ):
279
- """Draws the robot moving."""
279
+ """Draws the robot moving at the given position ."""
280
280
pygame .draw .circle (surface = map_ , color = (0 , 0 , 255 ), center = position , radius = 4 )
281
281
282
282
def draw_tree (self , nears , news , map_ ):
283
283
"""Draws the tree constantly. Used to display it in an infinite loop."""
284
284
for i in range (len (nears )):
285
285
self .draw_local_planner (p1 = nears [i ], p2 = news [i + 1 ], map_ = map_ )
286
286
287
- def draw_trajectory (self , nears , news , environment_ ):
287
+ def draw_trajectory (self , nears , news , environment , obstacles , keep_tree ):
288
288
"""Draws the robot moving in the map."""
289
289
for i in range (len (self .path_coordinates )- 1 ):
290
290
robot_position = self .path_coordinates [::- 1 ][i ]
291
291
292
+ if obstacles != []:
293
+ environment .draw_obstacles ()
294
+
292
295
# Draw inital and final robot configuration
293
- self .draw_initial_node (map_ = environment_ .map )
294
- self .draw_goal_node (map_ = environment_ .map )
295
- environment_ .draw_obstacles ()
296
+ self .draw_initial_node (map_ = environment .map )
297
+ self .draw_goal_node (map_ = environment .map )
296
298
297
299
# Draw path to goal, and the robot movement
298
- self .draw_path_to_goal (map_ = environment_ .map )
299
- self .move_robot (position = robot_position , map_ = environment_ .map )
300
- self .draw_tree (nears = nears , news = news , map_ = environment_ .map )
300
+ self .draw_path_to_goal (map_ = environment .map )
301
+ self .move_robot (position = robot_position , map_ = environment .map )
302
+
303
+ if keep_tree :
304
+ self .draw_tree (nears = nears , news = news , map_ = environment .map )
301
305
302
306
# Refresh the screen
303
307
pygame .display .update ()
304
308
pygame .time .delay (20 ) # Wait 0.1 seconds
305
- environment_ .map .fill (self .WHITE )
309
+ environment .map .fill (self .WHITE )
0 commit comments