Add 'car/' from commit 'eee0e8dc445691e600680f4abc77f2814b20b054'

git-subtree-dir: car
git-subtree-mainline: 1d29a5526c
git-subtree-split: eee0e8dc44
This commit is contained in:
Piv
2020-04-19 11:07:44 +09:30
93 changed files with 8401 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
This module is a utility to load and save lidar
scans to disk.
As such, it is useful for testing, to create real lidar
data that can be reused later, without needing to connect the lidar.
"""
from rplidar import RPLidar
import pickle
def get_scans(num_scans, device='/dev/ttyUSB0', measurements_per_scan=100):
lidar = RPLidar(device)
scans = lidar.iter_scans(measurements_per_scan)
return [next(scans) for i in range(0, num_scans)]
def save_scans_bytes(scans, filename='out.pickle'):
with open(filename, 'wb') as f:
pickle.dump(scans, f)
def load_scans_bytes_file(filename):
with open(filename, 'rb') as f:
return pickle.load(f)