Add some running code for lidar cache, test stubs, fix proto.
This commit is contained in:
@@ -28,7 +28,7 @@ class Group:
|
|||||||
|
|
||||||
def _update_min_max(self, new_point):
|
def _update_min_max(self, new_point):
|
||||||
"""
|
"""
|
||||||
Updates the in and max points for this group.
|
Updates the min and max points for this group.
|
||||||
This is to determine when assigning groups whether the
|
This is to determine when assigning groups whether the
|
||||||
same group is selected.
|
same group is selected.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ from threading import Thread
|
|||||||
from car.tracking import algorithms
|
from car.tracking import algorithms
|
||||||
import car.tracking.lidar_tracker_pb2 as tracker_pb
|
import car.tracking.lidar_tracker_pb2 as tracker_pb
|
||||||
import zmq
|
import zmq
|
||||||
|
from car.tracking.devices.mock_lidar import MockLidar
|
||||||
|
import car.tracking.lidar_loader as lidar_loader
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class LidarCache():
|
class LidarCache():
|
||||||
@@ -65,7 +68,7 @@ class LidarCache():
|
|||||||
angle=point[1], distance=point[2], group_number=group.number))
|
angle=point[1], distance=point[2], group_number=group.number))
|
||||||
|
|
||||||
for listener in self._group_listeners:
|
for listener in self._group_listeners:
|
||||||
listener.onGroupsChanged(pointScan)
|
listener(pointScan)
|
||||||
|
|
||||||
def add_groups_changed_listener(self, listener):
|
def add_groups_changed_listener(self, listener):
|
||||||
"""
|
"""
|
||||||
@@ -76,9 +79,17 @@ class LidarCache():
|
|||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
listener
|
listener
|
||||||
An object that implements the onGroupsChanged(message) method.
|
An function that takes a PointScan proto object as its argument.
|
||||||
"""
|
"""
|
||||||
self._group_listeners.append(listener)
|
self._group_listeners.append(listener)
|
||||||
|
|
||||||
def stop_scanning(self):
|
def stop_scanning(self):
|
||||||
self.run = False
|
self.run = False
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
lidar = MockLidar(iter(lidar_loader.load_scans_bytes_file('car/src/car/tracking/out.pickle')))
|
||||||
|
cache = LidarCache(lidar)
|
||||||
|
cache.add_groups_changed_listener(lambda a : print(a))
|
||||||
|
cache.start_cache()
|
||||||
|
time.sleep(1)
|
||||||
|
cache.stop_scanning()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class LidarServicer(PersonTrackingServicer):
|
|||||||
self._lidar = RecordingLidarDecorator(
|
self._lidar = RecordingLidarDecorator(
|
||||||
lidar_factory.get_lidar())
|
lidar_factory.get_lidar())
|
||||||
self.cache = LidarCache(self._lidar, measurements=100)
|
self.cache = LidarCache(self._lidar, measurements=100)
|
||||||
self.cache.add_groups_changed_listener(self)
|
self.cache.add_groups_changed_listener(self.onGroupsChanged)
|
||||||
self._mFactory = None
|
self._mFactory = None
|
||||||
self._port = 50052 if 'CAR_ZMQ_PORT' not in os.environ else os.environ[
|
self._port = 50052 if 'CAR_ZMQ_PORT' not in os.environ else os.environ[
|
||||||
'CAR_ZMQ_PORT']
|
'CAR_ZMQ_PORT']
|
||||||
|
|||||||
33
car/tests/test_algorithms.py
Normal file
33
car/tests/test_algorithms.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import unittest
|
||||||
|
import car.tracking as tracking
|
||||||
|
from car.tracking.devices.mock_lidar import MockLidar
|
||||||
|
import car.tracking.lidar_loader as loader
|
||||||
|
|
||||||
|
class TestAlgorithms(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.lidar = MockLidar(iter(loader.get_scans('../src/car/tracking/out.pickle')))
|
||||||
|
|
||||||
|
def test_find_centre(self):
|
||||||
|
# e.g.
|
||||||
|
#self.assertEqual
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_convert_lidar_cartesian(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_convert_cartesian_lidar(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_calc_groups_runs(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_group_changing(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
10
car/tests/test_lidar_cache.py
Normal file
10
car/tests/test_lidar_cache.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import unittest
|
||||||
|
import car.tracking as tracking
|
||||||
|
|
||||||
|
class TestLidarCache(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_fake_scanner(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -16,7 +16,7 @@ message Int32Value{
|
|||||||
|
|
||||||
message Point{
|
message Point{
|
||||||
double angle = 1;
|
double angle = 1;
|
||||||
int32 distance = 2;
|
double distance = 2;
|
||||||
int32 group_number = 3;
|
int32 group_number = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user