The current suspension implementation.
1. Take new velocity(linear, angular) from bullet.
2. Calculate the force to reach this velocity (v1 - v0) / (m * dt). This is the external force: collision, gravity.
3. Run 10 sub steps (60Hz*10) driveline/suspension/tire simulation.
Suspension:
1. Cast rays from current wheel position along car down vector(offset is wheel radius * 2).
2. Use ray cast results as wheel displacement(displacement relative to wheel position).
3. Calculate normal force limit. The max force exerted by the surface to keep the car from penetrating it(along contact normal). Means reduce car velocity at contact point along surface normal to zero.
4. Get suspension force limit by projecting normal force limit onto suspension vector(car down vector).
5. Get suspension velocity by projection of the normal velocity.
6. Get displacement by proj..
->This is wrong as the displacement is along the suspension vector already.
7. Update suspension, get suspension force.
8. Add anti roll force to suspension force(depending on new wheel positions).
9. Get normal force by inverse projection.
10. Add suspension geometry force(perpendicular to suspension). This is a bit voodoo. Should be solved by using distance constraint for the geometry.
I think I should setup a simulation validation car, create a test track.
The origins of the issue: One day I figured out that the tire forces were applied at wheel center and not at tire contact point. Fixing it has caused the cars to start to roll. An easy fix would be to go back to the previous tire force at wheel center model.
|