Homepage

I'm sick so here's a devlog on throttle maps

I can’t say I have opinions as strong as Niels Heusinkveld on throttle maps in racing sims, although I do sympathise with his raging passion against lazy design for things that really aren’t complicated. And I’m sick, having been up all night, unable to sleep, so let me present a quick and dirty example of how to do a fancier throttle input than lerping peak torque to engine braking as nearly every sim does.

My take:

Watch Niels' video here to understand what the problem is. I’m in two minds about calling it a problem, partly because we’re talking about games where we can map the controls however we see fit as we play god with race cars, so it doesn’t totally matter. A 0-100% scale of how much torque you demand as a driver is easy to comprehend and makes learning and troubleshooting within the realm of the sim easy. On the other hand, he makes a lot of good points about how this would actually improve handling and require driving style changes, but typically would improve the way a car drives. I won’t bog down this explanation by repeating his words, but he most succinctly covers why having a more accurate throttle map would benefit a sim here.

That all being said, I quite like the idea of including this in my own vehicle model, mostly because the way you can hold partial throttle, increase speed and yet lose torque sounds like another layer of stability. I fell across this topic while trying to research procedural power curves, which somehow landed me on this BeamNG post, which is useful for the example graphs. The best I’ve got so far is by buggering a sine wave, which as a proof of concept works, but I’m not a fan of it so I’ll be replacing it whenever I figure out something better.

Anyway, throttle maps. My immediate idea was based on the fact a throttle limits mass air flow, and theoretically maximum mass airflow should be at redline. You get exceptions, but only if the engine’s been poorly designed and is wasting its own flow. And we’re making up numbers anyway. Since the sleepless night where I started writing this I’ve since reworked my ideas a little, so this isn’t a raw first draft.

This is the end result, including a comparison to the traditional “throttle is a % of torque” system of usual at 50%:

And here's a more minimalist version focused on 50% throttle:

None of these numbers are necessarily connected to reality, but as a starting point it’ll do. I’ll have to dig up some data to fudge the curves to be more accurate (if I even care, I’m not desperate to match all the details but this looks like it’ll help driveability)

Next, minimum throttle to make maximum torque. I tried a few combinations of torque and rpm, but settled on the very simple:

minimum throttle = (current rpm/maximum rpm)^M

where M is a letter I’ve plucked out the air to mean modifier for fiddling with exponents.

Yeah, it’s basic and doesn’t really shape like it probably should, but as a starting point it probably works. Chucking an exponential modifier for testing usually does’t hurt, at worst, you can leave it at 1 and forget about it. I think I prefer this slightly above 1, as it makes the partial throttle conditions peakier.

Then torque for a given throttle position and rpm is simple:

engine torque = if(throttle > minimum throttle, 1, throttle/minimum throttle) * (Tmax-Tmin) + Tmin

Where Tmax is the torque at 100% throttle, and Tmin is torque at 0% throttle, for a given rpm.

I’d like to rework this more. Ideally I want to design somewhat of an engine generator for whatever sim I’m using, not necessarily baked in reality but something to draw curves and create choke points due to exhaust or intake design that shifts the curves about. But I haven’t had any great ideas for where to even start with that.

Testing:

All my testing within my “sim” (try it here! Although as of writing it doesn’t have this new throttle map) has been done using a lazy as you like constant driving torque. As part of this throttle map update, I’ve changed the torque curve to use this to produce torque at 100% throttle:

100% throttle torque = sin(rpm/Wp * pi/2) * (Tp - Tz) + Tz

where Wp is the rpm where peak torque is produced, Tp is the peak torque, and Tz is the torque at 0rpm.

The engine braking curve is just a lerp from point to point with an exponent to curve it a little. Nothing fancy.

0% throttle torque = (rpm / maxrpm)^M2 * (Ep - Ez) + Ez

Where M2 is another arbitrary modifier variable, Ep is the maximum engine braking torque, and Ez is the engine braking at zero rpm.

I'm only including this for the sake of completeness and documentation, as I don't think these curve methods are particularly special or useful.

In my previous attempt at a driving “sim” in Unity I was amazed at how sluggish going from constant torque to anything with any sort of peak felt. To compensate this time, and to exaggerate throttle control, I cranked torque from 300Nm to 1000Nm for testing. The car’s quick, and spins the tyres up easily enough, but I should probably think about redesigning my test course to be a little more open, with some more furniture around the course for judging braking and comparing throttle application points. Applying the new throttle to torque demand mapping in my “sim” was incredibly easy. But I didn’t feel the sort of benefits I was hoping for, although that's not necessarily a surprise. There’s a few million reasons why that could possibly be, from the fact I’m more used to the old style the throttle, the way I’ve refined and balanced the car, to the way I’ve set up this new throttle map system. So I’m not going to write off this more realistic approach but first impressions suggest it isn't easier to drive like this, or more enjoyable.

Testing a more aggressive torque dropoff does improve things, so I’m going to keep trying to refine this concept. I've got Heywood's book on internal combustion engine fundamentals, and I haven't really dug into it yet. Maybe there's some juicy info on throttle mapping in there?