Friday, March 21, 2014

Car engine

I like car racing simulations. I spent a lot of time playing Gran Turismo Prologue on my PS3 years ago. So I thought it would be time for me to try making my own racing game. After coding a Hover Bike and all sorts of Heavy Machinery that should be easy, not?

Well, it turns out to be a lot more difficult than I expected. Just some high school physics will not cut it. The image above is my prototype in action. I'm pleased with the suspension, the steering and the traction models. Most of which you get for free by using the OpenDE physics engine. But how can I create a simulation model for the engine?

OpenDE lets me speed up/dn the wheels by simply specifying:

  • Desired wheel velocity.
  • Torque available to achieve this wheel velocity.
  • Mass of the wheel.
  • Moment of inertia of the wheel.
So how do I go about this? How do I determine what speed the wheel wants to turn, and how much torque is available for this?

In real life, things are more complicated. The engine primarily speeds up the fly wheel, not the car wheels. Depending on the state of the clutch, the gearbox, it will result in wheel acceleration. Do I need to model a flywheel in my simulation? And somehow transfer kinetic energy between flywheel and car wheels depending on clutch and gearbox? How does the accelerator fit in here? And what about the torque curve of the engine, and the rpm of the engine? I am beginning to think a few simple equations are not going to suffice.

How does the accelerator affect the engine RPM? Well, that depends on engine load. How do I calculate that? It seems that there is also a circular dependency in here somewhere:

With an engaged clutch, you can only increase wheel velocity if you increase engine RPM. But engine RPM can only go up if wheel velocity goes up. I think I need to study up on what is actually engine load, and how I can measure it in my sim.

3 comments:

  1. By the way, acceleration in Little Crane sim was much simplified. I simply adjust the wheel velocity towards the accelerator setting with limited (but constant) torque available to do this. There is no gear box, no clutch, no rpm (other than sound effect where engine rpm and loudness go up by low-pass-filtered accelerator setting.)

    ReplyDelete
  2. At its most basic, the drive train is made out of metal, and therefore acts like a spring. If we ignore the gearbox and clutch for a tick, we imagine the energy the wheel rotation has (and the inertia of the vehicle, etc) as one end of the spring, and the energy the engine is producing as the other end of the spring.

    Hooke's spring law then tells us how much engine force gets applied to the wheels, and vice versa. If the spring extension length gets too high, you can make the clutch slip, or the engine throw a piston, or one or more tyres can overcome friction (depending on how elaborate your diff is), or whatever you feel needs to happen.

    That way, the accelerator is just another force acting on one end of the spring.

    One problem though, is that this needs to be a *very* stiff spring. Or possibly two springs. Hope that helps :-)

    ReplyDelete