3D Theory - Example - Car Racing Game Discussuion

By: Ian Greenwood - ijaygee
file modelling cars  
2006-07-18 22:35

Hi Martin, 
 
I'm trying to model a racing car as simply as possible. 
 
Initially I was thinking it should be possible to calc forces during braking and turns and apply these to induce skids and slides... I haven't had much success though. Wonder if you have any ideas how to derive the forces? - I got as far as reckoning a turn describes a tangent to the turning circle and the centripetal force acts through the normal to this tangent but putting a value to the force/acceleration is where I got stuck (damned angular momentum no doubt ;) 
 
Next I tried the usual Newtonian method of summing accelerations and resultant velocity vectors but this ended up like driving on sheet ice. Nice for a rally car sim but not a F1 type circuit car. However, it seems obvious all these forces are present in a track car but I'm not sure how to constrain or 'temper' their effects with downforce and grip/traction. 
 
Any ideas? 
 
cheers 
 
Ian

By: Martin Baker - martinbakerProject Admin
file RE: modelling cars  
2006-07-19 03:52

Yes, the force trying to make the car go in a circle and the equal and opposite trying to keep it going in a straight line (centrifugal and centripetal force), have magnitude m v^2/r and direction, as you say, tangential. 
where: 
m=mass 
v = velocity 
r = radius of turn. 
 
The outward force acts on the centre of mass, the equal and opposite reaction acts on the tyre-road surface. 
 
As you say, whether the tyre skids, or not, depends on a lot of factors: friction on tyre-road surface, downforce, heat, wheel spin, bumps in road, etc. 
 
Another thing that needs to be modelled is the torque caused because the above action and reaction are at different heights. This tries to rotate the car so it goes round the corner on two wheels, or at least causes different downforces on the inner and outer wheels. 
 
The other factor is the suspension of the car, this is complicated as you can see from the Angular Momentum thread, I don't know if danske can give any further insights? (if my earlier messages have not caused too much exasperation!) 
 
It looks like this subject is of interest to a lot of people, so I would welcome any information about what approaches work and what doesn't, I will try to put any information you can give me on the website to help others. 
 
Martin

By: Danske - danske
file RE: modelling cars  
2006-07-19 08:09

Turn back while you still can! ;) 
 
Modelling a car as simply as possible would be removing the third dimension. You might still model the third dimension but might ignore any torques that cause the car to pitch or roll. If you don't allow pitch and roll it won't behave so very realistically, but it's simple. 
 
The trick is how tires behave. They have variable friction, basically. They have partially static friction and partially kinetic friction as they roll along with their non-solid bodies, deforming with contact with the road and partially sliding and partially sticking. Go search up "Physics of Racing". 
 
Simple-ish summary: 
You could look at a tire as a three-dimensional spring. If it's deformed from its zero-force point it will exert a force between the road and the wheel. The problem is that as it rolls along this "relaxes" the deformation. This is easier to visualize in the lateral direction. If the bottom of the tire is displaced to one side, it's obviously pulling the wheel to that side just like a normal spring. But even if we keep the wheel from moving laterally, as the wheel rolls the tire will relax, moving back to directly under the wheel. You can see that this must be true in that the top of the tire not in contact with the ground has zero lateral displacement and without anything providing a sideways force and movement it will have no sideways displacement when it gets to the ground. Longitudinal displacement works the same. Thankfully, axial displacement (toward the axis) is just air pressure and can be measured as a spring just from the center of the wheel and that doesn't change as the wheel rotates (although the tires do expand as they rotate as seen in drag racing). 
 
Maybe that's already too complex even if it's just theory. :) 
 
The short summary is that the tire "spring" provides no force without a displacement, and rolling along the ground relaxes this displacement. To keep a constant force the tire must have a difference in velocity with the ground to keep "pulling" the spring away from the zero point as the rolling relaxing it. 
 
Aha, maybe you can relate this to skiing. You have to turn the ski sideways to the velocity of the ground to have any force. Similarly for tires. To get a lateral force you have to turn the wheel sideways to the velocity of the ground. For a longitudinal force you must speed them up (acceleration) or slow them down (braking). 
 
The upshot is that mathematically near the zero-force point the force from the tire behaves as the sine of its velocity relative to the ground. It's nearly linear near zero and "flattens" off to maximum grip. Past that it decays down to completely kinetic friction (locking the wheels under breaking, car completely sideways, smoking burnout). The lateral velocity component is proportional to the angle at which the wheel is turned, and the longitudinal the ratio between the rate the wheel is spinning at and the linear velocity of the wheel. 
 
Oh, and that's really how you determine the tires coefficient of grip. The force is then the "weight" on the tire multiplied by that. 
 
Now since the ground exerts a force on the tire (and the tire on the ground, but the ground isn't going to experience any noticable acceleration from that), and the tire on the wheel (and wheel on the tire, but we consider the tire more or less massless), and the wheel on the car, if you don't want to model the physics of the rotating wheel then you have to make some shortcuts. 
 
The linear and rotational velocities of the car determine the range of forces the tires could possibly provide. At zero braking/engine force (torque on the wheel) you'll have only lateral force as given by the slip angle from the steering angle of the wheels. You can apply more longitudinal force up until the maximum total force from the tire is reached, after which the tire is slipping more than it's gripping, and the coefficient of "grip" decreases. 
 
So in a practical example: let's begin with a car travelling at a constant velocity and heading (orientation) such that it's pointed in its direction of travel, zero angular velocity, and wheel rotation rates such that the linear velocity of the tire's contact patch matches groundspeed (i.e. the wheels are neither rotating too fast nor too slow). If you steer the front wheels to the right then you've introduced an angle between the wheel and the ground velocity. This causes a lateral force at the front end of the car which results in both linear and rotational acceleration for the car. As the car rotates this introduces a slip angle for the rear tires, and they provide a lateral force which increases the cars linear acceleration and decreases its angular acceleration (to zero once you've reached a constant turn). 
 
So as the car travels in a constant circle the tires at it's four corners are not pointed in the direction of their travel (think skiier's skiis). In a gentle turn they'd all be pointed at a small angle (say one degree), while near maximum grip they'd be at more like ten degrees. 
 
Well anyway, the four tires provide separate forces which must be summed to give total torque and force. There's a maximal force vector (direction and magnitude) they can provide for any given steering angle. You could keep track of the wheel's rotational velocity and acceleration as given by the torque both the tire and the car (engine/brakes), but to keep things more simple you might just say that if matching the torque from the car with torque from the tire would exceed the maximum grip of the tire then you just increase the slip ratio (longitudinal difference in velocity with the ground) of the tire at a rate proportional to the difference in the two torques. Hmm...I guess that is just distilling out the angular acceleration on the wheel. 
 
Anyway, the tangential-to-the-road forces from the four tires depend primarily on how fast the wheels are rotating, their steering angle, and the linear and angular velocity of the car, and the normal force between the tire and road (which is a constant if we neglect the third dimension). 
 
"Physics of Racing" 
http://phors.locost7.info/contents.htm 

By: Danske - danske
file RE: modelling cars  
2006-07-19 12:06

Oh, I think there's a reference to a very simple 2D simulator in "Physics of Racing". IIRC, it was a very simple model for use in competitive programming. It might be a little too simple, though. I don't know if it allowed for the "cars" getting completely out of control and spinning around.

By: Danske - danske
file RE: modelling cars  
2006-07-19 17:48

Ah, here's the decendent of RARS: 
http://torcs.sourceforge.net/ 

By: Ian Greenwood - ijaygee
file RE: modelling cars  
2006-07-20 02:15

Martin/Danske, 
 
Cheers guys. 
 
The PhsOR articles are fantastic. - I see where you got the sinusoidal response for the tyres now. Brilliant stuff. 
 
I've already tweaked a few bits in my sim and its starting to behave more like I hoped. 
 
Many thanks for the links and info. 
 
No doubt I'll be back if I get stuck, otherwise I'll post any interesting info for the dynamics pages...(don't hold your breath though ;) 
 
 
Ian


metadata block
see also:

 

Correspondence about this page

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.