I have an annoying issue with vehicles. I’ve followed the vehicle sample, and implemented vehicles into our project. However, as soon as the vehicle’s suspension ray casts hit the ground, the force generated by suspension is huge (around 400 KN), launching the vehicle up in the air. Jounce is correct - during the first few frames before the newly created vehicle hits the ground it is equal to max wheel droop. On contact, suspension compresses slightly (from jounce of -0.150 to about -0.120), but the generated force is enormous.
Suspension parameters are close to those in the vehicle sample, except for a bit larger droop and compression (0.15 and 0.4), but changing them doesn’t affect the outcome much. Only when both max compression and droop are zeroed, the vehicle rest on the ground (with physx reporting errors, ofc). Other than that, changing suspension strength and damping does change the suspension force, but not in any useful way. Even with suspension strength set to 1, the generated force is huge.
Examining the setup with the visual debugger doesn’t reveal any glaring flaws. I’ve been stuck on this for the last three days, so any advice would be much appreciated.
400kN does sound like an incredibly large suspension force. The suspension force at rest should be sprungMass*g so a car of mass 1000kg with 4 wheels should generate around 2500N per suspension at rest. The maximum suspension force should only ever be a few multiples of the rest load so the upper bound in this scenario should be around 10kN.
Can you explain how you verified that you are getting 400kN applied to the suspension? Are you reading this from PxWheelQueryResult::suspSpringForce?
I think the quickest way to fix this is to compile in debug and put a breakpoint in the vehicle update code. The following code is responsible for computing the suspension force and can be found in PxVehicleUpdate.cpp
//Compute the spring force.
const PxF32 wDotGrav=PxMax(0.0f, w.dot(gravity));
PxF32 springForce=susp.mSprungMasswDotGrav;
springForce=susp.mSprungMasswDotGrav; //gravity acting along spring direction
springForce+=susp.mSpringStrengthjounce; //linear spring
springForce+=susp.mSpringDamperRatejounceSpeed;//damping
springForce=PxMax(springForce,0.0f);
As you can see, this is really very simple and involves only a few parameters. It should be straightforward to step over each line in debug mode.
It would also be helpful to know the values of gravity, sprung mass, spring strength and spring damper rate.
To get the suspension force, i was using mWheelsDynData.getSuspensionForce(i) on my PxVehicleDrive4W object, after the vehicle was updated. The 400 KN force was present on all four wheels, for one frame only.
Gravity is 9.81, pointing in the -z direction, which off corresponds to the ‘down’ direction. Sprung mass is 375kg (vehicle weight is 1500kg), spring strength 35000, damper rate 4500. The last two values are the same as in the vehicle sample.
The only unknown variable from the above code is jounceSpeed, but i don’t see how that could be such a huge number.
A simple experiment is to minimise the effect of each parameter one at a time to see what is causing the issue. For example, run your test with spring strength = 1, then with damper rate = 1 etc etc.
The next step, though, is really to step through the code in debug configuration.
btw it looks like you are using 3.2 or earlier. We are still supporting this release but it’s best to be on a more recent release. The most recent is 3.3.1.
i did what you suggested above even before posting here. In the end, it turned out that the error was quite basic - gravity was in cm/s^2 instead of m/s^2. I stepped through the code many times, but just didn’t see it. Everything works fine now.
We’re currently running version 3.2.3. At this point, it’s not likely that we’ll upgrade to latest release, unless it resolves a major problem.