A runned a few simulations under same conditions, and I see that the vehicle did differents routes, when using the traffic AI setting. Is is there anyway to set this route to be deterministic?
Also, I’m working without UI, and I don’t have acess to coordenates to spawn the vehicle, using only the given in the repository’s examples
This is expected behavior. In AI traffic mode, there’s some built-in randomization in the paths vehicles take to ensure more natural and varied traffic flow, rather than having all vehicles follow the exact same route.
To better assist, it would be helpful to understand what you’re trying to achieve. That way, we can suggest the most appropriate solution for your use case.
My intention is to perform a trip (relatively long) and replicate it, changing some parameters, preserving the same route (i.e., changing the vehicle’s model, agressivity).
I’ve already tried using the set_line method. I ran the base simulation, reporting every triplet of x,y, and z positions, and built a list of n dictionaries having the coordinates and speed, passing it as a parameter to the set_line.
When running the second simulation using the set_line(list_of_dictionaries), with approximately 10000 entries, the main loop of data collecting becomes slow. Alternatively, I tried building the list_of_dictionaries, getting every 1000, and, although it becomes faster, it does not take the exact same route, so I discarded that approach as a solution.
Is there any built-in solution for this case? In case not, which recommendation would you do?
Yes, in BeamNGpy there are several AI control methods depending on whether you’re working with a single waypoint, a route, or a full custom driving trajectory:
To configure and manage multiple vehicles with different AI behaviors, BeamNGpy includes a TrafficConfig utility. This allows vehicles to be set up with:
Basic AI (speed, aggression, lane-following)
Scripted path following
For your specific use case, TrafficConfig supports driving along custom paths by setting aiType to “script” in the traffic configuration JSON. Internally it uses:
veh_data[“aiType”] == “script”:
Example of TrafficConfig in use:
Implementation:
Full AI API reference:
These interfaces allow you to set up and run deterministic scripted routes across multiple vehicles for controlled, repeatable simulation in BeamNG.tech.
Best regards,
Abdulrahman Saeed
Research Software Engineer
BeamNG.tech Support Team
I was reviewing the options you mentioned and I saw that my case aligns with the vehicle.ai.drive_using_waypoints([…]) method. I tested this method, but I noticed that even with avoid_vehicle set to true, the vehicle still collides with others in the scenario, because apparently reaching the waypoint has the highest priority.
Is there any way to avoid these collisions?
Any alternative to avoid_vehicle?
I have already set the aggression to 0.3 and the maximum speed to 50 km/h.
Hello @erick1-618,
you can add a waypoint through WorldEditor, from the top icons, find “Create Object” > '“BeamNG” > “Waypoint”, then you can add it to the map by moving your cursor to the desired point.
Hello @Helio.
We have a limitation of avoid_cars option, that it could cause ‘small’ crashes, like a slight bumping into other vehicles, as a workaround, try use ScriptAI editor tool to create your scenario as you need, by drowing or recording you time-based or velocity based path.