Tidy up lidar tracker and its protos
This commit is contained in:
@@ -4,6 +4,7 @@ from threading import Thread
|
||||
from persontracking import algorithms
|
||||
import zmq
|
||||
|
||||
|
||||
class LidarCache():
|
||||
'''
|
||||
A class that retrieves scans from the lidar,
|
||||
@@ -14,15 +15,18 @@ class LidarCache():
|
||||
tracking_group_number = -1
|
||||
currentGroups = None
|
||||
groupsChanged = []
|
||||
|
||||
def __init__(self, port, measurements=100):
|
||||
self.port = port
|
||||
port = None
|
||||
|
||||
def __init__(self, measurements=100):
|
||||
self.lidar = RPLidar('/dev/ttyUSB0')
|
||||
self.measurements = measurements
|
||||
print('Info: ' + self.lidar.get_info())
|
||||
print('Health: ' + self.lidar.get_health())
|
||||
|
||||
def start_cache(self):
|
||||
if self.port is None:
|
||||
print('ERROR: Port has not been set!')
|
||||
return
|
||||
self.thread = Thread(target=self.do_scanning)
|
||||
self.thread.start()
|
||||
|
||||
@@ -30,7 +34,6 @@ class LidarCache():
|
||||
'''
|
||||
Performs a scan for the given number of iterations.
|
||||
'''
|
||||
|
||||
# Create the 0MQ socket first. This should not be passed between threads.
|
||||
self._socket = self._create_socket()
|
||||
self._socket.bind("tcp://*:" + str(self.port))
|
||||
@@ -40,9 +43,10 @@ class LidarCache():
|
||||
if(not self.run):
|
||||
break
|
||||
|
||||
# Now process the groups.
|
||||
# Now process the groups.
|
||||
if self.currentGroups is not None:
|
||||
self.currentGroups = algorithms.assign_groups(self.currentGroups, algorithms.calc_groups(scan))
|
||||
self.currentGroups = algorithms.assign_groups(
|
||||
self.currentGroups, algorithms.calc_groups(scan))
|
||||
else:
|
||||
self.currentGroups = algorithms.calc_groups(scan)
|
||||
|
||||
@@ -56,4 +60,3 @@ class LidarCache():
|
||||
|
||||
def _create_socket(self):
|
||||
return zmq.Context.instance().socket(zmq.PUB)
|
||||
|
||||
Reference in New Issue
Block a user