2018-11-10 14:13:01 -04:00
|
|
|
#!/usr/bin/python
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
plt.style.use('seaborn-whitegrid')
|
|
|
|
import matplotlib.animation as animation
|
|
|
|
import numpy as np
|
|
|
|
import csv
|
|
|
|
|
|
|
|
fig = plt.figure()
|
|
|
|
ax = fig.add_subplot(1,1,1)
|
2018-11-11 16:11:41 -04:00
|
|
|
fig.set_tight_layout(True)
|
2018-11-10 14:13:01 -04:00
|
|
|
axes = plt.gca()
|
|
|
|
axes.set_xlim([-70,70])
|
|
|
|
axes.set_ylim([-70,70])
|
2018-11-11 16:11:41 -04:00
|
|
|
datafile = open('src/rosbuzz/buzz_scripts/log/voronoi_3.csv', 'r')
|
2018-11-10 14:13:01 -04:00
|
|
|
Vorreader = csv.reader(datafile, delimiter=',')
|
|
|
|
|
|
|
|
def animate(i):
|
|
|
|
for row in Vorreader:
|
|
|
|
ax.clear()
|
|
|
|
# ax.plot([-50, -50, 50, 50, -50],[-50, 50, 50, -50, -50],'b--')
|
|
|
|
j = 1
|
|
|
|
while j < len(row)-2:
|
|
|
|
ax.plot([float(row[j]), float(row[j+2])], [float(row[j+1]), float(row[j+3])])
|
|
|
|
j += 6
|
|
|
|
ax.plot(float(row[len(row)-2]),float(row[len(row)-1]),'x')
|
|
|
|
return
|
|
|
|
|
|
|
|
ani = animation.FuncAnimation(fig, animate, interval=250)
|
2018-11-11 16:11:41 -04:00
|
|
|
ani.save('Voronoi.gif', dpi=80, writer='imagemagick')
|
2018-11-10 14:13:01 -04:00
|
|
|
plt.show()
|