Adaptive Cruise Control

Overview

Adaptive Cruise Control (ACC) is an ADAS feature that maintains a user-set cruise speed while automatically slowing for a lead vehicle. The effective target speed is the minimum of the cruise-speed setpoint and the speed needed to keep a safe following distance.

The controller runs on the vehicle and uses simulation data about nearby traffic to select a lead vehicle, then applies longitudinal control through the brake and throttle pedals. Leader detection scans nearby map objects, filters candidates by position, heading, and corridor overlap, and tracks the most relevant vehicle ahead. Longitudinal control uses a kinematic follow law with dynamic headway, leader-acceleration feedforward, and comfort deceleration limits. Pedal commands are produced by online throttle and brake models that map desired longitudinal acceleration to actuator inputs.

How it works

  1. Leader detection — Nearby vehicles are scanned each frame. Candidates must be ahead of the ego vehicle, within lateral and vertical windows, and have overlapping forward corridors. The best leader is chosen using distance, closing speed, and a threat score. If the current leader is briefly lost, its state is held for up to 3 seconds.
  2. Speed and gap control — Desired following distance grows with lead speed (standStillDistance + speedHeadwayGain × leadSpeed). A gap-error term adjusts the desired speed relative to the leader. When closing too fast inside the desired gap, the controller demands the deceleration needed to fit within the remaining distance.
  3. Actuation — Desired acceleration is mapped to throttle or brake using learned line-fitting models. At very low speeds, a hold-brake term can keep the vehicle stopped behind a stationary leader.
  4. Driver override — Pressing the brake pedal above a small threshold unloads ACC. Pressing the throttle temporarily reduces ACC authority and gradually re-engages control over about one second.

Usage

Inputs

  • speed — desired cruise speed in m/s
  • debugFlag — if true, ACC logs debug samples and writes a CSV file named accLog to AppData/Local/BeamNG.tech/<current version> on unload. The CSV includes target speed, ego speed, leader state, acceleration targets, and throttle/brake commands. Defaults to false.

Lua

ACC is a vehicle Lua extension. The following commands can be used inside the vlua code or in-game Lua console (open with Ctrl + @ or `).

  • extensions.tech_ACC.load(speed, debugFlag) — Loads and starts ACC on the current vehicle. If speed is omitted, the current vehicle speed is used.

  • extensions.tech_ACC.changeSpeed(speed) — Changes the cruise-speed setpoint while ACC is loaded.

  • extensions.tech_ACC.unload() — Unloads ACC and releases ADAS pedal control.

BeamNGpy

ACC is exposed through the vehicle API. For details, see the BeamNGpy documentation .

For a practical example, see the ACC test example in the BeamNGpy repository.

Advanced leader control

These functions are used by vehicle platooning:

  • extensions.tech_ACC.setLeaderMode(mode)"auto" (default) or "external"
  • extensions.tech_ACC.setExternalLeader(objectId, leadSpeed, leadAccel) — follow a specific object with supplied leader kinematics
  • extensions.tech_ACC.clearExternalLeader() — return to automatic leader selection
  • extensions.tech_ACC.setDriverOverrideCallback(callback) — optional callback invoked when the driver overrides with the brake pedal

Limitations

  • Leader Perception — Leader detection uses simulation object data from the map manager, not a sensor feed directly. The ACC doesn’t take into account the road network.
  • Vehicle and powertrain variation — Throttle and brake mapping is learned online during operation. Behaviour can vary with vehicle type, drivetrain, and terrain slope.
Last modified: August 20, 2026

Any further questions?

Join our discord
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.