question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using BeamNGpy to control scenario start routine

See original GitHub issue

Hi,

I was wondering if it is possible to use BeamNGpy to control the scenario start routine including the initial message which is shown to the user.

self.beamng.load_scenario(scenario)
self.beamng.start_scenario()
self.beamng.switch_vehicle(vehicle=player_vehicle)

For example, when I was testing the above with BeamNG.tech.v0.25.4.0 sometimes it would show the scenario start message, but other times it would show briefly and go away and give the player direct control of the vehicle without interacting with the GUI.

Would it be possible to:

  • configure scenario start message, including title and description?
  • configure if the GUI appears or not (i.e. completely disable it)?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
aivora-beamngcommented, Aug 23, 2022

The only small thing which I noticed was that if the player clicks ESC key ➡️ pause menu ➡️ ESC key again to go back, then the scenario start dialog with Start button appears again. I was expecting the start_scenario() method to clear that once and for all.

Ah, I see, thanks for reporting! Unfortunately, this is a bug. It will be fixed in the next major release.

I also have another question regarding the Scenario class, what are checkpoints? and how do checkpoints differ from waypoints?

The waypoints field in the Scenario class is unused (we’ll remove it to decrease confusion). To get the waypoints of a scenario, you can call the function Scenario.find_waypoints().

Waypoints are nodes of the navgraph - you can think of them as named positions in a map. If you call find_waypoints, you’ll see that there are tens of waypoints already predefined on most of the maps.

Checkpoints of a scenario are positions that are needed to be driven through in order to finish a scenario. To create checkpoints in your scenario, you can call the function Scenario.add_checkpoints (see the example below).

If you run the example, you can see that every checkpoint created through the add_checkpoints function has its associated waypoint.

from beamngpy import BeamNGpy, Scenario, Vehicle

bng = BeamNGpy('localhost', 64256)
bng.open()

scenario = Scenario('west_coast_usa', 'waypoint demo')
vehicle = Vehicle('ego', model='etk800')
scenario.add_vehicle(vehicle, pos=(-712.76, 105.05, 118.66), rot_quat=(0.0010, 0.0057, 0.9187, -0.3949))

positions = [(-705.03, 112.40, 118.67), (-696.67, 120.39, 118.65), (-687.03, 129.76, 118.15)]
scales = [(1, 1, 1)] * 3
ids = ['my_waypoint_1', 'my_waypoint_2', 'my_waypoint_3']
scenario.add_checkpoints(positions, scales, ids)
scenario.make(bng)

bng.load_scenario(scenario)
bng.start_scenario()

waypoints = {waypoint.name: waypoint for waypoint in scenario.find_waypoints()}
print(f'{len(waypoints)} waypoints found.')
print(f'Waypoints: [', ', '.join(waypoints.keys()), ']')

vehicle.ai_drive_in_lane(True)
vehicle.ai_set_waypoint('my_waypoint_3')
0reactions
purple-meshcommented, Aug 25, 2022

@aivora-beamng thanks for the explanation and demo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BeamNGpy/guide.md at master - GitHub
This guide helps exploring the collection and can help in finding examples for specific problems and features. For getting started we suggest taking...
Read more >
BeamNG GmbH - BeamNGpy
for example, run a scenario in which each vehicle is controlled by a ... We have a guide helping you getting started and...
Read more >
BeamNG.drive Script AI: Advanced Tutorial & Techniques
This video will give you an overview of some of the more advanced techniques of using the Script AI Manager in BeamNG.drive.
Read more >
DriveBuild Automation of Simulation-based Testing of ...
However, any subset of test cases involves AIs which control AVs. ... of CommonRoad scenarios with a guaranteed high accuracy.
Read more >
(PDF) DriveBuild: Automation of Simulation-based Testing of ...
However, any subset of test cases involves AIs which control AVs. These AIs ... of CommonRoad scenarios with a guaranteed high accuracy.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found