parent
15e071f88c
commit
c37ccd4565
2 changed files with 5 additions and 32 deletions
@ -1,61 +1,35 @@ |
||||
#!/usr/bin/env python3 |
||||
from cereal import car |
||||
from openpilot.system.swaglog import cloudlog |
||||
import cereal.messaging as messaging |
||||
from openpilot.selfdrive.car import get_safety_config |
||||
from openpilot.selfdrive.car.interfaces import CarInterfaceBase |
||||
|
||||
|
||||
# mocked car interface to work with chffrplus |
||||
# mocked car interface for dashcam mode |
||||
class CarInterface(CarInterfaceBase): |
||||
def __init__(self, CP, CarController, CarState): |
||||
super().__init__(CP, CarController, CarState) |
||||
|
||||
cloudlog.debug("Using Mock Car Interface") |
||||
|
||||
self.sm = messaging.SubMaster(['gpsLocation', 'gpsLocationExternal']) |
||||
|
||||
self.speed = 0. |
||||
self.prev_speed = 0. |
||||
self.sm = messaging.SubMaster(['gpsLocation', 'gpsLocationExternal']) |
||||
|
||||
@staticmethod |
||||
def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): |
||||
ret.carName = "mock" |
||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput)] |
||||
ret.mass = 1700. |
||||
ret.wheelbase = 2.70 |
||||
ret.centerToFront = ret.wheelbase * 0.5 |
||||
ret.steerRatio = 13. # reasonable |
||||
|
||||
ret.steerRatio = 13. |
||||
return ret |
||||
|
||||
# returns a car.CarState |
||||
def _update(self, c): |
||||
self.sm.update(0) |
||||
gps_sock = 'gpsLocationExternal' if self.sm.rcv_frame['gpsLocationExternal'] > 1 else 'gpsLocation' |
||||
if self.sm.updated[gps_sock]: |
||||
self.prev_speed = self.speed |
||||
self.speed = self.sm[gps_sock].speed |
||||
|
||||
# create message |
||||
ret = car.CarState.new_message() |
||||
|
||||
# speeds |
||||
ret.vEgo = self.speed |
||||
ret.vEgoRaw = self.speed |
||||
|
||||
ret.aEgo = self.speed - self.prev_speed |
||||
ret.brakePressed = ret.aEgo < -0.5 |
||||
|
||||
ret.standstill = self.speed < 0.01 |
||||
ret.wheelSpeeds.fl = self.speed |
||||
ret.wheelSpeeds.fr = self.speed |
||||
ret.wheelSpeeds.rl = self.speed |
||||
ret.wheelSpeeds.rr = self.speed |
||||
ret.vEgo = self.sm[gps_sock].speed |
||||
ret.vEgoRaw = self.sm[gps_sock].speed |
||||
|
||||
return ret |
||||
|
||||
def apply(self, c, now_nanos): |
||||
# in mock no carcontrols |
||||
actuators = car.CarControl.Actuators.new_message() |
||||
return actuators, [] |
||||
|
Loading…
Reference in new issue