  import math
  import numpy as np
  import time
  import threading
  from typing import Any
  
  import cereal.messaging as messaging
  from common.params import Params
  from common.realtime import Ratekeeper, DT_DMON
  from lib.can import can_function
 
</s> remove def fake_gps():
  # TODO: read GPS from CARLA
  pm = messaging.PubMaster(['gpsLocationExternal'])
  while 1:
    dat = messaging.new_message('gpsLocationExternal')
    pm.send('gpsLocationExternal', dat)
    time.sleep(0.01)
 </s> add def gps_callback(gps, vehicle_state):
  dat = messaging.new_message('gpsLocationExternal')

  # transform vel from carla to NED
  # north is -Y in CARLA
  velNED = [
    -vehicle_state.vel.y, # north/south component of NED is negative when moving south
    vehicle_state.vel.x, # positive when moving east, which is x in carla
    vehicle_state.vel.z,
  ]

  dat.gpsLocationExternal = {
    "flags": 1, # valid fix
    "verticalAccuracy": 1.0,
    "speedAccuracy": 0.1,
    "vNED": velNED,
    "bearingDeg": vehicle_state.bearing_deg,
    "latitude": gps.latitude,
    "longitude": gps.longitude,
    "altitude": gps.altitude,
    "source": log.GpsLocationData.SensorSource.ublox,
  }

  pm.send('gpsLocationExternal', dat) </s> remove def imu_callback(imu):
 </s> add def imu_callback(imu, vehicle_state):
  vehicle_state.bearing_deg = math.degrees(imu.compass) </s> remove pm = messaging.PubMaster(['roadCameraState', 'sensorEvents', 'can'])
 </s> add pm = messaging.PubMaster(['roadCameraState', 'sensorEvents', 'can', "gpsLocationExternal"])
from cereal import log
  import math
  import numpy as np
  import time
  import threading
from cereal import log
  from typing import Any
  
  import cereal.messaging as messaging
  from common.params import Params
  from common.realtime import Ratekeeper, DT_DMON
  from lib.can import can_function
keep keep keep add keep keep keep keep keep keep
 sim: get GPS data from CARLA (#20717)

* Send simulated carla GPS to OP

* Use ublox enum from cereal

* Add more fields to carla gnss packet

* use math.degrees

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> 
tools/sim/bridge.py