fix speed of mock car with qcom gps (#25993)

* fix speed of mock car with qcom gps

* typo
pull/25999/head
Adeeb Shihadeh 3 years ago committed by GitHub
parent 01d05f66fe
commit 7c49c44c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      selfdrive/car/mock/interface.py

@ -20,8 +20,7 @@ class CarInterface(CarInterfaceBase):
cloudlog.debug("Using Mock Car Interface") cloudlog.debug("Using Mock Car Interface")
self.gyro = messaging.sub_sock('gyroscope') self.sm = messaging.SubMaster(['gyroscope', 'gpsLocation', 'gpsLocationExternal'])
self.gps = messaging.sub_sock('gpsLocationExternal')
self.speed = 0. self.speed = 0.
self.prev_speed = 0. self.prev_speed = 0.
@ -45,15 +44,16 @@ class CarInterface(CarInterfaceBase):
# returns a car.CarState # returns a car.CarState
def _update(self, c): def _update(self, c):
self.sm.update(0)
# get basic data from phone and gps since CAN isn't connected # get basic data from phone and gps since CAN isn't connected
gyro_sensor = messaging.recv_sock(self.gyro) if self.sm.updated['gyroscope']:
if gyro_sensor is not None: self.yaw_rate_meas = -self.sm['gyroscope'].gyroUncalibrated.v[0]
self.yaw_rate_meas = -gyro_sensor.gyroscope.gyroUncalibrated.v[0]
gps = messaging.recv_sock(self.gps) gps_sock = 'gpsLocationExternal' if self.sm.rcv_frame['gpsLocationExternal'] > 1 else 'gpsLocation'
if gps is not None: if self.sm.updated[gps_sock]:
self.prev_speed = self.speed self.prev_speed = self.speed
self.speed = gps.gpsLocationExternal.speed self.speed = self.sm[gps_sock].speed
# create message # create message
ret = car.CarState.new_message() ret = car.CarState.new_message()

Loading…
Cancel
Save