@@ -13,12 +13,14 @@ class GlobalXYVisualizer:
1313 Visualization class for global 2D X-Y plot
1414 """
1515
16- def __init__ (self , x_lim , y_lim , time_params , show_zoom = True ):
16+ def __init__ (self , x_lim , y_lim , time_params , show_zoom = True , gif_name = None ):
1717 """
1818 Constructor
1919 x_lim: MinMax object of x axis
2020 y_lim: MinMax object of y axis
2121 time_params: TimeParameters object
22+ show_zoom: Zoom around vehicle when this flag is true
23+ gif_name: Gif file's name as string
2224 """
2325
2426 self .objects = []
@@ -27,6 +29,7 @@ def __init__(self, x_lim, y_lim, time_params, show_zoom=True):
2729 self .y_lim = y_lim
2830
2931 self .time_params = time_params
32+ self .gif_name = gif_name
3033 self .show_plot = True
3134 self .show_zoom = show_zoom
3235
@@ -95,7 +98,10 @@ def draw(self):
9598 frames = self .time_params .get_frame_num (),
9699 interval = self .time_params .get_interval_msec (),
97100 repeat = False )
98- self .anime .save ("simulation.gif" , writer = "pillow" )
101+ if self .gif_name :
102+ self .anime .save (self .gif_name , writer = "pillow" )
103+ else :
104+ plt .show ()
99105 print ("Simulation finished!!" )
100106 else :
101107 # only when executed as unit test
0 commit comments