How to solve The Vertical Dir of Vehicle is Unstable?

Question 1:why compute the longSlip in this way?

//Don't let the denominator fall below a user-specified value.  This can be tuned upwards until the  
//oscillation in the sign of longSlip disappears. 
longSlip = (wheelSpeed - longSpeed) / (PxMax(maxDenominator, PxMax(longSpeedAbs, wheelSpeedAbs)));

I have read some Vehicle Mechanics books
and I think the longSlip = (1 - abs(wheelSpeed)/abs(longSpeed))*100%;

Why it need a maxDenominator or the longSpeed/wheelSpeed have sign?

I think the oscillation in the sign of longSlip will affect the LongForce and LongForceTorque,eventually affect the Jitter Effect

Question 2: The Position of Vertical Direction is unstable before the Actor Sleeping?
There are Four SuspForceW and SuspForceW Torque on the Chassis,
I find the reason why the vehicle Jitter in Vertical Direction.
The value of jounce is unstable when it’s very small ,result in the suspension force is unstable and the VerticalPosition is unstable
What’s the condition of RigidActor Sleeping?
Where is NpRigidDynamic::putToSleep() called?
I don’t know how to solve the problem…

the Vertical Position/Rotation of Vehicle will Jitter when I steer the Vehicle without Accel or when the vehicle will be static
My Demo Video,the Position.Z (in UE4 Up is Z) will Jitter in the range [61.51xx 61.55xx] :
http://www.iqiyi.com/w_19rvaopngd.html

VehicleSample Video of PhysXSDK,the Vertical Position of Vehicle is stable
I print the position of Vehicle PxRigidDynamic in Console
Position.Y (in VehicleSample Up is Y) not Jitter…
So Why there is no Jitter in Vertical Direction ?
http://www.iqiyi.com/w_19rvbiez6h.html

I find UE4 use ApexScene->simulate(DeltaTime) By Default,Does it matter the Jitter?

“Why it need a maxDenominator or the longSpeed/wheelSpeed have sign?”

/**
\brief Set the minimum denominator used in the longitudinal slip calculation.

\note The longitudinal slip has a theoretical value of (w*r - vz)/|vz|, where w is the angular speed of the wheel; r is the radius of the wheel; 
and vz is the component of rigid body velocity (computed at the wheel base) that lies along the longitudinal wheel direction. The term |vz|
normalizes the slip, while preserving the sign of the longitudinal tire slip.   The difficulty here is that when |vz| approaches zero the 
longitudinal slip approaches infinity. A solution to this problem is to replace the denominator (|vz|) with a value that never falls below a chosen threshold. 
The longitudinal slip is then calculated with (w*r - vz)/PxMax(|vz|, minLongSlipDenominator).

\note The default value is the equivalent of 4 metres per second after accounting for the length scale set in PxTolerancesScale.  

\note Adjust this value upwards if a vehicle has difficulty coming to rest.

\note Decreasing the timestep (or increasing the number of sub-steps at low longitudinal speed with setSubStepCount) should allow stable stable 
behavior with smaller values of minLongSlipDenominator.
*/
void setMinLongSlipDenominator(const PxReal minLongSlipDenominator);

What’s the condition of RigidActor Sleeping?

You probably need to scale the sleep threshold energy.

/**
\brief Sets the mass-normalized kinetic energy threshold below which an actor may go to sleep.

Actors whose kinetic energy divided by their mass is below this threshold will be candidates for sleeping.

<b>Default:</b> 5e-5f * PxTolerancesScale::speed * PxTolerancesScale::speed

\param[in] threshold Energy below which an actor may go to sleep. <b>Range:</b> [0, PX_MAX_F32)

@see isSleeping() getSleepThreshold() wakeUp() putToSleep() PxTolerancesScale
*/
virtual		void				setSleepThreshold(PxReal threshold) = 0;

I find UE4 use ApexScene->simulate(DeltaTime) By Default,Does it matter the Jitter?

There’s a discussion of the relationship between the timestep and the spring stiffness in the tuning guide. I’m guessing your spring is too stiff for the timestep.

I have getSleepThreshold() ,and the value 50.f is scaled by default
But my Vehicle isn’t Sleeping before 0.1s Jitter…

I have configure the UE4 timestep to a fixed value = 0.01667,the same as VehicleSample of PhysX SDK.

There is a Main Different Point between MyVehiclePlugin and VehicleSample,
It is the Configs of PxSceneDesc.flags

I’m not sure if different Configs will result in Jitter

The vehicle should not jitter if it is resting on a flat plane. I don’t think the problem is the sleep threshold. In fact, it might be a good idea to temporarily set the sleep threshold to zero to make sure the vehicle never goes to sleep. At this stage it is better to avoid masking problems.

I suspect the suspension is just too stiff or underdamped. Could you compute the natural frequency of ech spring?

Does the Four SuspSpring use the same NaturalFrequency?

VehicleSuspensionData susps[4];
	for (PxU32 i = 0;i<4;i++)
	{
		susps[i].mMaxCompression = MaxCompression*toleranceScale;
		susps[i].mMaxDroop = MaxDroop*toleranceScale;
		susps[i].mSpringStrength = FMath::Square(NaturalFrequency) * suspSprungMasses[i];
		susps[i].mSpringDamperRate = SuspensionDampingRatio * 2.0f * FMath::Sqrt(susps[i].mSpringStrength * suspSprungMasses[i]);
	}

susSpringMass[4] -> 341 341 408 408
NaturalFrequency -> 7
SuspensionDampingRatio -> 0.6


It’s easy to tune

after compute:
SpringStrength -> 16740 16740 20000 20000
SpringDamperRate -> 2869 2869 3430 3430

Does the front and rear Spring should have the same SpringStrength and SpringDamperRate?
The VehicleSample of PhysX SDK use the same value 35000 and 4500…

I will share my project based on UE4.15 with you if you want to see/debug/tune it.
The Jitter Problem is the biggest Problem,Before I can develop VehicleApplication in practice!!
You could
<1> right click .uproject select Generate the .sln to your VS Version
<2> Open the .sln project
<3> Confirm what the real reason of Jitter is
<4> W A S D control the vehicle

My Plugin will Log the jounces[4] in OutputLog Window

front left and front right jounce are not equal !!!
I think the values not correct…
After tuning the susp natural frequency and damping rate,I find the jounces value very strange…
I think The correct jounces value should be
1> very close to 0.0 when the vehicle static
2> left jounce = right jounce

Is this Because the wrong ChassisMassCenter Position?

VehicleSample jounces

I’m afraid I’m not really able to dig in to the project specifics but I am able to help here on the forum.

The jounce should follow damped harmonic motion towards a steady state of zero if the vehicle is dropped on to a flat plane. The left and right jounce should be approximately equal.

I think it should be fairly easy to track the left and right jounce frame by frame. PxVehicleWheelQueryResult returns all sorts of useful information: tireContactNormal, suspJounce, suspSpringForce etc. I would imagine that a frame by frame analysis of that data would reveal the frame where symmetry between left and right is broken.

Cheers,

Gordon

Thanks !

My Next Debug Plan
<1> import my Vehicle Mesh FBX/obj in VehicleSample Project and trace the value of jounces(I recommend the SamplesProject implement a FBX importer in the next version ,currently I have to import obj myself…)
<2> if <1> is correct ,left jounce = right jounce, I’ll change the UE4 FPhyScene Source code in order to the same as VehicleSample,now the PxSceneDesc is different between VehicleSample and UE4 FPhyScene

I don’t think the issue is in PxSceneDesc. The jounce calculation depends only on a scene query and a force calculation and an update of a rigid body. None of the settings in PxSceneDesc should affect any of that.

I supsect this is a problem with the car data. There is a lot of debug data (graph data and PxVehicleWheelQueryResult) and I think that clues to your problem lie in there.

Comparing a working version with your version is a great idea.

I’ll show you what happened in my VehiclePlugin Debug Info :

<b>Frame N:</b>
LogTemp: <b>LinearVelcity: 0.00000000 0.00000000 -479.69708252</b>
LogTemp: AngularVelcity: 0.00000000 0.00000000 0.00000000
LogTemp: jounces[4]: -5.00000000 -5.00000000 -5.00000000 -5.00000000
LogTemp: jounces[4]: -5.00000000 -5.00000000 -5.00000000 -5.00000000
LogTemp: suspGravity: 334157.78125000,suspSpringStrength: -103076.25781250,suspSpringDamp: 2241207.00000000
LogTemp: suspGravity: 334157.75000000,suspSpringStrength: -103076.24218750,suspSpringDamp: 2241206.75000000
LogTemp: suspGravity: 400842.28125000,suspSpringStrength: -123646.14062500,suspSpringDamp: 2688461.75000000
LogTemp: suspGravity: 400842.31250000,suspSpringStrength: -123646.15625000,suspSpringDamp: 2688462.00000000
LogTemp: jounces[4]: -3.73205566 -3.73205566 -3.73205566 -3.73205566

<b>Frame N+1:</b>
LogTemp: <b>LinearVelcity: 0.00004613 -0.00036611 116.92098999</b>
LogTemp: AngularVelcity: 0.00000287 0.00000049 0.00000029
LogTemp: jounces[4]: -5.00000000 -5.00000000 -5.00000000 -5.00000000
LogTemp: jounces[4]: -5.00000000 -5.00000000 -5.00000000 -5.00000000
LogTemp: jounces[4]: -5.00000000 -5.00000000 -5.00000000 -5.00000000

the Frame N ,the LinearVelocity is Vec3(0,0,-479)
the Frame N+1, the LinearVelocity is Vec3(0,0,116)

I think it’s very ridiculous!

What’s the difference between ApexScene->simulate and PxScene->simulate ?
Does ApexScene->simulate affect the Vehicle RigidActor update in the wrong way?

The car seems very heavy. Is that expected? suspGravity is 334157, so the mass is 3341.57 kg. The total car mass will be about 4 times that. I make that about 14k kg.

The spring strength is negative: suspSpringStrength: -103076.25781250. That doesn’t sound right.

The spring has hit its limit because the jounce remains constant at -5.0f. The velocity change you see is the instantaneous bounce off the suspension limit that is enforced by the suspension limit constraint.

The Gravity Acclerator = 980 ,susGravity = 334.157 * 980 the mass is 334kg, UE4 use centimeters not meters as unit,so it’s right

The suspSpringStrenghForce = -103076 suspSpringDampForce: 2241207.00000000 ,I forgot to add _Force

suspSpringStringthForce = SpringStrengthjounce
suspSpringDampForce = SpringDamp
jounce_speed

The suspension limit is just active at MaxCompression=8cm,not at MaxDroop=-5cm,
In my case, the suspension limit constraint is not active,I think the chassis just hit the plane and bounce,not the suspension limit force bounce it .

Also I find the suspension limit force won’t bounce the chassis to the air directly after I trace the VehicleSample .

I think I find the reason of the 0.1s Jitter.
After I debug step by step and compare with the VehicleSample of PhysX SDK.
I find my VehiclePlugin is correct,the Postion and Rotation is the same as VehicleSample…

It’s not because the CarData or PxScene->simulate have any problem.

It’s a problem of UE4 AntiAlias and my Car has too many faces (100,000),UE4 use TemporalAA default, when the velocity of Car is very samll ,the frame will be jitter in the edges of Car Mesh

[b]Thanks a lot for your help in the past several months !!!
When you come ShangHai ,I’m very glad to invite you have a dinner in my Home.

I will show you my Demo Video without AA in UE4:
[/b]
http://119.23.71.163:18888/CarVideo.html

That is great news. I’m glad you sorted it out. This looks really promising.

Thanks for the offer!

I check the forums a few times a week so feel free to ask more questions.