Beispiel #1
0
def getSquareRoadScenario():
    beamng = BeamNGpy('localhost', 64256, home=getBeamngDirectory()
                      )  # This is the host & port used to communicate over
    squareRoadScenario = Scenario('smallgrid', 'Straight_Foward_Test')

    testRoad = Road('track_editor_C_center', rid='Test_Road', looped=True)
    roadNode = [(0, 0, 0, 7), (250, 0, 0, 7), (250, 250, 0, 7), (0, 250, 0, 7)]
    testRoad.nodes.extend(roadNode)

    testVehicle = Vehicle('Test_Vehicule',
                          model='etkc',
                          licence='LIFLAB',
                          colour='Blue')

    # Create an Electrics sensor and attach it to the vehicle
    electrics = Electrics()
    testVehicle.attach_sensor('electrics', electrics)

    # Create a Damage sensor and attach it to the vehicle if module is selected
    damage = Damage()
    testVehicle.attach_sensor('damage', damage)

    # Create a Gforce sensor and attach it to the vehicle if module is selected
    gForce = GForces()
    testVehicle.attach_sensor('GForces', gForce)

    squareRoadScenario.add_road(testRoad)
    squareRoadScenario.add_vehicle(testVehicle, pos=(0, 0, 0), rot=(0, 0, -90))
    scenarioDict = {
        'beamng': beamng,
        'scenario': squareRoadScenario,
        'vehicule': testVehicle
    }

    return scenarioDict
Beispiel #2
0
def getStrangeScenario():
    beamNGPAth = getBeamngDirectory()
    beamng = BeamNGpy(
        'localhost', 64256,
        home=beamNGPAth)  # This is the host & port used to communicate over
    wallCrashScenario = Scenario('smallgrid', 'road_test')
    wall = StaticObject(
        name="Crash_Test_Wall",
        pos=(10, 0, 0),
        rot=(0, 0, 0),
        scale=(1, 10, 1),
        shape='/levels/smallgrid/art/shapes/misc/gm_alpha_barrier.dae')
    testRoad = Road('track_editor_A_center', rid='Test_Road')
    roadNode = [(-10, 0, 0, 7), (20, 0, 62)]
    testRoad.nodes.extend(roadNode)
    testVehicle = Vehicle('Test_Vehicule',
                          model='etkc',
                          licence='LIFLAB',
                          colour='Blue')
    wallCrashScenario.add_road(testRoad)
    wallCrashScenario.add_object(wall)
    wallCrashScenario.add_vehicle(testVehicle,
                                  pos=(0, 0, 0),
                                  rot=(0, 180, -90))
    scenarioDict = {
        'beamng': beamng,
        'scenario': wallCrashScenario,
        'vehicule': testVehicle
    }
    return scenarioDict
Beispiel #3
0
def getStaticScenario(testName):
    beamng = BeamNGpy('localhost', 64256, home=getBeamngDirectory()
                      )  # This is the host & port used to communicate over
    staticScenario = Scenario('smallgrid', str(testName))

    testVehicle = Vehicle('Test_Vehicule',
                          model=SelectCar(),
                          licence='LIFLAB',
                          colour='Blue')

    # Create an Electrics sensor and attach it to the vehicle
    electrics = Electrics()
    testVehicle.attach_sensor('electrics', electrics)

    # Create a Damage sensor and attach it to the vehicle if module is selected
    damage = Damage()
    testVehicle.attach_sensor('damage', damage)

    # Create a Gforce sensor and attach it to the vehicle if module is selected
    gForce = GForces()
    testVehicle.attach_sensor('GForces', gForce)

    staticScenario.add_vehicle(testVehicle, (0, 0, 0), (0, 0, -90))

    scenarioDict = {
        'beamng': beamng,
        'scenario': staticScenario,
        'vehicule': testVehicle
    }

    return scenarioDict
Beispiel #4
0
def getWallCrashScenario(testName):
    beamng = BeamNGpy('localhost', 64256, home=getBeamngDirectory()
                      )  # This is the host & port used to communicate over
    wallCrashScenario = Scenario('smallgrid', str(testName))

    wall = StaticObject(
        name="Crash_Test_Wall",
        pos=(420, 0, 0),
        rot=(0, 0, 0),
        scale=(1, 10, 75),
        shape='/levels/smallgrid/art/shapes/misc/gm_alpha_barrier.dae')

    testRoad = Road('track_editor_B_center', rid='Test_Road')
    roadNode = [(-2, 0, 0, 7), (420, 0, 0, 7)]
    testRoad.nodes.extend(roadNode)

    testVehicle = Vehicle('Test_Vehicule',
                          model=SelectCar(),
                          licence='LIFLAB',
                          colour='Blue')

    # Create an Electrics sensor and attach it to the vehicle
    electrics = Electrics()
    testVehicle.attach_sensor('electrics', electrics)

    # Create a Damage sensor and attach it to the vehicle if module is selected
    damage = Damage()
    testVehicle.attach_sensor('damage', damage)

    # Create a Gforce sensor and attach it to the vehicle if module is selected
    gForce = GForces()
    testVehicle.attach_sensor('GForces', gForce)

    wallCrashScenario.add_road(testRoad)
    wallCrashScenario.add_object(wall)
    wallCrashScenario.add_vehicle(testVehicle, pos=(0, 0, 0), rot=(0, 0, -90))
    scenarioDict = {
        'beamng': beamng,
        'scenario': wallCrashScenario,
        'vehicule': testVehicle
    }

    return scenarioDict
Beispiel #5
0
def main():


    beamng = BeamNGpy('localhost', 64256,getBeamngDirectory())

    scenario = Scenario('smallgrid', 'road_test')
    vehicle = Vehicle('LIF_Mobile', model='etkc', licence='LIFLAB', colour='Blue')
    ramp = StaticObject(name='pyramp', pos=(250,0, 0), rot=(0, 0, 90), scale=(0.5, 0.5, 0.5),
                        shape='/levels/west_coast_usa/art/shapes/objects/ramp_massive.dae')
    ring = ProceduralRing(name='pyring', pos=(380, 0, 60), rot=(0, 0, 0), radius=5, thickness=2.5)

    wall= StaticObject(name="trumps_wall",pos=(420,0,0),rot=(0,0,0), scale=(1,10,75),
                       shape='/levels/smallgrid/art/shapes/misc/gm_alpha_barrier.dae')
    road_c = Road('track_editor_B_center', rid='jump_road')
    roadC_Nodes=[(-2,0,0,10),(420,0,0,7)]
    road_c.nodes.extend(roadC_Nodes)
    scenario.add_road(road_c)



    scenario.add_procedural_mesh(ring)
    scenario.add_object(ramp)
    scenario.add_object(wall)

    scenario.add_vehicle(vehicle,(0,0,0),(0,0,-90))



    scenario.make(beamng)

    bng = beamng.open(launch=True)
    try:
        bng.load_scenario(scenario)
        bng.start_scenario()
        input('Press enter when done...')
    finally:
        bng.close()
Beispiel #6
0
import time
import sys
import json
import seaborn as sns
from beamngpy import BeamNGpy, Vehicle, Scenario
from beamngpy.sensors import GForces
from beamngpy.sensors import Electrics
from beamngpy.sensors import Damage
from VehicleData import VehicleData
from BeamHome import getBeamngDirectory
from ActualisationTime import getActualisationTime


sns.set()  # Make seaborn set matplotlib styling

beamNGPAth= getBeamngDirectory()
testTime=None
dataRate=None



#if normal mode with the right number of arguments
if len(sys.argv)==3: #Command line execution
    testTime=int(sys.argv[1])#Time lenght of the test in seconds
    dataRate=int(sys.argv[2])#Number of data aquisition per second
else:
    raise Exception('Wrong number of arguments. This program takes 2 arguments and it received the following number of argument: {}.'.format(len(sys.argv)-1))

print(str(testTime))
print(str(dataRate))
actualisationTime=getActualisationTime(dataRate)
Beispiel #7
0
from BeamHome import getBeamngDirectory
import matplotlib
import numpy as np
import matplotlib.pyplot as plt

from matplotlib.pyplot import imshow
from PIL import Image
from shapely.geometry import Polygon

from beamngpy import BeamNGpy, Vehicle, Scenario, Road
from beamngpy.sensors import Camera
from getAIScript import getAIScript
beamng = BeamNGpy('localhost', 64256, getBeamngDirectory())

scenario = Scenario('smallgrid', 'vehicle_bbox_example')
road = Road('track_editor_A_center', rid='main_road')
orig = (0, -2, 0)
goal = (1150, -22, 0)
nodes = [(*orig, 7), (*goal, 7)]
road.nodes.extend(nodes)
scenario.add_road(road)

vehicle = Vehicle('ego_vehicle', model='etk800', licence='PYTHON')
overhead = Camera((0, -10, 5), (0, 1, -0.75), 60, (1024, 1024))
vehicle.attach_sensor('overhead', overhead)
scenario.add_vehicle(vehicle, pos=orig, rot=(0, 0, -90))

scenario.make(beamng)
bng = beamng.open(launch=True)
try:
    bng.load_scenario(scenario)
Beispiel #8
0
def getDonutScenario():
    beamng = BeamNGpy('localhost', 64256, home=getBeamngDirectory()
                      )  # This is the host & port used to communicate over
    donutScenario = Scenario('smallgrid', 'road_test')

    concreteWallSide1 = StaticObject(
        name="Crash_Test_Wall",
        pos=(20, 10, 0),
        rot=(0, 0, 0),
        scale=(10, 1, 1),
        shape=
        '/levels/driver_training/art/shapes/race/concrete_road_barrier_a.dae')

    concreteWallSide2 = StaticObject(
        name="Crash_Test_Wall2",
        pos=(35, -5, 0),
        rot=(0, 0, 90),
        scale=(10, 1, 1),
        shape=
        '/levels/driver_training/art/shapes/race/concrete_road_barrier_a.dae')

    concreteWallSide3 = StaticObject(
        name="Crash_Test_Wall3",
        pos=(20, -20, 0),
        rot=(0, 0, 0),
        scale=(10, 1, 1),
        shape=
        '/levels/driver_training/art/shapes/race/concrete_road_barrier_a.dae')

    concreteWallSide4 = StaticObject(
        name="Crash_Test_Wall4",
        pos=(5, -5, 0),
        rot=(0, 0, 90),
        scale=(10, 1, 1),
        shape=
        '/levels/driver_training/art/shapes/race/concrete_road_barrier_a.dae')

    testRoad = Road('track_editor_C_center', rid='Test_Road')
    roadNode = [(*(-25, 25, 0), 45), (*(15, 25, 0), 45)]
    testRoad.nodes.extend(roadNode)

    testVehicle = Vehicle('Test_Vehicule',
                          model='etkc',
                          licence='LIFLAB',
                          colour='Blue')

    # Create an Electrics sensor and attach it to the vehicle
    electrics = Electrics()
    testVehicle.attach_sensor('electrics', electrics)

    # Create a Damage sensor and attach it to the vehicle if module is selected
    damage = Damage()
    testVehicle.attach_sensor('damage', damage)

    # Create a Gforce sensor and attach it to the vehicle if module is selected
    gForce = GForces()
    testVehicle.attach_sensor('GForces', gForce)

    donutScenario.add_vehicle(testVehicle, pos=(20, 0, 0), rot=(0, 0, 0))

    donutScenario.add_object(concreteWallSide1)
    donutScenario.add_object(concreteWallSide2)
    donutScenario.add_object(concreteWallSide3)
    donutScenario.add_object(concreteWallSide4)

    donutScenario.add_road(testRoad)

    scenarioDict = {
        'beamng': beamng,
        'scenario': donutScenario,
        'vehicule': testVehicle
    }

    return scenarioDict