If you want to get total movement of the car depends on the wheel:
Under an ideal state (ignore air resistance, any friction, vertical rotation of the wheel, ...)
$$ d_{istance} = 2r\theta^c $$$$ d_{istance} = 2r\theta^r $$ where $r$ is radius of wheel, $\theta^c$$\theta^r$ is total radians of the wheel.
In python expression:
oj = bpy.data.objects["wheel"]
rotation_euler = oj.rotation_euler
di = oj.dimensions
# suppose wheel rotation in x axle, wheel thickness less than diameter
# So your driver expression should be:
max(di.x, di.y, di.z)*rotation_euler.x
If you want to get total rotation according to the car travel distance: first you need get the total distance:
suppose the car control by keyframe, here is the script to get the total travel distance:
import bpy
car_name = "Cube"
start_frame = 1
last_frame = 60
current_frame = bpy.context.scene.frame_current
oj = bpy.data.objects[car_name]
loc = oj.location
travel = 0
bpy.context.scene.frame_set(start_frame)
last_loc = loc.copy()
for r in range(start_frame + 1, last_frame + 1):
bpy.context.scene.frame_set(r)
travel += (loc - last_loc).length
last_loc = loc.copy()
print("Travel: ", travel)
bpy.context.scene.frame_set(current_frame)
So, the driver expression of the wheel if the car have a constant speed:
travel/diameter*frame/last_frame