Skip to content

animation is not working #21

Open
shahin4u000 opened this issue Dec 9, 2018 · 1 comment
Open

animation is not working #21

shahin4u000 opened this issue Dec 9, 2018 · 1 comment

Comments

@shahin4u000
Copy link

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()

`

@claymaks
Copy link

Can you share the error you are getting?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants