DIL driver training — VRU/pedestrian control via BeamNGpy + traffic light state from Python

Hi BeamNG.tech team,

I am building a Driver-in-the-Loop simulator for driver training on BeamNG.tech. Current setup: triple screen, BeamNGpy, Italy map, etk800, Script AI traffic with IdealRadar and Roads sensor. Working well so far.

Two technical questions:

1. Pedestrians / VRU Is there a native VRU actor type planned for BeamNG.tech? If not, what is the recommended approach for simulating a hazard at a pedestrian crossing — static obstacle, Lua trigger, or something else?

I have found the BeamPedestrians mod by Mosez and have reached out to him directly. My question is specifically whether it is compatible with BeamNG.tech and whether pedestrian position and trigger timing can be controlled programmatically from Python via BeamNGpy.

2. Traffic light state from Python What is the correct Lua call to read the current signal phase via queue_lua_command? I want to log red|amber|green per tick and detect when a student crosses on red. Does AI traffic respect lights reliably on maps that have them?

Thanks in advance

Hello LennieLightning,

I hope this message finds you well.

Please find below what the latest published BeamNG.tech and BeamNGpy releases support for your DIL setup.


1. Pedestrians / VRU

There is no native VRU/pedestrian actor in the current release. You can still script crossing hazards with BeamNGpy:

  • Add a StaticObject to your Scenario (scenario.add_object()) using a collision mesh from game assets as the hazard prop.
  • Load and start the scenario as usual, then use bng.scenario.teleport_object() to move the prop into the crossing when your trigger fires (timer, distance to the student vehicle, etc.).
  • Use bng.control.queue_lua_command() in the same Python loop for any extra GE-side timing or logging.

The object_placement example in the BeamNGpy repo shows StaticObject placement.


2. Traffic light state from Python

v0.38.5.0 includes core_trafficSignals, but there is no dedicated BeamNGpy traffic-signals API in the published release yet.

The supported method is bng.control.queue_lua_command() against core_trafficSignalsgetSignalByName, getSignals, and getState() on signal instances. Have your Lua chunk return JSON via jsonEncode and parse it in Python. A level must be loaded first (getCurrentLevelIdentifier() should not be empty).

Discover instance names with a list call first; names are level-specific (e.g. West Coast USA uses trafficLight 1).

Red | amber | green: redTrafficLight → red, yellowTrafficLight → amber, greenTrafficLight → green. The action field is also useful: stop / alert / go. For red-light violations, watch for action == 'stop'.

Detecting a student crossing on red: Each tick, query the approach signal, read the student vehicle position (vehicle state or Roads sensor), and log a violation if the signal is stop/red and the vehicle passes the stop line or enters the junction. Use signal pos and dir for stop-line logic — not as a vehicle spawn point.

Italy vs West Coast / East Coast

Italy ships stop signs and other road signs on the map, but no working traffic lights and no bundled signals.json in v0.38.5.0. You cannot log red/amber/green phases on Italy as shipped.

West Coast USA and East Coast USA both include signals.json with full traffic-light sequences — use these to develop and test signal polling. To add stop-sign or signal logic on Italy, author and save signals.json yourself via the Traffic Signals Editor.

Does AI traffic respect lights?

Yes, when signals.json exists and signals are active. Script AI in traffic mode reads navgraph signal data and stops for red (action 2) and stop signs (action 3). This is generally reliable on West Coast and East Coast. On Italy as shipped, there is no bundled signal data — no traffic-light AI compliance unless you add signals.json yourself.


Please let me know if you have any further questions or need more detail on WCUSA polling or Italy stop-sign setup.

Best regards,

Abdulrahman Saeed
Research Software Engineer
BeamNG.tech Support Team