From 27e8adbbceee17f2831efda7b36cb079800832ba Mon Sep 17 00:00:00 2001 From: Gijs Koning Date: Fri, 1 Jul 2022 17:44:10 +0200 Subject: [PATCH] Laikad: Allow fetching orbits every minute (#25016) * Allow fetching orbits every minute * Small cleanup old-commit-hash: 8d6799d95a0a0ab9b2b0bc4ed6998abf6cabf266 --- selfdrive/locationd/laikad.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index da00c7aa6f..0df48dd893 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -13,7 +13,7 @@ import numpy as np from cereal import log, messaging from common.params import Params, put_nonblocking from laika import AstroDog -from laika.constants import SECS_IN_HR, SECS_IN_MIN +from laika.constants import SECS_IN_MIN from laika.ephemeris import Ephemeris, EphemerisType, convert_ublox_ephem from laika.gps_time import GPSTime from laika.helpers import ConstellationId @@ -171,7 +171,7 @@ class Laikad: self.gnss_kf.init_state(x_initial, covs_diag=p_initial_diag) def fetch_orbits(self, t: GPSTime, block): - if t not in self.astro_dog.orbit_fetched_times and (self.last_fetch_orbits_t is None or t - self.last_fetch_orbits_t > SECS_IN_HR): + if t not in self.astro_dog.orbit_fetched_times and (self.last_fetch_orbits_t is None or t - self.last_fetch_orbits_t > SECS_IN_MIN): astro_dog_vars = self.astro_dog.valid_const, self.astro_dog.auto_update, self.astro_dog.valid_ephem_types ret = None @@ -195,14 +195,12 @@ def get_orbit_data(t: GPSTime, valid_const, auto_update, valid_ephem_types): astro_dog = AstroDog(valid_const=valid_const, auto_update=auto_update, valid_ephem_types=valid_ephem_types) cloudlog.info(f"Start to download/parse orbits for time {t.as_datetime()}") start_time = time.monotonic() - data = None try: astro_dog.get_orbit_data(t, only_predictions=True) - data = (astro_dog.orbits, astro_dog.orbit_fetched_times) + cloudlog.info(f"Done parsing orbits. Took {time.monotonic() - start_time:.1f}s") + return astro_dog.orbits, astro_dog.orbit_fetched_times except (RuntimeError, ValueError, IOError) as e: cloudlog.warning(f"No orbit data found or parsing failure: {e}") - cloudlog.info(f"Done parsing orbits. Took {time.monotonic() - start_time:.1f}s") - return data def create_measurement_msg(meas: GNSSMeasurement):