nmea_navsat_driver icon indicating copy to clipboard operation
nmea_navsat_driver copied to clipboard

ValueError for NMEA sentences without nanoseconds in timestamp

Open ctampier opened this issue 3 years ago • 2 comments

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

ctampier avatar Aug 27 '21 11:08 ctampier

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.

evenator avatar Oct 26 '21 15:10 evenator

i also came across this problem and thankfully this helped me fix it. please update this :)

aristow1 avatar Jan 18 '23 14:01 aristow1