Files
dragonpilot/selfdrive/car/mock/interface.py

33 lines
989 B
Python
Raw Normal View History

2020-01-17 10:58:43 -08:00
#!/usr/bin/env python3
from cereal import car
import cereal.messaging as messaging
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
2020-01-17 10:58:43 -08:00
# mocked car interface for dashcam mode
2020-01-17 10:58:43 -08:00
class CarInterface(CarInterfaceBase):
def __init__(self, CP, CarController, CarState):
2020-05-09 16:40:43 -07:00
super().__init__(CP, CarController, CarState)
2020-01-17 10:58:43 -08:00
self.speed = 0.
self.sm = messaging.SubMaster(['gpsLocation', 'gpsLocationExternal'])
2020-01-17 10:58:43 -08:00
@staticmethod
def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
2020-01-17 10:58:43 -08:00
ret.carName = "mock"
ret.mass = 1700.
ret.wheelbase = 2.70
ret.centerToFront = ret.wheelbase * 0.5
ret.steerRatio = 13.
ret.dashcamOnly = True
2020-01-17 10:58:43 -08:00
return ret
def _update(self, c):
self.sm.update(0)
gps_sock = 'gpsLocationExternal' if self.sm.recv_frame['gpsLocationExternal'] > 1 else 'gpsLocation'
2020-01-17 10:58:43 -08:00
ret = car.CarState.new_message()
ret.vEgo = self.sm[gps_sock].speed
ret.vEgoRaw = self.sm[gps_sock].speed
return ret