RPLidar A1 example working

This commit is contained in:
simondlevy
2018-06-30 22:53:23 -04:00
parent 9408fb89e8
commit 6616af3fcd
2 changed files with 13 additions and 4 deletions

View File

@@ -64,7 +64,7 @@ if __name__ == '__main__':
# Interpolate to get 360 angles from 0 through 359, and corresponding distances
f = interp1d(angles, distances, fill_value='extrapolate')
distances = list(f(np.arange(360)))
distances = list(f(np.arange(360))) # slam.update wants a list
# Update SLAM with current Lidar scan, using third element of (quality, angle, distance) triples
slam.update(distances)
@@ -79,9 +79,10 @@ if __name__ == '__main__':
display.setPose(x, y, theta)
# Exit on window close
# Break on window close
if not display.refresh():
exit(0)
break
# Shut down the lidar connection
lidar.stop()
lidar.disconnect()