Skip to content

Commit

Permalink
add gif file's name as input argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ShisatoYano committed Dec 2, 2024
1 parent 8fdfade commit 4c0f6d6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/visualization/global_xy_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class GlobalXYVisualizer:
Visualization class for global 2D X-Y plot
"""

def __init__(self, x_lim, y_lim, time_params, show_zoom=True):
def __init__(self, x_lim, y_lim, time_params, show_zoom=True, gif_name=None):
"""
Constructor
x_lim: MinMax object of x axis
y_lim: MinMax object of y axis
time_params: TimeParameters object
show_zoom: Zoom around vehicle when this flag is true
gif_name: Gif file's name as string
"""

self.objects = []
Expand All @@ -27,6 +29,7 @@ def __init__(self, x_lim, y_lim, time_params, show_zoom=True):
self.y_lim = y_lim

self.time_params = time_params
self.gif_name = gif_name
self.show_plot = True
self.show_zoom = show_zoom

Expand Down Expand Up @@ -95,7 +98,10 @@ def draw(self):
frames=self.time_params.get_frame_num(),
interval=self.time_params.get_interval_msec(),
repeat=False)
self.anime.save("simulation.gif", writer="pillow")
if self.gif_name:
self.anime.save(self.gif_name, writer="pillow")
else:
plt.show()
print("Simulation finished!!")
else:
# only when executed as unit test
Expand Down

0 comments on commit 4c0f6d6

Please sign in to comment.