Vehicle - erratic longitudinal slip


i’m traying to implement vehicles (tanks, actually) in our game, and have a problem i can’t fix. The effect is that the vehicle is very twitchy and sometimes not at all controllable. This is much more pronounced on tanks than wheeled vehicles. Examining the vehicle query data, i found that the longitudinal slip values are quite erratic. Here is an example of longitudinal slip for two front wheels of a tank, which should be going straight forward:

long_slip: 	-2.171			1.781
long_slip: 	-0.262			0.259
long_slip: 	0.610			-0.260
long_slip: 	-1.755			1.158
long_slip: 	0.216			-0.292
long_slip: 	-0.974			0.963
long_slip: 	1.000			-0.352
long_slip: 	-2.203			1.218
long_slip: 	-0.114			-0.091
long_slip: 	0.264			0.166
long_slip: 	-0.695			-0.216
long_slip: 	0.815			0.267
long_slip: 	-1.829			-0.317
long_slip: 	0.203			0.412
long_slip: 	-0.472			-0.879
long_slip: 	0.739			0.518
long_slip: 	-0.790			-0.414
long_slip: 	1.930			0.943
long_slip: 	0.115			-0.421
long_slip: 	-0.207			0.625
long_slip: 	1.496			-1.699
long_slip: 	-0.181			0.172
long_slip: 	0.485			-0.242
long_slip: 	-1.637			1.369
long_slip: 	0.281			-0.325
long_slip: 	-0.530			0.654
long_slip: 	2.346			-2.013
long_slip: 	0.491			-0.225
long_slip: 	-0.671			0.616
long_slip: 	2.272			-2.107
long_slip: 	0.536			-0.279
long_slip: 	-0.600			0.691
long_slip: 	0.893			-0.771
long_slip: 	-2.158			2.493
long_slip: 	-0.399			0.718
long_slip: 	0.811			-0.645
long_slip: 	-0.741			0.904
long_slip: 	2.391			-2.148
long_slip: 	0.665			-0.392
long_slip: 	-0.608			0.800
long_slip: 	0.862			-0.729
long_slip: 	-2.077			2.370
long_slip: 	-0.355			0.656
long_slip: 	0.739			-0.603
long_slip: 	-0.695			0.779
long_slip: 	0.950			-0.625
long_slip: 	-2.147			2.056
long_slip: 	-0.349			0.467
long_slip: 	0.734			-0.467
long_slip: 	-0.713			0.398
long_slip: 	0.475			-0.297
long_slip: 	-1.528			0.534
long_slip: 	0.213			-0.003
long_slip: 	-0.402			0.013
long_slip: 	0.429			-0.002
long_slip: 	-1.532			0.013
long_slip: 	0.424			0.116
long_slip: 	-0.520			-0.008
long_slip: 	0.897			0.097
long_slip: 	-0.626			-0.006
long_slip: 	2.081			-0.008
long_slip: 	0.424			0.106
long_slip: 	-0.453			-0.040
long_slip: 	0.690			0.136
long_slip: 	-0.522			-0.098
long_slip: 	0.759			0.246
long_slip: 	-1.622			-0.569
long_slip: 	0.039			0.688

As you can see, they are all over the place, causing the tank to jitter left-right, sometimes even causing it to turn and change direction even if no left-right control has been applied. I’ve verified that only the accelerate and thrust are applied, and that brakes are at zero. Wheel and surface materials have frictions and restitution set to 0.6.
I’ve compared the way my vehicles look in the Visual Debugger with the tank from the PhysX 3.3.4 samples, and can’t find significant differences.

Any help would be greatly appreciated.

I haven’t used pxvehicle so I can’t offer any really solid advice but in the past I’ve found that physx systems behave more in the way I expect them to if I increase my tick rate (i.e. take shorter timesteps). This may not be an acceptable solution for you but if you find that your tank acts in the way you expect at a higher tick rate then it probably implies you’ve provided a set of parameters to physx which it’s struggling to solve. Of course having determined this you would still need to figure out which parameter is the problem and I don’t know how you’d do that.

Shorter timesteps may indeed be the solution here.

Do you know what load is on the tires? You can find that out with PxWheelQueryResult::suspSpringForce. The value of suspSpringForce/(numWheelsvehicleMassgravity) should be close to 1.0f.

One other thing is to make sure that there is no rigid body contact between the wheels and the ground planes under the wheels. It is very important that the vehicle is supported by suspension forces rather than contact impulses.

Have you configured the vehicle friction system? It is worth looking at the values stored in PxWheelQueryResult::tireFriction. A simple experiment would be to increase the friction values. Maybe try a friction value of 1.5 and see if that solves the problem. Of course, physics doesn’t allow a friction value> 1.0 but this isn’t quite the real world so it is perfectly acceptable to push it a little if it gives good behaviour.


Just posting the resolution so others can benefit from it.

Shorter timesteps were indeed the solution.

I did investigate load on the tires and the friction. Friction value was very stable (1.0), but the load on the tires was not. Total normalized load on all tires was around 0.85, meaning that only 85% of total chassis mass was supported by suspensions.

Note that the formula given above is incorrect, it should say (suspSpringForce * numWheels) / (vehicleMass * gravity).

Debugging the issue with longer timestep showed that when calculating wheel speeds from engine angular velocity, it would overdo it in one substep, causing the calculation of engine angular velocity to be off in the next one, in turn causing an error in wheel speeds in the next substep. Shortening the timestep corrected this.

Thank you for your help, it is much appreciated.