# Forums

Full Version: mathematical model of vdrift cars
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone,

I'm interested in the mathematical model of the cars of VDrift. That means i.e. how is the engines torque, the braking force, etc. calculated out of the actual velocity, controls and car parameters.
Can I find a (complete) math. model anywhere or do I have to go to the whole code?

Thanks,
flo
I'd love to have something like that, but unfortunately I don't. :-)

Luckily (?) almost all of the code is concentrated in cardynamics.cpp. You can probably follow it through OK, but let me know if you have questions.
Okay, I'm trying to create a nice diagram to get an overview about the car model and also a description of equations with example parameters of two cars, to get an idea about the functionality in detail.

Can you tell me, how the crankshaft speed is calculated, which means the engines angular velocity?
And why does the added clutch torque to the crankshaft torque, has to be negative?
Crankshaft speed is simulated in carengine.h with the ROTATIONALFRAME object. Torque is applied to the crankshaft from combustion, internal friction, and the clutch. The crankshaft position is updated with the calls to Integrate1() and Integrate2().

The clutch torque is negative by convention (so no real reason). The difference between the clutch speed and crankshaft speed generates equal and opposite torque on the engine and clutch output, so I had to pick one value to be negative and one to be positive.
I do know understand, that the clutch torque is an opposite torque and I imagine it as a drag torque, depending on the difference of crankshaft and clutch.
But if the clutch torque gets bigger than the crankshaft torque or lets say we have no crankshaft torque at all (throttle = 0), the torque is set to -max. clutch torque and hence car accelerates anyway ( because of two negative signs ).

Are there any mistakes in my thoughts or do I just don't get the physics behind that effect?!?
Here's how everything is connected together:

engine --- crankshaft --- clutch --- transmission --- driveshaft --- wheels

The engine is simulated as a rotating body with inertia and the wheels are simulated as rotating bodies with inertia. The crankshaft is always spinning at the same speed as the engine, and the driveshaft is always spinning at the same speed as the wheels. Let's also assume that the transmission is in a forward gear that has a 1:1 ratio, so we can ignore it.

Quote:But if the clutch torque gets bigger than the crankshaft torque or lets say we have no crankshaft torque at all (throttle = 0), the torque is set to -max. clutch torque and hence car accelerates anyway ( because of two negative signs ).

Correct me if I misunderstand your statement, but you're saying that the engine is at idle but the wheels are rotating like the car is moving backward, right? Let's assume that we had the clutch disengaged and then we rapidly engage it. In that case, the torque at the crankshaft from the engine is zero, the torque at the driveshaft from the wheels is negative, so the clutch causes the wheels to get positive torque and the engine to get negative torque, which pushes the car forward a little and slows the engine (probably killing the engine). This makes sense if you think about it.
No, that was not what I meant.

If you look at the equation in clutch.GetTorque (in carclutch.h):

new_speed_diff = engine_speed - drive_speed

There is on the one hand the engine speed, calculated from modified euler method in rotatinalframe and on the other hand the driveshaft speed computed "backwards" from the wheel speed over transmission to the clutch. The difference is multiplied with the maximum force at the clutch, which leads to a friction force. But this result is only active if new_speed_diff is between (-1, 1), elsewise the friction force is set to (-max_force) respectively (max_force). So if the current drive_speed is bigger than the engine_speed+1(both forward speed), you get in return -max_force, which in turn is getting positive because of the minus at the total torque.

total_torque = combustion_torque + friction_torque - (-max_force)
(with max_force from clutch)

What I meant in the last post was, you are driving with forward speed, but without use of the throttle at the moment you get something like this.

total_torque = 0 + (-small_friction_value) - (-max_force)

And the engine would accelerate because of the high torque from the clutch, without any use of the throttle.
So in my opinion, the clutch.GetTorque function only make sense, if new_speed_diff is really small and engine_speed is bigger than drive_speed, than you can see it additionally friction force.

I hope I made my problem more obvious this time :-p
flo Wrote:new_speed_diff = engine_speed - drive_speed

There is on the one hand the engine speed, calculated from modified euler method in rotatinalframe and on the other hand the driveshaft speed computed "backwards" from the wheel speed over transmission to the clutch. The difference is multiplied with the maximum force at the clutch, which leads to a friction force. But this result is only active if new_speed_diff is between (-1, 1), elsewise the friction force is set to (-max_force) respectively (max_force). So if the current drive_speed is bigger than the engine_speed+1(both forward speed), you get in return -max_force, which in turn is getting positive because of the minus at the total torque.

total_torque = combustion_torque + friction_torque - (-max_force)
(with max_force from clutch)

What I meant in the last post was, you are driving with forward speed, but without use of the throttle at the moment you get something like this.

total_torque = 0 + (-small_friction_value) - (-max_force)

Yes, this is all correct.

Quote:And the engine would accelerate because of the high torque from the clutch, without any use of the throttle.

Yep! That's right. That's how it's supposed to be. If the wheels are moving faster than the engine, the clutch friction will cause the engine to speed up. This happens every time you downshift.

Quote:the clutch.GetTorque function only make sense, if new_speed_diff is really small and engine_speed is bigger than drive_speed

No, I disagree. I think the crucial idea you're missing is that the friction from the clutch is relative. Any time one side of the clutch is spinning faster than the other side, you'll get friction. Depending on which side is spinning faster determines the sign of the friction. If the engine speed is faster than the driveshaft, the clutch friction will generate torque to slow the engine and speed up the wheels. If the engine speed is slower than the driveshaft, the clutch friction will generate torque to speed up the engine and slow the wheels.
Okay I got it!

Another question:

What does the friction_factor in the Pacejka formula do (cartire.h)?
I didn't find it neither in Beckman's paper, nor in Gentas book - so where do you have it from?
It's a simple multiplier that gets set depending on what surface the car is driving on. A grass track surface could be set to 0.5 times friction, for example, which would cause the tire to only generate half the usual forces. It's not a very good way to model real off-road driving but it works well enough for when a car goes off the track accidentally.
joevenzon Wrote:It's a simple multiplier that gets set depending on what surface the car is driving on. A grass track surface could be set to 0.5 times friction, for example, which would cause the tire to only generate half the usual forces. It's not a very good way to model real off-road driving but it works well enough for when a car goes off the track accidentally.

does this mean that the code will need a little reworking to allow realistic off-road rally type events?

by realistic i mean gran turismo 1 or 2's rally realism. which isn't too realistic, but works
portets Wrote:by realistic i mean gran turismo 1 or 2's rally realism. which isn't too realistic, but works

Yeah, I think VDrift is capable of that with the current system. It'd take more work to get it up to the level of richard burns' rally or dirt, though.