vehicle dynamics model in ADS simulation

VD background

usually to simualate vehicle dynamic(VD) system, either by physical model, e.g. pysical models of engine, gearbox, powertrain; or parameter model, which doesn’t take into the physical process of the dynamic system, but tracking the system’s input, output and fit their relationship with polynomail equation or functions with multi-pieces.

traction force is derived from engine torque, which goes to gearbox(powertrain system) and then divided by radius of wheels, then distribute to wheels.

traction torque

  • air drag

  • air lift force

  • traction force

    $$ F(traction) = F(air drag) + F(air lift force) + F(tire drag) + acc * mass $$

in a detail way, the equation above should split into lateral state equation and longitudional state equation, if consider driver control module, which will give laterl control equation and longitudional control equation.

brake torque and ABS system

ABS(anti-block system) works in the situation, when driver input brake torque is larger than the max ground-tire torque can attached between tire and ground.

once max ground-tire torque is achieved, namely the max fore-aft force T is achived, the traction direction traction slip angular decceleration will leap, this is the dead-blocking situation, and when it happens, the driver input brake torque is saturated.

to avoid block situation happens, usually track decelleration of traction slip angular during brake torque increase, if the value of decelleration of slip traction angular is beyond a threshold value, ABS controller will trigger to decease brake torque.

drive stability

the driving stability is mainly due to forces on tires, sepcially the lateral angular velocity derived from Lateral Force

image

lateral control

taking driver as one element, the driveing system is a close-loop control system. the system works on a road situation:

  • the driver pre-expect a driving path(predefined path) and operate the steering wheel to some certain angular
  • the vehicle take a move with a real driving path(real path)
  • the real path is not exactly fitted to the predefined path, leading the driver take an additional conpensation control

longitudinal control

similar as lateral control

VD in Unity

any vehicle in Unity is a combination of: 4 wheels colliders and 1 car collider.

image

WheelConllider

1) AxleInfo

AxleInfo represents the pair of wheels, so for 4-wheel vehicle, there are two AxleInfo objects.

1
2
3
4
5
6
7
8
9
10
struct AxleInfo
{
WheelCollider left ;
WheelCollider right;
GameObject leftVisual ;
GameObject rightVisual ;
bool motor ; #enable movement of this wheel pair
bool steering ; # enable rotation of this wheel pair
float brakeBias = 0.5f;
}

2) core parameters

  • wheel damping rate

  • suspension distance

  • Force apply point distance (where ground force act on wheel)

  • suspension spring

  • forwardSlip(slip angle), tire slip in the rolling(tractional) direction, which is used in calculating torque

  • sidewaySlip, the lateral direction slip, which leads to stability issue.

physical of wheel

3) visualization

the WheelCollider GameObject is always fixed relative to the vehicle body, usually need to setup another visual GameObject to represent turn and roll.

implementation from lg-sim

1
2
3
4
5
6
7
8
9
10
11
void ApplyLocalPositionToVisuals(WheelCollider collider, GameObject visual)
{
Transform visualWheel = visual.transform;
Vector3 position;
Quaternion rotation;
collider.GetWorldPose(out position, out rotation);
visualWheel.transform.position = position;
visualWheel.transform.rotation = rotation;
}

4) WheelCollider.ConfigureVehicleSubsteps

1
public void ConfigureVehicleSubsteps(float speedThreshold, int stepsBelowThreshold, int stepsAboveThreshold);

Every time a fixed update happens, the vehicle simulation splits this fixed delta time into smaller sub-steps and calculates suspension and tire forces per each smaller delta. Then, it would sum up all resulting forces and torques, integrate them, and apply to the vehicle’s body.

5) WheelCollider.GetGroundHit
return the ground collision data for the wheel, namely WheelHit

wheel friction curve

for wheels’ forward(rolling) direction and sideways direction, first need to determine how much the tire is slipping, which is based on speed difference between the tire’s rubber and the road,
then this slip is used to find out the tire force exerted on the contact point

the wheel friction curve taks a measure of tire slip as an Input and give a force as output.

The property of real tires is that for low slip they can exert high forces, since the rubber compensates for the slip by stretching. Later when the slip gets really high, the forces are reduced as the tire starts to slide or spin

1) AnimationCurve
unity official

store a collection of Keyframes that can be evaluated over time

vehicleController() in lg-sim

1) the controllable parameters:

1
2
3
4
5
6
currentGear
currentRPM
currentSpeed
currentTorque
currentInput
steerInput

2) math interpolate function used

Mathf.Lerp(a, b, t)

a -> the start value

b -> the end value

t -> the interpolation value between start and end

3) fixedUpdate()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// cal trace force by rigidbody
rigidbody.AddForce(air_drag)
rigidbody.AddForce(air_lift)
rigidbody.AddForceAtPosition(tire_drag, act_position)
// update current driving torque
currentTorque = rpmCurve.Evalue(currentRPM / maxRPM) * gearRaion * AdjustedMaxTorque
// apply torque
// apply traction control
// update speed
currentSpeed = rigidbody.velocity.magnitude
// update fuel info
fuelLevel -= deltaConsumption
// update engine temp
// update turn signal light

4) ApplyTorque()

1
2
3
4
5
6
float torquePerWheel = accelInput * (currentTorque / numberofWheels)
foreach(axle in axles):
if(axle.left.motor):
axle.left.motorTorque = torquePerWheel
if(axle.right.motor):
axle.right.motorTorque = torquePerWheel

5) TractionControl()

1
2
3
4
5
6
7
8
9
10
11
12
TractionControl()
{
AdjustTractionControlTorque(axle.hitLeft.forwardSlip)
}
AdjustTractionControlTorque(forwardSlip)
{
if(forwardSlip > SlipLimit)
tractionMaxTorque -= 10
else
tractionMaxTorque += 10
}

in lg-sim, the VD model is still simple, as there is only traction/logitudional control.

refer

add equation in markdown

wheelcollider doc

whell collider official

whellcollider tutorial