commaai / laika

Simple Python GNSS processing library
MIT License
629 stars 180 forks source link

dog.get_delay fails : IndexError: index 4 is out of bounds for axis 0 with size 4 #114

Open jonathanmuller opened 1 year ago

jonathanmuller commented 1 year ago

Hi,

First of all thank you for the awesome repo. I would like to help solving the following issue

Simple code to reproduce

import laika
from laika import AstroDog
from laika.lib.coordinates import geodetic2ecef
from laika.gps_time import GPSTime
import datetime

constellations = ['GPS', 'GLONASS', 'GALILEO']
dog = AstroDog(valid_const=constellations, dgps=True)
prn ="G07"
pos_ecef = geodetic2ecef([46, 6, 123])
gps_time = GPSTime.from_datetime(datetime.datetime(2022, 11, 25, 9, 43, 6))

delay = dog.get_delay(prn, gps_time, pos_ecef)

print(delay)

Result :

Downloading https://github.com/commaai/gnss-data-alt/raw/master/MCC/PRODUCTS/22328/rapid/Sta22374.sp3
Downloading https://github.com/commaai/gnss-data-alt/raw/master/MCC/PRODUCTS/22329/rapid/Sta22375.sp3
...
pulling from https://geodesy.noaa.gov/corsdata/coord/coord_14/ to /tmp/gnss/cors_coord/zsu4_14.coord.txt
pulling from https://geodesy.noaa.gov/corsdata/coord/coord_14/ to /tmp/gnss/cors_coord/ztl4_14.coord.txt
...
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/dgps.py", line 31, in download_and_parse_station_postions
    with open(coord_file_path, 'r+') as coord_file:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/gnss/cors_coord/ab27_14.coord.txt'

(Let's download it manually : cd /tmp/gnss/cors_coord && wget https://geodesy.noaa.gov/corsdata/coord/coord_14/ab49_14.coord.txt ) Then, relaunching the same code now gives :

Traceback (most recent call last):
  File "/tmp/test_laika.py", line 14, in <module>
    delay = dog.get_delay(prn, gps_time, pos_ecef)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/astro_dog.py", line 325, in get_delay
    return self._get_delay_dgps(prn, rcv_pos, time)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/astro_dog.py", line 340, in _get_delay_dgps
    dgps_corrections = self.get_dgps_corrections(time, rcv_pos)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/astro_dog.py", line 124, in get_dgps_corrections
    latest_data = self._get_latest_valid_data(self.dgps_delays, self.cached_dgps, self.get_dgps_data, time, recv_pos=recv_pos)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/astro_dog.py", line 361, in _get_latest_valid_data
    download_data_func(time, recv_pos)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/astro_dog.py", line 239, in get_dgps_data
    station_names = get_closest_station_names(recv_pos, k=8, max_distance=MAX_DGPS_DISTANCE, cache_dir=self.cache_dir)
  File "/home/jonathan/Desktop/cloud_locate/laika/laika/dgps.py", line 65, in get_closest_station_names
    return np.array(station_ids)[idxs]
IndexError: index 4 is out of bounds for axis 0 with size 4

Any suggestion on why this happens and how to solve it ?

pbkompasz commented 1 year ago
65  distances, idxs = tree.query(pos, k=k, distance_upper_bound=max_distance)

distances is [inf inf inf inf inf inf inf inf] in get_closest_station_names After removing max_distance I get RuntimeError: Pulled dgps, but still can't get valid for time GPSTime(week=2237, tow=466986.0)