diff --git a/common/params.cc b/common/params.cc index d4c5cd7caf..a23c0e003e 100644 --- a/common/params.cc +++ b/common/params.cc @@ -166,6 +166,7 @@ std::unordered_map keys = { {"TermsVersion", PERSISTENT}, {"Timezone", PERSISTENT}, {"TrainingVersion", PERSISTENT}, + {"UbloxAvailable", PERSISTENT}, {"UpdateAvailable", CLEAR_ON_MANAGER_START}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, {"UpdaterState", CLEAR_ON_MANAGER_START}, diff --git a/common/params.h b/common/params.h index 7758a015f6..aecb3ee471 100644 --- a/common/params.h +++ b/common/params.h @@ -29,8 +29,8 @@ public: // helpers for reading values std::string get(const std::string &key, bool block = false); - inline bool getBool(const std::string &key) { - return get(key) == "1"; + inline bool getBool(const std::string &key, bool block = false) { + return get(key, block) == "1"; } std::map readAll(); diff --git a/common/params_pyx.pyx b/common/params_pyx.pyx index bbddda46ea..9d8933609f 100755 --- a/common/params_pyx.pyx +++ b/common/params_pyx.pyx @@ -16,7 +16,7 @@ cdef extern from "common/params.h": cdef cppclass c_Params "Params": c_Params(string) nogil string get(string, bool) nogil - bool getBool(string) nogil + bool getBool(string, bool) nogil int remove(string) nogil int put(string, string) nogil int putBool(string, bool) nogil @@ -68,11 +68,11 @@ cdef class Params: return val if encoding is None else val.decode(encoding) - def get_bool(self, key): + def get_bool(self, key, bool block=False): cdef string k = self.check_key(key) cdef bool r with nogil: - r = self.p.getBool(k) + r = self.p.getBool(k, block) return r def put(self, key, dat): diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index c7f2d2ceac..c4fdfb9871 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -328,7 +328,7 @@ class EphemerisSourceType(IntEnum): def main(sm=None, pm=None): - use_qcom = os.path.isfile("/persist/comma/use-quectel-rawgps") + use_qcom = not Params().get_bool("UbloxAvailable", block=True) if use_qcom: raw_gnss_socket = "qcomGnss" else: diff --git a/selfdrive/locationd/locationd.cc b/selfdrive/locationd/locationd.cc index ac340fb4aa..9608f4003b 100755 --- a/selfdrive/locationd/locationd.cc +++ b/selfdrive/locationd/locationd.cc @@ -492,10 +492,10 @@ void Localizer::determine_gps_mode(double current_time) { int Localizer::locationd_thread() { const char* gps_location_socket; - if (util::file_exists("/persist/comma/use-quectel-rawgps")) { - gps_location_socket = "gpsLocation"; - } else { + if (Params().getBool("UbloxAvailable", true)) { gps_location_socket = "gpsLocationExternal"; + } else { + gps_location_socket = "gpsLocation"; } const std::initializer_list service_list = {gps_location_socket, "cameraOdometry", "liveCalibration", "carState", "carParams", diff --git a/selfdrive/locationd/test/test_locationd.py b/selfdrive/locationd/test/test_locationd.py index 8841b3e67c..e32861cfae 100755 --- a/selfdrive/locationd/test/test_locationd.py +++ b/selfdrive/locationd/test/test_locationd.py @@ -22,6 +22,7 @@ class TestLocationdProc(unittest.TestCase): self.pm = messaging.PubMaster(self.LLD_MSGS) + Params().put_bool("UbloxAvailable", True) managed_processes['locationd'].prepare() managed_processes['locationd'].start() diff --git a/selfdrive/sensord/pigeond.py b/selfdrive/sensord/pigeond.py index f47cefed6c..5fe120c061 100755 --- a/selfdrive/sensord/pigeond.py +++ b/selfdrive/sensord/pigeond.py @@ -116,7 +116,7 @@ class TTYPigeon(): time.sleep(0.001) -def initialize_pigeon(pigeon: TTYPigeon) -> None: +def initialize_pigeon(pigeon: TTYPigeon) -> bool: # try initializing a few times for _ in range(10): try: @@ -198,6 +198,10 @@ def initialize_pigeon(pigeon: TTYPigeon) -> None: break except TimeoutError: cloudlog.warning("Initialization failed, trying again!") + else: + cloudlog.warning("Failed to initialize pigeon") + return False + return True def deinitialize_and_exit(pigeon: Optional[TTYPigeon]): cloudlog.warning("Storing almanac in ublox flash") @@ -236,7 +240,8 @@ def main(): time.sleep(0.5) pigeon = TTYPigeon() - initialize_pigeon(pigeon) + r = initialize_pigeon(pigeon) + Params().put_bool("UbloxAvailable", r) # start receiving data while True: diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 10084bff9f..9d37be4a56 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -417,6 +417,7 @@ def setup_env(simulation=False, CP=None, cfg=None, controlsState=None): params.put_bool("DisengageOnAccelerator", True) params.put_bool("WideCameraOnly", False) params.put_bool("DisableLogging", False) + params.put_bool("UbloxAvailable", True) os.environ["NO_RADAR_SLEEP"] = "1" os.environ["REPLAY"] = "1" diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index c400eb93f5..e436e92292 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -244,11 +244,13 @@ class CarlaBridge: def __init__(self, arguments): set_params_enabled() + self.params = Params() + msg = messaging.new_message('liveCalibration') msg.liveCalibration.validBlocks = 20 msg.liveCalibration.rpyCalib = [0.0, 0.0, 0.0] - Params().put("CalibrationParams", msg.to_bytes()) - Params().put_bool("WideCameraOnly", not arguments.dual_camera) + self.params.put("CalibrationParams", msg.to_bytes()) + self.params.put_bool("WideCameraOnly", not arguments.dual_camera) self._args = arguments self._carla_objects = [] @@ -363,6 +365,7 @@ class CarlaBridge: gps_bp = blueprint_library.find('sensor.other.gnss') gps = world.spawn_actor(gps_bp, transform, attach_to=vehicle) gps.listen(lambda gps: gps_callback(gps, vehicle_state)) + self.params.put_bool("UbloxAvailable", True) self._carla_objects.extend([imu, gps]) # launch fake car threads