beamngpy: spawn two vehicles not working

Discussion in 'Programming' started by benjiiiii, Mar 9, 2019.

  1. benjiiiii

    Expand Collapse

    Mar 9, 2019
    Hi All

    We are now trying for a while to spawn two vehicles in one scene, somehow this does not work
    and it throws an error. When we comment out `vehicle2 = Vehicle('other', model='piano', licence='CRASH')` and `vehicle2.ai_set_mode('disabled')` the code works, but obviously we then only have one vehicle. Could someone help us to understand why we can only load one vehicle?


    # Instantiate BeamNGpy instance running the simulator from the given path,
            # communicating over localhost:64256
            bng = BeamNGpy('localhost', 64256, home=r'.\\research-14\\trunk')
            # Create a scenario in west_coast_usa called 'example'
            scenario = Scenario('smallgrid', 'car crash simulaton')
            # Create an ETK800 with the licence plate 'PYTHON'
            vehicle = Vehicle('ego_vehicle', model='etk800', licence='PYTHON')
            vehicle2 = Vehicle('other', model='piano', licence='CRASH')
            # Add it to our scenario at this position and rotation
            scenario.add_vehicle(vehicle, pos=(0, 0, 0), rot=(0, 0, 0))
            scenario.add_vehicle(vehicle2, pos=(0, 2000, 0), rot=(0, 0, 90))
            # Place files defining our scenario for the simulator to read
            # Launch BeamNG.research
            # Load and start our scenario
            # Make the vehicle's AI span the map
            road_a = Road('track_editor_C_center', looped=True)
            nodes = [
                (0, 0, 0, 0),
                (0, 90, 300, 1)
            vehicle.control(gear=2, throttle=1)
            while 1:
                vehicle.control(gear=2, throttle=1)
    And here is the error we are getting:

    002.071|D|StandardMainLoop::doMainLoop|Started up in 2.06 seconds...
    002.113|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    002.117|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    002.131|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    002.132|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    002.190|D|GELua.bindings|Registered new action map: RoadEditorActionMap
    002.192|D|GELua.bindings|Registered new action map: ReplayPlaybackActionMap
    002.195|D|GELua.bindings|Registered new action map: ExplorationGeneralActionMap
    002.279|D|SFXFMODProject::acquire|SFXFMODProject: Opened project 'art/sound/FMOD/Desktop/' in 0.074364 seconds.
    002.459|D|SFXFMODProject::acquire|SFXFMODProject: Opened project 'art/sound/FMOD/Desktop/' in 0.038858 seconds.
    002.658|D|SFXFMODProject::acquire|SFXFMODProject: Opened project 'art/sound/FMOD/Desktop/' in 0.098020 seconds.
    002.872|D|Win32Window::setVideoMode|AntialiasLevel: 4,BitDepth: 32,FullScreen: 0, RefreshRate: 59, Resolution: 1824x824, wideScreen: 0
    002.875|D|GFXD3D11WindowTarget::resetMode|setting video mode: Width 1824, Height 824, Format 1, Windowed 2000
    002.898|D|GFXD3D11WindowTarget::resetMode|setting video mode: Width 1800, Height 760, Format 1, Windowed 2000
    003.030|D|SFXSystem::createDevice|Using default audio device: Speakers (Realtek High Definition Audio(SST))
    003.038|D|GFXD3D11WindowTarget::resetMode|setting video mode: Width 1824, Height 824, Format 1, Windowed 2000
    003.373|E|BEAMNGCEF::BNGCefClient::OnResourceResponse|MainGEUI | local://local/ui/modules/lightrunner/lightrunner.js | response: 404 - ERROR
    003.740|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    003.743|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    003.749|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    003.757|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    003.834|D|GELua.core_gamestate.gamestate|show main menu (true)
    003.890|D|GELua.core_gamestate.gamestate|ui finished loading
    004.029|D|GELua.core_modmanager.modmanager.initDB|Notification : took 0.0013ms to reorganise 0 files
    004.030|D|GELua.core_modmanager.modmanager.initDB|Notification : took 1.593ms to callback
    004.034|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    004.036|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    004.070|E|GELua.extensions|extension unavailable: telemetry_gameTelemetry at location: telemetry/gameTelemetry
    004.074|E|GELua.extensions|extension unavailable: editor_main at location: editor/main
    004.138|D|CEF.local://local/ui/lib/int/logger.js:70|MainGEUI | [Console] Expected AppLayout but didn't get one :-(
    004.262|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    004.265|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    004.293|D|CEF.local://local/ui/lib/int/beamng-core.js:375|MainGEUI | invalid image data: imageurls =
    005.032|I|GELua.util_researchGE.ResearchGE|Trying to connect to: localhost:64256
    006.067|D|GELua.extensions|unloadInternal: core_repository
    006.092|D|GELua.scenario_scenarios.scenarios|loading level: levels/smallgrid/main.level.json
    006.094|D|GELua.core_gamestate.gamestate|loading screen request from: levels; value before was: nil
    006.096|D|GELua.core_gamestate.gamestate|sending show loading screen
    006.098|D|GELua.core_gamestate.gamestate|ui initialised (true)
    006.100|D|GELua.core_gamestate.gamestate|waiting for ui (false)
    006.107|D|GELua.core_gamestate.gamestate|loading screen request from: server.lua; value before was: nil
    006.110|D|GELua.core_gamestate.gamestate|ui initialised (true)
    006.112|D|GELua.core_gamestate.gamestate|waiting for ui (false)
    006.115|D|GELua.core_gamestate.gamestate|loading screen request from: worldReadyState; value before was: nil
    006.117|D|GELua.core_gamestate.gamestate|ui initialised (true)
    006.131|D|GELua.core_gamestate.gamestate|waiting for ui (false)
    006.133|D|GELua.core_gamestate.gamestate|exiting : levels
    006.492|D|GELua.core_gamestate.gamestate|ui told us loading screen is now loaded
    006.532|D|SFXFMODProject::acquire|SFXFMODProject: Opened project 'art/sound/FMOD/Desktop/' in 0.038412 seconds.
    006.725|I|GELua.main|Loading default vehicle
    006.728|I|GELua.main|Loading the default vehicle etk800
    006.909|I|GELua.missionLoad.lua|*** loading mission: levels/smallgrid/main.level.json
    007.155|I|GELua.missionLoad.lua|*** Mission loaded: levels/smallgrid/main.level.json
    007.157|D|GELua.serverConnection|Everything should be loaded setting worldReadyState to 1
    007.159|D|GELua.scenario_scenarios.scenarios|changeState: pre-start
    007.162|D|GELua.spawn.lua|not spawning player upon request
    007.163|D|GELua.core_gamestate.gamestate|exiting : server.lua
    007.167|D|GELua.clientStartMission|starting mission: levels/smallgrid/main.level.json
    007.174|D|GELua.scenario_scenarios.scenarios|Starting scenario : car crash simulaton
    007.177|D|GELua.scenario_scenarios.scenarios|Scenario path : levels/smallgrid/scenarios/car crash simulaton.json
    007.179|D|GELua.scenario_scenarios.scenarios|spawning prefabs ...
    007.181|D|GELua.lua|adding prefab car crash simulaton
    007.184|D|GELua.lua|loading prefab car crash simulaton
    007.188|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    007.190|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    007.192|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    007.194|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    007.199|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    007.201|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    007.206|I|BeamNGVehicle::spawnObject|Spawning object 'etk800' with config: vehicles/etk800/etk854t_A.pc
    007.277|D|libbeamng.lua.V.default.init|spawning vehicle vehicles/etk800/
    007.338|D|libbeamng.lua.V.default.init|  using partconfig filename vehicles/etk800/etk854t_A.pc - path:vehicles/etk800/
    008.292|D|libbeamng.lua.V.vehicleController.settingsChanged|NOT refreshing settings before access
    008.426|I|GELua.main|Player #0 vehicle switched from: nil to: id 5088 (vehicles/etk800/)
    008.476|D|DirectInputDevice::setupForceFeedback|No matches found for player 0, desc 'xaxis', device 'mouse0' (abandoning search on this device)
    008.477|D|DirectInputDevice::setupForceFeedback|No matches found for player 0, desc 'xaxis', device 'keyboard0' (abandoning search on this device)
    008.937|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    008.940|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    008.948|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    008.950|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    008.955|W|ConsoleTypeTypeColorF::setData|TypeColorF() - Invalid single argument of 'None' could not be interpreted as a stock color name.  Using default.
    008.960|W|StockColor::colorF|Could not find stock color name 'None', defaulting to 'White'
    008.965|D|GELua.main|prefabLoaded: 5086,"car crash simulaton"
    009.000|D|GELua.core_camera.|Camera switched to "orbit"
    010.781|I|GELua.util_researchGE.ResearchGE|Setting engine flags!
    010.784|D|GELua.scenario_scenarios.scenarios|processing vehicles. Found 2 vehicles
    010.788|D|GELua.scenario_scenarios.scenarios|5088 = ego_vehicle
    010.790|D|GELua.scenario_scenarios.scenarios|5481 = other
    010.798|E|GameEngineLua:Exception|[string "lua/ge/extensions//scenario/scenarios.lua"]:722: attempt to index local 'vehicle' (a nil value)
    =============== Stack Traceback >> START >>
    (1) metamethod C function '__index'
    (2) Lua upvalue 'processObjectsStartingTransform' at line 722 of chunk '"lua/ge/extensions//scenario/scenarios.lua"]'
      Local variables:
      (for generator) = C function: next
      (for state) = table: 0x021193f2e748  {ego_vehicle:5088, other:5481}
      (for control) = userdata: 0x7fff00000002
      vecName = string: "other"
      vid = number: 5481
      vehicle = nil
      (*temporary) = table: 0x0211941633e8  {ego_vehicle:table: 0x021194163478}
      (*temporary) = table: 0x0211941635e0  {}
      (*temporary) = number: 5481
      (*temporary) = nil
      (*temporary) = nil
      (*temporary) = string: "attempt to index local 'vehicle' (a nil value)"
    (3) Lua upvalue 'completeStartUp' at line 853 of chunk '"lua/ge/extensions//scenario/scenarios.lua"]'
    (4) Lua upvalue 'tickPreStart' at line 1515 of chunk '"lua/ge/extensions//scenario/scenarios.lua"]'
      Local variables:
      dt = number: 4.24526
      dtSim = number: 0.00662263
    (5) Lua function '?' at line 2053 of chunk '"lua/ge/extensions//scenario/scenarios.lua"]'
      Local variables:
      dt = number: 4.24526
      dtSim = number: 0.00662263
    (6) Lua field 'hook' at line 454 of chunk '"lua/common/extensions.lua"]'
      Local variables:
      func = string: "onPreRender"
      funcList = table: 0x0211a2034ab8  {1:function: 0x021193e04b90, 2:function: 0x0211a2025058, 3:function: 0x021193ddc888 (more...)}
      (for index) = number: 6
      (for limit) = number: 10
      (for step) = number: 1
      i = number: 6
    (7) Lua function 'luaPreRender' at file 'lua/ge/main.lua:360' (best guess)
      Local variables:
      dtReal = number: 4.24526
      dtSim = number: 0.00662263
      dtRaw = number: 4.24526
    --------------- << END <<
    010.900|D|Material::_mapMaterial|[Material::mapMaterial] - Cannot map unnamed Material - scripts/client/beamng.cs
    011.094|D|GELua.gamestate|Checking material finished loading
    011.104|D|libbeamng.lua.V.hydros.init|Response to FFB config request: nil
    011.106|D|GELua.core_gamestate.gamestate|exiting : worldReadyState
    011.107|D|GELua.core_gamestate.gamestate|show main menu (false)
    011.108|D|GELua.core_gamestate.gamestate|exiting loading screen to menu
    011.505|E|GELua.core_levels.levels|info.json missing: /levels/garage/info.json
    011.507|E|GELua.core_levels.levels|No entry point for level found: /levels/garage. Ignoring level.
    011.512|D|CEF|VehicleTex-@etk800_gauges_screen | Uncaught ReferenceError: VehicleInfo is not defined
    011.514|D|CEF.local://local/vehicles/common/ETK_navi_screen.html:151|VehicleTex-@etk800_screen | Received empty map data
    011.521|D|CEF|VehicleTex-@licenseplate-default-normal | Uncaught ReferenceError: VehicleInfo is not defined
    011.524|D|CEF|VehicleTex-@etk800_screen | Uncaught ReferenceError: VehicleInfo is not defined
    011.527|D|CEF|VehicleTex-@licenseplate-default | Uncaught ReferenceError: VehicleInfo is not defined
    011.529|D|CEF|VehicleTex-@licenseplate-default-specular | Uncaught ReferenceError: VehicleInfo is not defined
    012.777|I|libbeamng.lua.V.ResearchVE|Trying to connect to: localhost:64257
    013.818|I|GELua.util_researchGE.ResearchGE|Setting engine flags!
  2. Signaltonsalat

    Expand Collapse
    Staff Member

    May 24, 2018
    Hello, by default, .research only allows for a single vehicle. Contact us at with what you're trying to do and we can work something out. Thanks!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice