Its been almost one month and i could not find a way to animate the graph which will show the surrounding. can you please tell me where should i do the modification?
`from rplidar import RPLidar, RPLidarException
import matplotlib.pyplot as plt
import matplotlib.animation as animation
lidar = RPLidar('/dev/ttyUSB0')
info = lidar.get_info()
print(info)
health = lidar.get_health()
print(health)
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='polar')
def run(i):
angle = []
distance = []
for i, scan in enumerate(lidar.iter_scans()):
for d in scan: # d[0] : Quality of the measurement
# if 0< d[1] <200: #d[1] : Angle of the measurement
# print(d[2]/10) #d[2] : Distance of the measurement '''
angle.append(0.0174533 * d[1])
distance.append(d[2])
print('angle:', angle)
ax.clear()
ax.scatter(angle, distance, s=5)
angle.clear()
distance.clear()
ani = animation.FuncAnimation(fig, run, interval=50)
plt.show()
Its been almost one month and i could not find a way to animate the graph which will show the surrounding. can you please tell me where should i do the modification?
`from rplidar import RPLidar, RPLidarException import matplotlib.pyplot as plt import matplotlib.animation as animation
lidar = RPLidar('/dev/ttyUSB0')
info = lidar.get_info() print(info)
health = lidar.get_health() print(health)
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='polar')
def run(i): angle = [] distance = [] for i, scan in enumerate(lidar.iter_scans()):
ani = animation.FuncAnimation(fig, run, interval=50) plt.show()
`