![]() |
![]() OCAU News - Wiki - QuickLinks - Pix - Sponsors |
|
|||||||
| Notices |
|
Sign up for a free OCAU account and this ad will go away! Search our forums with Google: |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Member
Join Date: Dec 2001
Location: Melbourne
Posts: 1,392
|
Me and my little car game again
I've finally got myself some torque curves, but I'm having a problem with accelerating my car. It seems that it hits it's highest speed if first gear, and then slows down when you change up... All values are for an Audi 1998 A8 Here is my code:Set up all car values: Code:
corvette.cartype.GearRatio[1] = 3.570f; corvette.cartype.GearRatio[2] = 2.200f; corvette.cartype.GearRatio[3] = 1.500f; corvette.cartype.GearRatio[4] = 1.000f; corvette.cartype.GearRatio[5] = 0.800f; corvette.cartype.Diff = 2.73f; corvette.cartype.Mass = 1792; corvette.cartype.WheelRadius = 0.4f; corvette.rpm = 1000; corvette.gear = 1; corvette.vel = 0; Code:
int MoveCar(CAR &car, float delta)
{
float max_torque, engine_torque, drag, friction;
max_torque = car.cartype.Torque[(int)car.rpm]; //Get max torque at a given RPM
engine_torque = max_torque * (car.throttle / 100); //Multiply it by throttle position
drive_force = engine_torque * car.cartype.GearRatio[(int)car.gear] * car.cartype.Diff * corvette.cartype.WheelRadius * 0.7f; //Calculate drive force
drag = - CDrag * car.vel * ABS(car.vel); //Calculate Drag
friction = - CFric * car.vel; //Calcualte Friction
car.force = drive_force + drag + friction; //Find sum of forces acting on car
car.accel = car.force / car.cartype.Mass; //F = m / a, to find acceleration
car.vel = car.vel + car.accel * delta; //calculate car velocity using v = u + at
car.rpm = ((car.vel / corvette.cartype.WheelRadius) * car.cartype.GearRatio[(int)car.gear] * car.cartype.Diff * 60) / (2 * (float)PI); //Workout RPM off new speed, for next set of calculations
if (car.rpm < 1000) //Make sure RPM doesn't go under engine idling RPM
car.rpm = 1000;
return 1;
}
const float CDrag = 0.4257f; const float CFric = 12.8f; I got these values from http://home.planet.nl/~monstrous/tutcar.html Any suggests would be a great help.
__________________
"One good thing about music, when it hits you, you feel no pain." - Bob Marley OCAU Guitar Players Club OCAU Magic Club Last edited by BAC :S; 12th September 2002 at 10:40 AM. |
|
|
|
| Join OCAU to remove this ad! |
|
|
#2 |
|
Member
Join Date: Mar 2002
Location: Gosford
Posts: 1,950
|
Well, when your going up a steep hill 1st gear is actually the fastest gear in some cars, the rest are unable to overcome the force of going up the hill.
I think you have a similar problem as you have probably made your drag and friction constants too high. |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2001
Location: Adelaide
Posts: 73
|
I would suggest you have units wrong somewhere. If you are reaching maximum speed in first gear this means that the torque of the engine multiplied by your gearing is more than your friction and drag ONLY in this gear. So, check your CFric and CDrag units, your CFric units in particular look too high to me. Of course your units for these may be fine and your units for your car force / gear ratio things may be screwed. But as an engineer, I would say UNITS UNITS UNITS!!!
|
|
|
|
|
|
#4 |
|
Member
Join Date: Dec 2001
Location: Melbourne
Posts: 1,392
|
I found one little mistake (that makes a fair difference)
![]() drive_force = engine_torque * car.cartype.GearRatio[(int)car.gear] * car.cartype.Diff * corvette.cartype.WheelRadius * 0.7f; This should be: drive_force = engine_torque * car.cartype.GearRatio[(int)car.gear] * car.cartype.Diff * 0.7f / corvette.cartype.WheelRadius; Your supposed to divide the wheel radius, this gives a fair bit more drive force to overcome the drag. Now the car makes it to 3rd gear, but when you change into 4th it starts slowing down ![]() The only problem is when I lower the friction, and drag the car goes to quick. At the lowest friction and drag that I can get the car into 5th gear its going about 360 km/h, and really the car only has a top speed of about 205 - 210km/h. Also, this makes the car take ages to slow down when there is little drag. As for my units: mass - kgs speed - m/s drive, drag, friction forces = N(ewtons) so I think they are all right?
__________________
"One good thing about music, when it hits you, you feel no pain." - Bob Marley OCAU Guitar Players Club OCAU Magic Club Last edited by BAC :S; 14th September 2002 at 9:50 AM. |
|
|
|
|
|
#5 |
|
Member
Join Date: Mar 2002
Location: Gosford
Posts: 1,950
|
You could put in some engine friction.
ie. an engine at 6000rpm will have more friction than an engine at 2000rpm This means that it will be better to go into a higher gear with low RPM |
|
|
|
![]() |
| Bookmarks |
|
Sign up for a free OCAU account and this ad will go away! |
| Thread Tools | |
|
|