Class ESCModule
Electronic Stability Control (ESC) module for NWH Vehicle Physics 2.
Inherited Members
Namespace: NWH.VehiclePhysics2.Modules.ESC
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class ESCModule : VehicleComponent
Remarks
ESC helps maintain vehicle stability by detecting and reducing loss of traction during cornering. It monitors the difference between the vehicle's intended direction (based on steering input) and actual direction (based on velocity), applying individual wheel braking to correct oversteer or understeer conditions.
The module calculates slip angle continuously and applies corrective braking forces to the appropriate wheels to bring the vehicle back in line with the driver's intended path. The intervention is proportional to the severity of the slip angle and increases with vehicle speed for enhanced high-speed stability.
Key behaviors: - Only intervenes when slip angle exceeds the threshold, allowing for normal cornering - Applies braking to outer wheels during oversteer to counter the yaw moment - Compensates for intentional steering input to distinguish between desired and undesired slip - Intervention strength scales with vehicle speed for appropriate response at different velocities
Note: This module is designed for 4-wheel vehicles. For motorcycles or vehicles with different wheel configurations, the module may need adjustment or should be disabled.
Fields
baseBrakeTorque
Base brake torque (Nm) applied to wheels for stability correction.
Declaration
[Tooltip("Base torque applied to wheels")]
public float baseBrakeTorque
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This is the foundational brake force used for ESC intervention, which gets multiplied by the intensity and slip angle to determine the actual applied torque.
Lower values (20-40 Nm): Subtle corrections, less intrusive but may be insufficient for heavy vehicles. Medium values (50-100 Nm): Balanced intervention suitable for most passenger vehicles. Higher values (100-200 Nm): Aggressive corrections for heavy vehicles or sport applications.
intensity
Overall intensity multiplier for ESC corrections.
Declaration
[Tooltip("Intensity of ESC correction")]
public float intensity
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Controls how aggressively the ESC system responds to slip angles. This is a global multiplier applied to all ESC interventions.
Lower values (1-5): Minimal intervention, allows more vehicle rotation before correction. Medium values (5-15): Standard ESC behavior for most vehicles. Higher values (15-30): Very aggressive ESC, maintains tight trajectory control.
interventionThreshold
Minimum slip angle (degrees) required for ESC to begin intervention.
Declaration
[Tooltip("Minimum angle (degrees) before ESC activates")]
public float interventionThreshold
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Slip angle is the difference between the vehicle's velocity vector and its forward direction. ESC will not intervene below this threshold, allowing for normal cornering dynamics.
Lower values (1-2°): Early intervention, very stable but may feel restrictive during spirited driving. Medium values (2-5°): Balanced setting allowing some slip for performance driving. Higher values (5-10°): Late intervention, more freedom for experienced drivers but less safety margin.
minimumSpeed
Minimum vehicle speed (m/s) required for ESC to function.
Declaration
[Tooltip("Minimum speed (m/s) for ESC to activate")]
public float minimumSpeed
Field Value
| Type | Description |
|---|---|
| float |
Remarks
ESC is disabled at low speeds to prevent interference with parking maneuvers and tight turns. This also prevents false triggers from steering input when the vehicle is nearly stationary.
Typical values: 2-5 m/s (7.2-18 km/h). Default is 3.0 m/s. Lower values may cause unwanted intervention during parking. Higher values reduce ESC coverage during slow-speed emergency maneuvers.
speedMultiplier
Multiplier for ESC intervention strength at higher speeds.
Declaration
[Tooltip("Intervention strength increase at higher speeds")]
public float speedMultiplier
Field Value
| Type | Description |
|---|---|
| float |
Remarks
ESC intervention is scaled based on vehicle speed to provide appropriate response. At 50 m/s (180 km/h), the full speed multiplier is applied. The scaling is linear from 0 to 50 m/s.
Lower values (1.0-1.3): Consistent intervention regardless of speed. Medium values (1.5-2.0): Moderate speed-dependent scaling. Higher values (2.0-3.0): Strong speed sensitivity, aggressive high-speed stabilization.
steeringCompensation
Factor for compensating intentional steering input in slip angle calculation.
Declaration
[Tooltip("How much to compensate for steering input")]
public float steeringCompensation
Field Value
| Type | Description |
|---|---|
| float |
Remarks
This value helps distinguish between intentional sliding (e.g., drifting) and unwanted loss of control. The steering angle is multiplied by this factor and subtracted from the calculated slip angle.
0.0: No compensation - ESC treats all slip as unintended. 0.5: Moderate compensation - allows some intentional slip during aggressive cornering. 1.0: Full compensation - maximum allowance for intentional sliding.
Higher values make ESC less intrusive during intentional maneuvers but may reduce safety.
Methods
VC_FixedUpdate(float)
Physics update called at fixed intervals. Override to implement physics-based behavior.
Declaration
public override void VC_FixedUpdate(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Time elapsed since last FixedUpdate in seconds |
Overrides
Remarks
Only called when the component is active (initialized and enabled). Use for physics calculations, force application, and other fixed-timestep operations. Called from VehicleController.FixedUpdate().
VC_Initialize()
Initializes the component's internal systems and resources. Called once during vehicle startup after the VehicleController reference is set.
Declaration
protected override void VC_Initialize()
Overrides
Remarks
Override this to set up component-specific resources, cache references, or perform one-time initialization. Sets state.initialized to true on completion.