Recording
a) Default capture (tcomCapture.log
)
This capture is generated every time you run BeamNG with the -tcom-debug
argument and it communicates
with BeamNGpy. It is overwritten every run, so if you want to preserve your recordings, you can create
your custom capture names.
You need to run BeamNG with the -tcom-debug
argument and also start the BeamNGpy server. You can choose between launching BeamNG from BeamNGpy,
or by using the command-line arguments to start the BeamNG server.
Launch BeamNG from BeamNGpy
from beamngpy import BeamNGpy
beamng = BeamNGpy("localhost", 25252, debug=True)
Launch BeamNG using command line
Windows:
Bin64\BeamNG.drive.x64.exe -tcom-listen-ip 127.0.0.1 -tcom-debug -lua extensions.tech_techCore.openServer(25252) -console
Linux:
BinLinux/BeamNG.drive.x64 -tcom-listen-ip 127.0.0.1 -tcom-debug -lua "extensions.tech_techCore.openServer(25252)"
b) Capture with custom name
You need to run BeamNG with the arguments that start the BeamNGpy server. You don’t need to run
it with the -tcom-debug
argument in this case. As an alternative, you can launch BeamNG from BeamNGpy
without any extra parameters.
BeamNGpy:
from beamngpy import BeamNGpy
beamng = BeamNGpy("localhost", 25252)
beamng.open()
Windows:
Bin64\BeamNG.drive.x64.exe -tcom-listen-ip 127.0.0.1 -lua extensions.tech_techCore.openServer(25252) -console
Linux:
BinLinux/BeamNG.drive.x64 -tcom-listen-ip 127.0.0.1 -lua "extensions.tech_techCore.openServer(25252)"
Then, you need to run the following Lua code to start the capture and start logging to the capture file of your choice:
extensions.tech_techCapture.enableRequestCapture('/path/to/outputFilenameWithoutExtension')
After you have start the capture, launch BeamNGpy, record the commands you want, and then close BeamNG and BeamNGpy.
Playing a capture (and recording responses)
To play a capture, you don’t need to have Python installed or any open TCP connections. Only the capture files created in the previous step are needed.
-
Start BeamNG (no extra arguments needed).
-
Run the following Lua code:
extensions.tech_capturePlayer.playCapture('/tcomCapture.GE.log', 'tcomOutput', -1, true)
tech_capturePlayer.playCapture(inputFilename, outputPrefix, dtBetweenRequests, mergeResponses)
inputFilename
: The name of the capture. After the first run, the captures from the main socket and the vehicle sockets are merged, therefore the/tcomCapture.*.log
intermediate files get merged into the complete/tcomCapture.log
file. Both types of captures are replayable using this function.outputPrefix
: The complete path to the output response file without the.log
extension. Ifnil
, then the responses are not logged.dtBetweenRequests
: The minimum time (in seconds) between requests that should pass. If it is set to-1
, then the timestamps from the request file are used for calculating the time between requests.mergeResponses
: Iftrue
, then the intermediate response files (/tcomOutput.*.log
) will get merged into the complete response file (/tcomOutput.log
) after the capture is finished playing.
You can check the outputs of the simulator in /tcomOutput.log
in the userfolder after the capture is finished playing.