mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-24 22:23:53 +08:00
Laikad: more sensible ephemeris management (#28721)
* Laikad: more sensible ephemeris management * Tow * fix test * Also publish qcom * Update * Update laikad.py
This commit is contained in:
@@ -130,26 +130,27 @@ class Laikad:
|
||||
|
||||
if self.save_ephemeris and (self.last_report_time - self.last_cached_t > SECS_IN_MIN):
|
||||
nav_list: List = sum([v for k,v in self.astro_dog.navs.items()], [])
|
||||
ephem_cache = ephemeris_structs.EphemerisCache(**{'glonassEphemerides': [e.data for e in nav_list if e.prn[0]=='R'],
|
||||
'gpsEphemerides': [e.data for e in nav_list if e.prn[0]=='G']})
|
||||
|
||||
put_nonblocking(EPHEMERIS_CACHE, ephem_cache.to_bytes())
|
||||
cloudlog.debug("Cache saved")
|
||||
#TODO this only saves currently valid ephems, when we download future ephems we should save them too
|
||||
valid_navs = [e for e in nav_list if e.valid(self.last_report_time)]
|
||||
if len(valid_navs) > 0:
|
||||
ephem_cache = ephemeris_structs.EphemerisCache(**{'glonassEphemerides': [e.data for e in valid_navs if e.prn[0]=='R'],
|
||||
'gpsEphemerides': [e.data for e in valid_navs if e.prn[0]=='G']})
|
||||
put_nonblocking(EPHEMERIS_CACHE, ephem_cache.to_bytes())
|
||||
cloudlog.debug("Cache saved")
|
||||
self.last_cached_t = self.last_report_time
|
||||
|
||||
def create_ephem_statuses(self):
|
||||
ephemeris_statuses = []
|
||||
prns_to_check = list(self.astro_dog.get_all_ephem_prns())
|
||||
prns_to_check.sort()
|
||||
for prn in prns_to_check:
|
||||
eph = self.astro_dog.get_eph(prn, self.last_report_time)
|
||||
if eph is not None:
|
||||
status = log.GnssMeasurements.EphemerisStatus.new_message()
|
||||
status.constellationId = ConstellationId.from_rinex_char(prn[0]).value
|
||||
status.svId = get_sv_id(prn)
|
||||
status.type = get_log_eph_type(eph).value
|
||||
status.source = get_log_eph_source(eph).value
|
||||
ephemeris_statuses.append(status)
|
||||
eph_list: List = sum([v for k,v in self.astro_dog.navs.items()], []) + sum([v for k,v in self.astro_dog.qcom_polys.items()], [])
|
||||
for eph in eph_list:
|
||||
status = log.GnssMeasurements.EphemerisStatus.new_message()
|
||||
status.constellationId = ConstellationId.from_rinex_char(eph.prn[0]).value
|
||||
status.svId = get_sv_id(eph.prn)
|
||||
status.type = get_log_eph_type(eph).value
|
||||
status.source = get_log_eph_source(eph).value
|
||||
status.tow = eph.epoch.tow
|
||||
status.gpsWeek = eph.epoch.week
|
||||
ephemeris_statuses.append(status)
|
||||
return ephemeris_statuses
|
||||
|
||||
|
||||
|
||||
@@ -251,6 +251,7 @@ class TestLaikad(unittest.TestCase):
|
||||
def test_cache(self):
|
||||
use_qcom = True
|
||||
for use_qcom, logs in zip([True, False], [self.logs_qcom, self.logs]):
|
||||
Params().remove(EPHEMERIS_CACHE)
|
||||
laikad = Laikad(auto_update=True, save_ephemeris=True, use_qcom=use_qcom)
|
||||
def wait_for_cache():
|
||||
max_time = 2
|
||||
@@ -263,8 +264,8 @@ class TestLaikad(unittest.TestCase):
|
||||
# Test cache with no ephemeris
|
||||
laikad.last_report_time = GPSTime(1,0)
|
||||
laikad.cache_ephemeris()
|
||||
wait_for_cache()
|
||||
Params().remove(EPHEMERIS_CACHE)
|
||||
if Params().get(EPHEMERIS_CACHE) is not None:
|
||||
self.fail("Cache should not have been written without valid ephem")
|
||||
|
||||
#laikad.astro_dog.get_navs(self.first_gps_time)
|
||||
msg = verify_messages(logs, laikad, return_one_success=True)
|
||||
|
||||
@@ -1 +1 @@
|
||||
02c134e5a0d1f707c79f7a0ad6c1a5b6b038ee7c
|
||||
7a045a0d17a73bf77c220a16e4d2c0eedc73cfb8
|
||||
|
||||
Reference in New Issue
Block a user