How to apply a force via python to a rigid body wheel
I just got it working myself.



The solution is the motor constraint. Using the motor constraint alone, the vehicle will fall apart. Thus you have to add another constraint between each vehicle and the body - a hinge constraint to only allow rotation.

Thus the complete setup looks like this


Create the vehicle (body and 4 wheels as seperate objects)
Create a Hinge Constraint between each wheel and the body (I used an empty for it - take care of the right rotation)
Create a Motor Constraint between each wheel and the body (Angular movement - I used an empty for it - take care of the right rotation))


Now you can check out the context menu of the angular velocity. There you can find the option "Copy Data Path". This will copy the relative property path of the object to use it withing your scripts



Then you can use it for example like this

constraints = [bpy.data.objects['fl'], bpy.data.objects['bl'], 
    bpy.data.objects['br'], bpy.data.objects['fr']]

for c in constraints:
    c.rigid_body_constraint.motor_ang_target_velocity=5 
    c.rigid_body_constraint.motor_ang_max_impulse=100