car loses power 'sometimes'

unclepauly

05-10-2006 13:21:22

hello,

i have implemented a torque curve and a gear box for my car, and i can achieve good speeds now. but the problem is that sometimes, when the car gets to a decent speed (it tops at just under 170km/h, but sometimes this happens at roughly 140km/h), its as if the engine cuts out and the car slows down, even on full throttle.

im at a loss because sometimes this happens and sometimes it doesnt. i have set friction between my tries and the world, and like i say i am not directly adding torque, (i have seen another thread similar where the guy was adding torque directly).

my terrain is a box.mesh scaled hugely so i have a completely flat terrain, so its not like im going uphill or anything. i just hit the throttle, theres no steering involved, i just drive in a straight line to monitor the top speed. thats when i noticed this problem.

if someone has any idea what the hell is going on i would be most grateful to hear from you.

thank you.

unclepauly

05-10-2006 14:25:30

in addition, i get the average omega the same way as stunt playground


//get the average omega of the wheels
int count = 0;
Ogre::Real omega = 0.0;
for (Car::CarTire* tire = (Car::CarTire*)getFirstTire(); tire; tire = (Car::CarTire*)getNextTire( tire ) )
{
// get omega
omega += tire->getOmega();
count++;
}

if (count>0) omega /= (Ogre::Real)count;
omega = Ogre::Math::Abs( omega );


i hit a breakpoint in this code when the app first loads up, and i can see 2 of the wheels have a negative omega value, and 2 have a positive omega value. this is before i have hit the throttle, its just the car sitting on the ground.

so does this mean that 2 tires are rotating backwards and 2 are rotating forwards??? and is this related to my origninal problem?

anyone have any idea? :?

unclepauly

05-10-2006 18:09:31

ok, more troubleshooting :roll:

i think both problems are related to the actual car setup itself. if i cut out all the code in the userCallback function, just leaving tire->upDate(), and run the app, the car sits perfectly on the ground, and then after a few seconds its starts spazzing out, and jumping up and down/moving around on its own. i have tried making the car/tyres heavier, and i am setting setMassMatrix(mCarMass, inertia*mCarMass). if i change this to setMassMatrix(mCarMass, inertia) its gets even worse, and if i do something like setMassMatrix(mCarMass, inertia*mCarMass * 2) it AVs after a couple of seconds :shock:

unclepauly

05-10-2006 20:06:21

looks like i am the only one posting today :wink:

well i played around with the ->centerOfMass function, and if i alter it, the problems remains, but gets worse. so i now am thinking this could be a centre of mass problem. currently the rigid body for my car (which is an Audi TT shape) is calculated using a ConvexHull, like this:


OgreNewt::ConvexCollision* col = new OgreNewt::CollisionPrimitives::ConvexHull(mWorld, mCarNode);
Ogre::Vector3 inertia;
Ogre::Vector3 offset;
col->calculateInertialMatrix(inertia, mOffset);
OgreNewt::Body* bod = new OgreNewt::Body(mWorld, col);
delete col;


then, i set the massMatrix thus:


bod->setMassMatrix(mCarMass, inertia * mCarMass);


and then i set the centreOfMass on the car by using the value of offset returned from calculateInertialMatrix above, like this:


m_chassis->setCenterOfMass(mOffset);


i think this is the correct to way to do it?

so why does my car start moving on its own after a while?

HexiDave

05-10-2006 20:34:37

The only time I had cars spazzing out on me was when I accidently ran over an object that got stuck in the tire's body or set it too low to the ground and the tire was actually inside the terrain's collision mesh.

You should set up some uneven "terrain" (maybe just drop a bunch of heavy blocks onto a plane first) and drop the car on it - if it wobbles on a weird axis, then it's a center of mass problem, most likely. Not sure what to tell you here.

unclepauly

05-10-2006 21:42:08

well i have increased the mass of the tyres to 20 and this seems to have stopped the car spazzing out whilst it is standing still.

but i am still back to square 1: the car gets to a nice speed, then slows down, even though im still on full throttle.

any idea with this one?

i stole the torque curve and gear ratio from stunt playground, so that should be ok.

unclepauly

05-10-2006 23:24:52

is it possible that the mesh itself could be the cause of the problem? because i am now using the GT mesh from Stunt Playground and its fine.

the mesh i am using was a 3dsmax model, exported to ogre. isnt there an option to export to various types of measurement? im sure you can change it so that each unit is either a metre, a centimetre, a yard etc. my project is using SI units, so if the car mesh is using something else, maybe this would cause a hickup.

or maybe im just clutching at straws.

HexiDave

06-10-2006 00:54:58

Well the unit measurements should be relative - each unit is only what you make it to be - 1 meter could be 1 Ogre unit or 0.01 units if you'd like.

You should show the mesh in debug view (think it's F3) to see if the tire is oddly shaped or if there's a vertex somewhere it shouldn't be. Also make sure that you set the meshes up correctly for your tires and suspension - I don't know how you're setting everything, so I can't say other than try using Stunt Playground for a good basis.

unclepauly

06-10-2006 13:59:48

yes, F3 shows the collision object around my car. i am using a convex collision, so things like the wheels arches are not done properly, such is the nature of convex hulls. but the general shape is correct. when you say set the tyres and suspension correctly, what do you mean by this? my understanding was that the wheels could be (theoretically) placed anywhere. yes, i am using stunt playground as my basis, that is why i do not understand why i have a problem. my car mass, engine mass, wheel mass, wheel radius, suspension settings, are all the same as stunt playground's GT car. i am even using the gt.mesh for the wheel! but one thing i did notice was that when the car accelerates

but my main issue is the car slowing down. i posted a new thread http://www.ogre3d.org/phpBB2addons/view ... 4356#14356 about this, i reproduced it in demo 5 which hopefully will make it easier for people to answer the problem!

thanks alot for your help.

unclepauly

07-10-2006 17:23:54

extra info (if anyone is bothered).

although the demo 5 vechicle and my own car both slow down, i now think the reasons are unrelated. i reduced the direct torque applied to the demo vehicle from 6000 to 600, and now the problem does not happen (at least, not for the few times that i ran the app). i assumed this was a lost traction problem, and if i append the return value from tire->lostTraction to an overlay, i can see that both rear tires are not loosing traction now that i have set the torque to this lower value.

however with my app, i can also see that the car is not loosing traction, but still it gets to 160km/h, stays there for a bit, and then loses power. this only happens sometimes. however, what i have noticed is that sometimes the car spazzes out sometimes, like one wheel has hit a small rock or something. sometimes this is major, and the car spins out of control and in the air. other times, it is minor, and causes the car to loose power. i think this is the reason it is loosing power sometimes.

my terrian is a box.mesh, so there are no pot holes, or rocks or anything that should cause the car to spaz out. as a test, i left the car sitting there, without applying any torque, with the camera pointing at it. i just sat and watched it for ages (boring by the way), and sometimes, for no reason, the car will spaz out on its own, with no forces applied to it. sometimes it will do this majorly, and sometimes just a little bit.

i think if i can get the car to stop spazzing out on its own, then maybe this will stop the slowing-down-for-no-goddamn-reason fiasco.

HexiDave, you mentioned suspension settings could be the cause of a spaz-out. what settings could cause this? looking at the car, the tyres are in perfect position (ie under the wheel guards), and are of a perfect size (good width, radius). susShock is 160, susSpring is 700 and susLength is 1.2.