Question about tdble type and vehicle position
Owen McAree <o.mcaree <at> sheffield.ac.uk>
2014-12-03 10:01:36 GMT
Firstly I'd like to say thanks for creating such a great piece of software! I've just started a research job and will be using TORCS extensively to study the behavior of autonomous vehicles.
I have written a small interface between TORCS and MATLAB such that I can I can prototype my algorithms quickly and I have come across a small problem. The 'tdble' type used by TORCS is defined as a float, which for the majority of parameters makes sense but when working with the vehicle positions I have found some numerical errors creeping in to the integration inside SimCarUpdatePos (in car.cpp). The issue comes about when two vehicles have very similar (but not identical) velocities, which when integrated with the position get truncated to be identical. This has the effect that computing the distance between two vehicles returns a constant value (as the velocities are being made identical). I have attached a plot illustrating the bug, it shows the computed distance between two vehicles (one following the other with near identical velocity) when the lead vehicle brakes.
At first I thought I could simply change the definition of tdble to double and this would solve the problem, but it seems that tdble is not used consistently through the source, so this caused more problems! In the end I modified the structures a little to simply have the position values represented as double (in addition to the tdble values, for compatibility) and leave the rest untouched, this has solved the problem (but is not elegant!).
I appreciate this is an edge case which will only crop up very rarely, but if you'd like me to share my changes with you (or if you have a more elegant solution!) please let me know.
Dr Owen McAree
Department of Automatic Control and Systems Engineering
University of Sheffield, S13JD
T: 0114 222 5138
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
Torcs-devel mailing list
Torcs-devel <at> lists.sourceforge.net