File Info

Filename esc.lua
Path /lua/vehicle/controller/esc.lua
Multiple Usage Not supported

Jbeam Properties

Name Default Unit Description
actionedWheels nil array<string> Defines the relevant wheel for the ESC/TC. Needs to be exactly four, not more or less.
isDebugMode 0 number Enables or disables the debug mode which prints some more information during init
defaultConfig 1 number Index of the default esc configuration
configurations nil array<escConfiguration> Array of ESC/TC configurations
offColor “343434” string The color being used in UI apps when there is current ESC/TC action
blacklistedEngines nil array<string> Array of powertrain device names that tell the ESC/TC to ignore the named engines/motors when adjusting throttle or cutting ignition


Name Default Unit Description
escEnabled false bool Sets whether the ESC/TC is enabled at all
escConfigurationEnabled false bool Sets whether the specific ESC configuration is active and can be selected. Useful for selectively removing a given configuration from a child part without redefining all configurations.
order nil number Specifies the order of the configuration relative to the other configurations
activeColor “98FB00” string The color which is used in UI apps to indicate the active ESC configuration
maxSideAcceleration 0 number  
brakeForceMultiplier 0 number  
escThreshold 0 number  
desiredYawRateSmoothing 500 number  
characteristicSpeed 0 m/s  
proportionalFactor 1 number  
integralFactor 0 number  
maxIntegralPart 2 number  
skewStiffnessFront 1 number  
skewStiffnessRear 1 number  
slipThreshold 0 number  
tcsWheelSpeedThreshold 10 rad/s Wheel angular velocity at which the TC starts to monitor slip and tries to prevent it
minThrottleFactor 1 number  
maxBrakingFactor 0 number  
throttleProportionalFactor 1.5 number  
throttleIntegralFactor 1 number  
brakingProportionalFactor 1.2 number  
brakingIntegralFactor 0 number  
brakeThrottleSwitchThreshold 10 m/s Speed at which the TC switches from using the brakes to slow down specific wheels to cutting the throttle instead
overrideESCPulse 0 number  
overrideTCSPulse 0 number  

Public functions

Function name Parameters Description
toggleESCMode()   Toggles between available ESC/TC modes
setESCMode(key) number Sets a specific ESC/TC mode via an index
getCarData()   Returns various ESC/TC relevant metrics about the car
getCurrentConfigData()   Returns the complete data of the currently active ESC/TC configuration

Example Usage

Controller setup

"controller": [
"esc": {
  "actionedWheels": ["FL", "FR", "RR", "RL"],
  "isDebugMode": 0,
  "defaultConfig": 1,
  "configurations": {
    "Regular ESC":{
      "escEnabled": true,
      "escConfigurationEnabled": true,
      "proportionalFactor": 0.85,
      "integralFactor": 1.5,
      "maxIntegralPart": 2.0,
      "slipThreshold": 0.15,
      "minThrottleFactor": 0.05,
      "maxBrakingFactor": 0.85,
      "throttleProportionalFactor": 2.0,
      "throttleIntegralFactor": 2,
      "brakingProportionalFactor": 2,
      "brakingIntegralFactor": 1.5,
      "brakeThrottleSwitchThreshold": 20,
    "Sport ESC":{
      "escEnabled": true,
      "escConfigurationEnabled": true,
      "proportionalFactor": 0.25,
      "integralFactor": 0.7,
      "maxIntegralPart": 1.0,
      "slipThreshold": 0.35,
      "minThrottleFactor": 0.35,
      "maxBrakingFactor": 0.6,
      "brakeThrottleSwitchThreshold": 60,
    "ESC Off":{
      "escEnabled": false,
      "escConfigurationEnabled": true,
      "overrideESCPulse": 1,
      "overrideTCSPulse": 1,