Jump to content
  • Advertisement
tbeaugelin

Unreal Accurate (& realistic) way of accelerating an engine

Recommended Posts

Posted (edited)

Hello everyone !

I have as a project to create a car simulation inside of UE4. So far so good, I have suspensions working, alongside with wheels spining & direction.

I would like to know what would be the most realistic way of making the car accelerate. I have read a bunch of post all around the internet, but never found answers to my questions. So here I am. Basically, I know that I can approximate acceleration with my 0-1 value of throttle (1 being maxium RPM the engine can handle), but, correct me if I'm wrong, in a real car, pressing the pedal to the max does not, in fact, make the engine rev at it's highest point. It increase the speed at wich the engine rev. If my gas pedal is pressed at 1/10 of it's full course, with no gear engaged, it will make the engine go to it's highest point, but slowly. Instead, if i pressed my gas pedal to 8/10 of its full course, I will "accelerate" my engine faster.

So my question is how to simulate this the most accuretly possible ? Let start with this, without speaking about gear, friction and loss. Basically, I'm in neutral, and press my gas pedal. How would you simulate this behavior ?

If anyone is interested in seeing how this project goes, i'll post updates on my youtube channel, and a quick preview of what I already have can be found here : https://youtu.be/dCdARHeV3Tk.

 

EDIT: Sorry if my english is not that good, I try my best (Its not my native language)

Edited by tbeaugelin

Share this post


Link to post
Share on other sites
Advertisement

Hi,

6 hours ago, tbeaugelin said:

I would like to know what would be the most realistic way of making the car accelerate

A realistic way involves a lots of things, like clutch, gearbox, differentials and the tyre itself.

6 hours ago, tbeaugelin said:

I know that I can approximate acceleration with my 0-1 value of throttle (1 being maxium RPM the engine can handle), but, correct me if I'm wrong, in a real car, pressing the pedal to the max does not, in fact, make the engine rev at it's highest point. It increase the speed at wich the engine rev. If my gas pedal is pressed at 1/10 of it's full course, with no gear engaged, it will make the engine go to it's highest point, but slowly. Instead, if i pressed my gas pedal to 8/10 of its full course, I will "accelerate" my engine faster.

I'd say you can map the 0-1 pedal input to a torque output that accelerates the whole thing. The RPM is kind of calculated value, a result of the simulation.
Also the 10% throttle will not necessarily rev up to the maximum, just until the engine torque and the friction balances.

 

As I saw in the video, your car is moving nicely, and it reminds me to my first fake driveline I made about 5-6 years ago. As I remember, I directly applied some acceleration on the wheels (depending on engine RPM, current gear and throttle position);

Something like:
ang_vel = FreeRollingAngVel() * magic_number

the magic_number was a scaling value that increased/decreased the current rotation speed. Then I calculated the wheel speed back to the engine. Somehow it worked so convincing it took me years before I implemented the real thing :)
 

6 hours ago, tbeaugelin said:

Let start with this, without speaking about gear, friction and loss. Basically, I'm in neutral, and press my gas pedal. How would you simulate this behavior ?

For this specific case (engine with clutch disengaged).
You have a throttle position 0..1
And the current engine RPM.

You'll need an engine torque curve, that is the torque at a specific RPM at full throttle, this way you can query the output torque at the engine's current RPM. You can have an other curve for engine braking, but that's not that relevant now.
So, you can simply multiply the looked up value by the throttle, or blend engine vs friction torque using the throttle position.

Now you have the torque that accelerates the flywheel, for this you need the flywheel inertia, integrate it over time, and you are done.

t_engine = GetEngineTorque(engine_rpm)
t_brake = GetEngineBrakeTorque(engine_rpm)
t = Lerp(t_brake, t_engine, throttle)  // or just t = t_engine * throttle

ang_acc = t / flywheel_inertia
ang_vel += ang_acc * dt

engine_rpm = AngVelToRPM(ang_vel)

or something similar :)

Share this post


Link to post
Share on other sites
Posted (edited)

So actually you need to simulate a real car, you take the mass the shape of vehicle (for drag) you calculate mass distribution alongside vehicle model, you need to know the size of gears and num of teeth etc. Then you can start to simulate it by engine >> that cylinder that connects it to the wheels lol....

Knowing the gear calculations formula you can calc actual forces that act on center of wheels, by that you need to access friction values of tires to see (and ground) to see how actually the veh will behave during movement, by calculating all push forward forces (not to mention that it can be different for each wheel connected to the motor), drag/friction forces acting on each wheel you may to start thinking of somethinhg related to car sim, but first youll need actual real data to work on.....

Not to mention that you can increase drag during gear change...

Edited by _WeirdCat_

Share this post


Link to post
Share on other sites

I'm kind of spitballing here but I would try to do something like have a function for a given engine that takes current RPM, engine load, and throttle position and spits out a value for change in RPM.  Then you can feed in other functions to that functions, that gives you engine load for a given car, gear, and speed.

Every engine will be different. For  instance I remember when I used to mess with cars , you could drop in a radical cam and it would give you good top end HP, but at lower RPM it was better to have a milder cam, for off the line acceleration.  These days newer cars have all the fancy hardware that can change lift and duration of your valves based a number of factors.

Share this post


Link to post
Share on other sites

Okay, so, after a lot of work, I'm starting to get something.

Following this: http://www.asawicki.info/Mirror/Car Physics for Games/Car Physics for Games.html and something else I can't seem to find anymore, I was able to pull something nice and sweet :)

Also, new question, since Air Resistance is tied to Speed² (Fdrag =  0.5 * Cd * A * rho * v), is it normal that I get crazy high values ? Speed is supposed to be in m.s-1 right ? (Values can be seen in green in the video, top left corner)

The RPM are for the moment directly tied to the wheel RPM, and therefore, not increasing in Neutral. My question is now, how would I "reaslisticaly" simulate the increasing in neutral (or clutch fully disengaged).

Here is a small video showing the progress (RPM can be seen top left corner, in purple). Also added camber to the tire, changing the car behavior as expected ^^

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

It sounds like you need to model the drivetrain and use that to 'transmit power' to the wheels as a separate concept. You'd need to track things such as:

- Is clutch engaged (not necessarily true or false, a value between 0 and 1 similar to throttle would allow you a simplistic approximation of a slipping clutch)

- Which gear is selected (R, 1, 2, 3, 4, 5, 6, Neutral). Each gear would have a ratio which changes the engine RPM to wheel RPM. I believe 4th gear is usually a 1:1 ratio. Neutral would be 1:0, R would return a negative rotation (negative relative to whatever your 'forward' direction is)

- The above model ignores the idea of 'final drive'

Going further you might model

- Inefficiencies in the powertrain 

- The differential

And probably many more things I'm missing.

Edited by marclurr

Share this post


Link to post
Share on other sites
Posted (edited)

Concerning the clutch, that's already what I had in mind, in a first time, have a Float between 0 & 1 that could induce slipping clutch.

I already have different ratio for the different gears, and also Final Drive in my calculations.

What I'm asking for is, everything is working more or less the way I want it, except when I'm in Neutral. I can't rev my engine in Neutral, and I'd like to know a realistic way of increasing it while in Neutral (or clutch disengaged), and not with "My throttle can go from 0 to 1, so while in neutral, my throttle value is the alpha of lerping between IDLE & Max Rev" thingy.

For the moment, my Torque delivred to the wheels is:

DeliveredTorque=(TorqueAtRPM(Curve)*FinalDriveRatio*CurrGearRatio/Radius)-(RollResistance*Mass*GravityScale)-(0.5*AirDrag*FrontArea*AirDensity*Velocity²)*ThrottleValue

All of this comes from Marco Monster Tutorial & another tutorial I found but can't rember it anymore.

So bascially main question, how to realisticaly rev engine at Neutral (Or Clutch disengaged) ?

Thanks all for the reponse !

EDIT: Oh yeah, I forgot, I also have Torque Bias integrated, alongside with Brake Bias (Torque & brakes repartitions between front & rear wheels)

EDIT 2: Since I can't edit my older post, here is the link to the actual progress of the project (previous video had FPS issues) https://youtu.be/YWM_XUUP3jQ

Edited by tbeaugelin

Share this post


Link to post
Share on other sites
On 4/15/2019 at 10:11 AM, tbeaugelin said:

Also, new question, since Air Resistance is tied to Speed² (Fdrag =  0.5 * Cd * A * rho * v), is it normal that I get crazy high values ? Speed is supposed to be in m.s-1 right ?

Speed should be in m/s. Also yes it can go high. At higher speed the majority of slow-down factor comes from air resistance.

On 4/15/2019 at 10:11 AM, tbeaugelin said:

The RPM are for the moment directly tied to the wheel RPM, and therefore, not increasing in Neutral. My question is now, how would I "reaslisticaly" simulate the increasing in neutral (or clutch fully disengaged)

In this case you would only accelerate the engine/flywheel. But as @marclurr wrote if you want the clutch to slip you need more sophisticated drivetrain simulation.

The clutch could be a 0..1 value and you'd need the max torque that the clutch can deliver. Since the clutch can lock when the pedal is half way down, and also can slip even when you don't touch it (in extreme cases)

So just multiply the pedal value by the clutch max torque, and if the torque coming from the engine is greater then it slips, otherwise it locks. The clutch is always trying to match the speed of the engine and the transmission.
That means, if the clutch slips its friction torque slows down the engine and speeds up the wheels, and as soon as their speed "match" the clutch is locked.

So to answer the original question the clutch is pressed, the max torque is 0.
It only accelerates the flywheel, like;

acc = GetEngineTorque(RPM) / FlywheelInertia
EngineAngVel += acc * dt

On 4/16/2019 at 6:44 AM, tbeaugelin said:

DeliveredTorque=(TorqueAtRPM(Curve)*FinalDriveRatio*CurrGearRatio/Radius)-(RollResistance*Mass*GravityScale)-(0.5*AirDrag*FrontArea*AirDensity*Velocity²)*ThrottleValue

I feel some disturbance here. You are mixing the forces and torques which are not good friends in the same equation :)

The engine torque goes to the wheels that generates wheel rotation that goes to the tire formula that gives friction force that you apply on the rigid body.

The air resistance is a force that you have to apply directly on the body. The CG is a good start.

In the video the resistance seems way too high!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!