Coder Social home page Coder Social logo

Comments (2)

pascale-commits avatar pascale-commits commented on July 17, 2024 1

I wrote a small example, which includes spawning after scenario creation, though it is not available on the dev branch yet, but you can find it here: examples/spawning.ipynb. You will have to change the rotation specification for it to work in your beamngpy version right now, or you wait for it to be integrated into dev/master :)

from beamngpy.

pascale-commits avatar pascale-commits commented on July 17, 2024

There are two options to generate assets through the BeamNG library BEFORE scenario generation:

  1. Using the various available procedural objects (ProceduralCylinder, ProceduralCone, ProceduralCube) for which you can find an example here: examples/procedural_meshes.py
  2. Using the ScenarioObject class to spawn any asset available in the game. Here is a minimal example:
from beamngpy import BeamNGpy, Vehicle, Scenario, ScenarioObject

beamng = BeamNGpy('localhost', 64256)

scenario = Scenario('east_coast_usa', 'spawn_objects_example')

vehicle_pos = (647.596008,-145.919678,53.4411545)
vehicle_rot = (0.00938976184,-0.00648232969,0.325634241)
vehicle = Vehicle('ego_vehicle', model='pickup', licence='PYTHON')
scenario.add_vehicle(vehicle, pos=vehicle_pos, rot=vehicle_rot)

rb_pos = (640.05011,-156.296127,53.5653763)
rot = (0,0,0)
scenario_obj = ScenarioObject(oid='roadblock', 
                              name='sawhorse',
                              otype='BeamNGVehicle',
                              pos=rb_pos,
                              rot=rot,
                              scale=(1, 1, 1),
                              JBeam = 'sawhorse',
                              datablock="default_vehicle"
                              )
scenario.add_object(scenario_obj)

scenario.make(beamng)

bng = beamng.open()
bng.load_scenario(scenario)
bng.start_scenario()

Concerning the generation of assets AFTER scenario creation, i.e. in-game:
It is possible to spawn assets of type BeamNGVehicle during the simulation with the spawn_vehicle and despawn_vehicle function of the BeamNGpy class. I'll write an example for that as well in the near future :-)

Hope that helps!

from beamngpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.