Add more print statments, actually allow scanning to start.

This commit is contained in:
Piv
2020-02-17 22:14:38 +10:30
parent 065dcc437a
commit 46bf1fe4e4

View File

@@ -31,29 +31,39 @@ class SlamStreamer:
to calling this method, and changing those values after to calling this method, and changing those values after
calling this method will have no effect. calling this method will have no effect.
''' '''
self.can_scan = True
print('Starting to stream') print('Starting to stream')
self._socket = self._start_socket( self._socket = self._start_socket(
self._create_socket(self._zmq_context), self._port) self._create_socket(self._zmq_context), self._port)
print('Started and bound zmq socket.') print('Started and bound zmq socket.'
# Adapted from BreezySLAM rpslam example. # Adapted from BreezySLAM rpslam example.
# Connect to Lidar unit # Connect to Lidar unit
lidar = Lidar(self._lidar_connection) lidar = Lidar(self._lidar_connection)
print('Initialised lidar')
# Create an RMHC SLAM object with a laser model and optional robot model # Create an RMHC SLAM object with a laser model and optional robot model
slam = RMHC_SLAM(LaserModel(), self._map_pixels, self._map_meters) slam = RMHC_SLAM(LaserModel(), self._map_pixels, self._map_meters)
print('initialised slam')
# Initialize empty map # Initialize empty map
mapbytes = bytearray(self.map_pixels * self.map_pixels) mapbytes = bytearray(self.map_pixels * self.map_pixels)
print('Initialised byte []')
# Create an iterator to collect scan data from the RPLidar # Create an iterator to collect scan data from the RPLidar
iterator = lidar.iter_scans() iterator = lidar.iter_scans()
print('Scanning')
# First scan is crap, so ignore it # First scan is crap, so ignore it
next(iterator) next(iterator)
print('Going to next scan')
while self.can_scan: while self.can_scan:
# Extract (quality, angle, distance) triples from current scan # Extract (quality, angle, distance) triples from current scan
items = [item for item in next(iterator)] items = [item for item in next(iterator)]