Why is my GPS speed messed up?
Why is my GPS speed messed up?
I have an XGPS150, but the speeds it's reporting seem to be off at some times, and out of sync at others.
I've uploaded two videos to youtube, one with GPS speed, and the other without (I guess it got the speed from OBD?). Neither of them are as accurate as they should be. The speed of the car is visible in the video on the speedometer, and the GPS and OBD reported speeds both seem to be wrong, too far ahead (time-wise) or too far behind (time-wise.) I've attached the lap data file, and two links for the youtube videos.
With GPS speed
http://youtu.be/OXIY0ru_EXw
Without GPS speed
http://youtu.be/OhvSOLSNhjU
Lap Timer File
https://dl.dropboxusercontent.com/u/581 ... 740.hlptrz
I've uploaded two videos to youtube, one with GPS speed, and the other without (I guess it got the speed from OBD?). Neither of them are as accurate as they should be. The speed of the car is visible in the video on the speedometer, and the GPS and OBD reported speeds both seem to be wrong, too far ahead (time-wise) or too far behind (time-wise.) I've attached the lap data file, and two links for the youtube videos.
With GPS speed
http://youtu.be/OXIY0ru_EXw
Without GPS speed
http://youtu.be/OhvSOLSNhjU
Lap Timer File
https://dl.dropboxusercontent.com/u/581 ... 740.hlptrz
Re: Why is my GPS speed messed up?
We have several threads on this topic here on the forum already 
To name the facts:
- Harry

To name the facts:
- GPS speed is very accurate at constant speeds (highways) but is heavily smoothed by GPS and lags significantly for changing speeds
- OBD speed is less accurate (depends on calibration, wheel conditions etc) but has less lag
- dashboards are connected directly to the car's bus and show almost no lag / get the best update rate; but dashboard speed is mostly off reality most as it needs to show a bigger value than reality at any time and in any condition (legal requirement).
- Harry
Re: Why is my GPS speed messed up?
Thanks. It looks like the correction factor isn't retroactive. I just changed it to .96 and overlaid the video again, but the OBD displayed MPH were still too high. Is there anyway to retroactively fix the lap file to have the OBD values reduced by 4%? I don't see any kind of global correction variable in the hlptrz file.
I guess worst case scenario, I could write a script that took the value of each obd speed and reduced it by 4% in the file.
I guess worst case scenario, I could write a script that took the value of each obd speed and reduced it by 4% in the file.
Re: Why is my GPS speed messed up?
Thanks again.
-
- 20 or more Posts ★★★
- Posts: 836
- Joined: Thu May 03, 2012 5:26 am
- Location: Kingsport, TN USA
Re: Why is my GPS speed messed up?
Have you tried exporting the data as .csv and plotting the OBD and GPS speeds vs time in a spreadsheet? Tires have a longitudinal slip factor under hard acceleration as well as a lateral slip angle. That would make the OBD speed faster than the GPS during acceleration even if you didn't have actual wheel spin. That will also tell you if you have to adjust the OBD time offset. RaceLogic makes a traction control system where you can adjust the maximum slip factor allowed. Maximum acceleration with good traction is about a 10% slip factor.
Higher data rate GPS generally smooths less. I see little difference between GPS and OBD speed with the XGPS160@10Hz and the VBox Sport@20Hz.
Higher data rate GPS generally smooths less. I see little difference between GPS and OBD speed with the XGPS160@10Hz and the VBox Sport@20Hz.
Re: Why is my GPS speed messed up?
I was able to apply correction retroactively to the OBD speed by unzipping the hlptrz file, and writing a python script that went through and multiplied every OBD speed by .96 and then saved it as a new XML file. Thanks for using standard file formats, Harry!
Here's the updated vid. I still think some of the timing is a little off on the overlay, but that is likely because I was overlaying on an external video source, and the track recently moved their start/finish line so I can't use it as a frame of reference for the video.
http://youtu.be/_sVnbFhhkZY
Here's the updated vid. I still think some of the timing is a little off on the overlay, but that is likely because I was overlaying on an external video source, and the track recently moved their start/finish line so I can't use it as a frame of reference for the video.
http://youtu.be/_sVnbFhhkZY
Re: Why is my GPS speed messed up?
Oh yeah, in case anyone wants the code for some reason, here it is. Replace the file name with the file in the same directory as the script, and "0.96" with your correction factor. After this is done, rename the "corrected_speed.xml" file to the original hlptrz file name, and then zip it back up before importing it into HLT.
Code: Select all
#!/usr/bin/env python
import xml.etree.ElementTree as ET
file_name = "LapTimer-0131-20150326-093740.hlptrz"
correction_factor = 0.96
parser = ET.XMLParser(encoding="windows-1252")
tree = ET.parse(file_name, parser=parser)
root = tree.getroot()
for speed in root.findall('.//obd/speed'):
corrected_speed = float(speed.text) * correction_factor
speed.text = str(corrected_speed)
tree.write('corrected_speed.xml')
Re: Why is my GPS speed messed up?
Great, thanks. Just write it to corrected_speed.hlptrl instead of corrected_speed.xml. LapTimer does not interpret the filename and accepts both uncompressed .hlptrl and gzip compressed .hlptrz extensions.
- Harry
- Harry
Re: Why is my GPS speed messed up?
Python has gzip libraries so I rewrote the script to make less work for the end user. No need to unzip the source LapTimer file. Now all you have to do is point it at the file, specify the correction factor, and it does all the work and returns a corrected and gzipped LapTimer file. Here's the code (for the maybe one other person in the world who will ever need to do this)
Code: Select all
#!/usr/bin/env python
import xml.etree.ElementTree as ET
import gzip
import argparse
import os.path
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input',
help="Input LapTimer file location.", required = True)
parser.add_argument('-o', '--output',
help='Destination file name for corrected LapTimer file. Default is "corrected_obd_speed.hlptrz"')
parser.add_argument('-c', '--correction-factor',
help="Correction factor to be applied in format '0.95' or '1.1'", required = True)
args = parser.parse_args()
if args.input.endswith('.hlptrz'):
lap_timer_file = gzip.open(args.input, 'rb')
lap_timer_string = lap_timer_file.read()
root = ET.fromstring(lap_timer_string)
for speed in root.findall('.//obd/speed'):
corrected_speed = float(speed.text) * float(args.correction_factor)
speed.text = str(corrected_speed)
tree = ET.ElementTree(root)
if not args.output:
args.output = 'corrected_obd_speed.hlptrz'
corrected_gzip = gzip.open(args.output, 'wb')
tree.write(corrected_gzip)
corrected_gzip.close()
lap_timer_file.close()
print "Corrected OBD speed LapTimer file saved to:", os.path.realpath(corrected_gzip.name)
else:
parser = ET.XMLParser(encoding="windows-1252")
tree = ET.parse(args.input, parser=parser)
root = tree.getroot()
for speed in root.findall('.//obd/speed'):
corrected_speed = float(speed.text) * float(args.correction_factor)
speed.text = str(corrected_speed)
if not args.output:
args.output = 'corrected_obd_speed.hlptrl'
tree.write(args.output)
print "Corrected OBD speed LapTimer file saved to:", os.path.realpath(args.output)