Exemplo n.º 1
0
    def __init__(
            self,
            start_finish_range=20,  # Meters, ~4x the width of straightaways.
            live_data=True,
            min_points_per_session=60 * 10):  # 1 min @ gps 10hz):
        """Initializer.

    Args:
      start_finish_range: Maximum distance a point can be considered when
                          determining if the car crosses the start/finish.
      live_data: A boolean, if True indicates that this session's data should be
                 tagged as live.
      min_points_per_session:  Used to prevent sessions from prematurely ending.
    """
        self.start_finish_range = start_finish_range
        self.live_data = live_data
        self.min_points_per_session = min_points_per_session
        self.point_queue = multiprocessing.Queue()

        self.config = config_lib.LoadConfig()
        self.leds = leds.LEDs()
        self.data_logger = None
        self.timescale = None
        self.rtmp_overlay = None
        self.point = None
        self.session = gps_pb2.Session()
        self.sdnotify = sdnotify.SystemdNotifier()
        self.sdnotify.notify('READY=1')
Exemplo n.º 2
0
 def testCrossStartFinish(self):
     point_a = gps_pb2.Point()
     point_b = gps_pb2.Point()
     point_c = gps_pb2.Point()
     point_b.start_finish_distance = 5.613414540798601
     point_c.start_finish_distance = 8.86833983566463
     point_a.time.FromMilliseconds(1000)
     point_b.time.FromMilliseconds(2000)
     point_c.time.FromMilliseconds(3000)
     point_a.lat = 45.594961
     point_a.lon = -122.694508
     point_b.lat = 45.594988
     point_b.lon = -122.694587
     point_c.lat = 45.595000
     point_c.lon = -122.694638
     session = gps_pb2.Session()
     session.track = 'Portland International Raceway'
     session.start_finish.lat = 45.595015
     session.start_finish.lon = -122.694526
     lap = session.laps.add()
     lap.points.extend([point_a, point_b])
     es = main.ExitSpeed(min_points_per_session=0)
     es.point = point_c
     es.lap = lap
     es.session = session
     es.CrossStartFinish()
     self.assertEqual(2, len(es.session.laps))
     self.assertEqual(2, len(es.session.laps[0].points))
     self.assertEqual(2, len(es.session.laps[1].points))
     self.assertIn(point_a, es.session.laps[0].points)
     self.assertIn(point_b, es.session.laps[0].points)
     self.assertIn(point_b, es.session.laps[1].points)
     self.assertIn(point_c, es.session.laps[1].points)
     self.assertNotIn(point_c, es.session.laps[0].points)
Exemplo n.º 3
0
 def testSetLapTime(self):
     es = main.ExitSpeed()
     first_point = gps_pb2.Point()
     first_point.time.FromJsonString(u'2020-05-23T17:47:44.100Z')
     last_point = gps_pb2.Point()
     last_point.time.FromJsonString(u'2020-05-23T17:49:00.100Z')
     session = gps_pb2.Session()
     lap = session.laps.add()
     lap.points.append(first_point)
     lap.points.append(last_point)
     es.lap = lap
     es.session = session
     es.SetLapTime()
     self.assertEqual(76, lap.duration.ToSeconds())
     self.assertEqual(es.leds.best_lap, lap)
Exemplo n.º 4
0
    def testCalcLastLapDuration(self):
        start_finish = gps_pb2.Point()
        start_finish.lat = 45.595015
        start_finish.lon = -122.694526
        session = gps_pb2.Session()
        lap = session.laps.add()
        point_x = lap.points.add()
        point_y = lap.points.add()
        point_z = lap.points.add()
        point_x.time.FromMilliseconds(1)
        point_y.time.FromMilliseconds(2)
        point_z.time.FromMilliseconds(3)
        point_x.lat = 45.593988
        point_x.lon = -122.693587
        point_y.lat = 45.594988
        point_y.lon = -122.694587
        point_z.lat = 45.595000
        point_z.lon = -122.694638
        point_y.start_finish_distance = common_lib.PointDelta(
            start_finish, point_y)
        point_z.start_finish_distance = common_lib.PointDelta(
            start_finish, point_z)
        point_y.speed_ms = 69.8
        point_y.speed_ms = 70
        point_z.speed_ms = 70.2
        self.assertEqual(2.0 * 1e6, lap_lib.CalcLastLapDuration(session))

        lap = session.laps.add()
        point_a = point_z
        lap.points.append(point_a)
        point_b = lap.points.add()
        point_c = lap.points.add()
        point_b.time.FromMilliseconds(3)
        point_c.time.FromMilliseconds(4)
        point_b.lat = 45.594988
        point_b.lon = -122.694587
        point_c.lat = 45.595000
        point_c.lon = -122.694638
        point_b.start_finish_distance = common_lib.PointDelta(
            start_finish, point_b)
        point_c.start_finish_distance = common_lib.PointDelta(
            start_finish, point_c)
        point_b.speed_ms = 70
        point_c.speed_ms = 70.2
        self.assertEqual(1000000, lap_lib.CalcLastLapDuration(session))
Exemplo n.º 5
0
    def testProcessSession(self):
        point = gps_pb2.Point()
        point.speed_ms = 21
        lap = gps_pb2.Lap()
        session = gps_pb2.Session()
        es = main.ExitSpeed()
        es.point = point
        es.session = session
        es.ProcessSession()

        for _ in session.laps:
            for lap_point in lap.points:
                self.assertEqual(point, lap_point)

        point = gps_pb2.Point()
        point.speed_ms = 1
        es.point = point
        es.ProcessSession()