Clean up project directory.
This commit is contained in:
0
persontracking/__init__.py
Normal file
0
persontracking/__init__.py
Normal file
@@ -1,7 +1,8 @@
|
||||
import rplidar
|
||||
from rplidar import RPLidar
|
||||
from threading import Thread
|
||||
import algorithms
|
||||
from persontracking import algorithms
|
||||
import zmq
|
||||
|
||||
class LidarCache():
|
||||
'''
|
||||
@@ -14,7 +15,8 @@ class LidarCache():
|
||||
currentGroups = None
|
||||
groupsChanged = []
|
||||
|
||||
def __init__(self, measurements=100):
|
||||
def __init__(self, port, measurements=100):
|
||||
self.port = port
|
||||
self.lidar = RPLidar('/dev/ttyUSB0')
|
||||
self.measurements = measurements
|
||||
print('Info: ' + self.lidar.get_info())
|
||||
@@ -28,6 +30,11 @@ 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))
|
||||
|
||||
for i, scan in enumerate(self.lidar.iter_scans(min_len=self.measurements)):
|
||||
print('%d: Got %d measurments' % (i, len(scan)))
|
||||
if(not self.run):
|
||||
@@ -40,7 +47,13 @@ class LidarCache():
|
||||
self.currentGroups = algorithms.calc_groups(scan)
|
||||
|
||||
def fireGroupsChanged(self):
|
||||
# Send the updated groups to 0MQ socket.
|
||||
# self._socket.send_multipart(["lidar_map", ...])
|
||||
pass
|
||||
|
||||
def stop_scanning(self):
|
||||
self.run = False
|
||||
|
||||
def _create_socket(self):
|
||||
return zmq.Context.instance().socket(zmq.PUB)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import lidar_tracker_pb2
|
||||
import lidar_tracker_pb2_grpc
|
||||
from .lidar_cache import LidarCache
|
||||
class LidarServicer(lidar_tracker_pb2_grpc.PersonTrackingServicer):
|
||||
import persontracking.lidar_tracker_pb2 as lidar_tracker_pb2
|
||||
from persontracking.lidar_tracker_pb2_grpc import PersonTrackingServicer
|
||||
from persontracking.lidar_cache import LidarCache\
|
||||
|
||||
|
||||
|
||||
class LidarServicer(PersonTrackingServicer):
|
||||
|
||||
def __init__(self):
|
||||
self.cache = LidarCache(measurements=100)
|
||||
@@ -21,5 +24,4 @@ class LidarServicer(lidar_tracker_pb2_grpc.PersonTrackingServicer):
|
||||
Starts the lidar cache.
|
||||
'''
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ message PointScan{
|
||||
repeated Point points = 1;
|
||||
}
|
||||
|
||||
message TrackingInfo{
|
||||
int32 port = 1;
|
||||
}
|
||||
|
||||
service PersonTracking{
|
||||
rpc set_tracking_group(Int32Value) returns (Empty) {}
|
||||
|
||||
@@ -31,5 +35,5 @@ service PersonTracking{
|
||||
|
||||
rpc get_scan_data(Empty) returns (PointScan) {}
|
||||
|
||||
rpc start_tracking(Empty) returns (Empty) {}
|
||||
rpc start_tracking(TrackingInfo) returns (Empty) {}
|
||||
}
|
||||
Reference in New Issue
Block a user