Laikad: set cache dir to comma_download_cache (#25131)

* Cache downloads for process replay

* set cache dir permanent

* Create constant
pull/25136/head
Gijs Koning 3 years ago committed by GitHub
parent 205f6f7414
commit 105afee4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      selfdrive/locationd/laikad.py

@ -27,6 +27,7 @@ from system.swaglog import cloudlog
MAX_TIME_GAP = 10 MAX_TIME_GAP = 10
EPHEMERIS_CACHE = 'LaikadEphemeris' EPHEMERIS_CACHE = 'LaikadEphemeris'
DOWNLOADS_CACHE_FOLDER = "/tmp/comma_download_cache"
CACHE_VERSION = 0.1 CACHE_VERSION = 0.1
POS_FIX_RESIDUAL_THRESHOLD = 100.0 POS_FIX_RESIDUAL_THRESHOLD = 100.0
@ -42,7 +43,7 @@ class Laikad:
valid_ephem_types: Valid ephemeris types to be used by AstroDog valid_ephem_types: Valid ephemeris types to be used by AstroDog
save_ephemeris: If true saves and loads nav and orbit ephemeris to cache. save_ephemeris: If true saves and loads nav and orbit ephemeris to cache.
""" """
self.astro_dog = AstroDog(valid_const=valid_const, auto_update=auto_update, valid_ephem_types=valid_ephem_types, clear_old_ephemeris=True) self.astro_dog = AstroDog(valid_const=valid_const, auto_update=auto_update, valid_ephem_types=valid_ephem_types, clear_old_ephemeris=True, cache_dir=DOWNLOADS_CACHE_FOLDER)
self.gnss_kf = GNSSKalman(GENERATED_DIR, cython=True) self.gnss_kf = GNSSKalman(GENERATED_DIR, cython=True)
self.auto_fetch_orbits = auto_fetch_orbits self.auto_fetch_orbits = auto_fetch_orbits
@ -183,7 +184,7 @@ class Laikad:
def fetch_orbits(self, t: GPSTime, block): def fetch_orbits(self, t: GPSTime, block):
# Download new orbits if 1 hour of orbits data left # Download new orbits if 1 hour of orbits data left
if t + SECS_IN_HR not in self.astro_dog.orbit_fetched_times and (self.last_fetch_orbits_t is None or abs(t - self.last_fetch_orbits_t) > SECS_IN_MIN): if t + SECS_IN_HR not in self.astro_dog.orbit_fetched_times and (self.last_fetch_orbits_t is None or abs(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 astro_dog_vars = self.astro_dog.valid_const, self.astro_dog.auto_update, self.astro_dog.valid_ephem_types, self.astro_dog.cache_dir
ret = None ret = None
if block: # Used for testing purposes if block: # Used for testing purposes
@ -203,8 +204,8 @@ class Laikad:
self.cache_ephemeris(t=t) self.cache_ephemeris(t=t)
def get_orbit_data(t: GPSTime, valid_const, auto_update, valid_ephem_types): def get_orbit_data(t: GPSTime, valid_const, auto_update, valid_ephem_types, cache_dir):
astro_dog = AstroDog(valid_const=valid_const, auto_update=auto_update, valid_ephem_types=valid_ephem_types) astro_dog = AstroDog(valid_const=valid_const, auto_update=auto_update, valid_ephem_types=valid_ephem_types, cache_dir=cache_dir)
cloudlog.info(f"Start to download/parse orbits for time {t.as_datetime()}") cloudlog.info(f"Start to download/parse orbits for time {t.as_datetime()}")
start_time = time.monotonic() start_time = time.monotonic()
try: try:
@ -301,6 +302,7 @@ def main(sm=None, pm=None):
replay = "REPLAY" in os.environ replay = "REPLAY" in os.environ
use_internet = "LAIKAD_NO_INTERNET" not in os.environ use_internet = "LAIKAD_NO_INTERNET" not in os.environ
laikad = Laikad(save_ephemeris=not replay, auto_fetch_orbits=use_internet) laikad = Laikad(save_ephemeris=not replay, auto_fetch_orbits=use_internet)
while True: while True:
sm.update() sm.update()

Loading…
Cancel
Save