nmea_navsat_driver
nmea_navsat_driver copied to clipboard
ValueError for NMEA sentences without nanoseconds in timestamp
Hello!
I'm using ROS Melodic and got this error when working with the nmea_topic_driver node.
Value error, likely due to missing fields in the NMEA message. Error was: invalid literal for int() with base 10: ''
I tracked the error to the parser.py script. Specifically on line 128:
nanosecs = int(nmea_utc[7:]) * pow(10, 9 - len(nmea_utc[7:]))
My GPS reports NMEA strings in the RMC format, the first field in the sentence is the timestamp, which in my case only has a length of 6 digits, causing the aforementioned line to fail.
A possible fix would be changing the line to:
nanosecs = int(nmea_utc[7:]) * pow(10, 9 - len(nmea_utc[7:])) if len(time_str) > 6 else 0
Cheers
Thanks for reporting this. I may have a chance to address it this week, but I'd welcome a PR from anyone who wants to fix it.
i also came across this problem and thankfully this helped me fix it. please update this :)