Exemple #1
0
from subprocess import call as terminalCall
if os.name == 'posix':  # unix
    terminalCall(['mkdir', '-p', os.path.realpath(outputFolder)])
else:
    terminalCall(['mkdir', os.path.realpath(outputFolder)], shell=True)

import pandas as pd
params = pd.read_csv(parametersFile)

# setup
roads = {
    'main': (0., 2., 1300., 2.),
    'oncoming': (1300., 5.2, 0., 5.2),
    'overtaking': (0., 5.2, 1300., 5.2)
}
roadMap = RoadMap(roads, [])


class Output:
    def __init__(self, colnames):
        self.df = None
        self.colnames = colnames

    def add(self, newrow):
        if self.df is None:
            self.df = pd.DataFrame([newrow])
        else:
            self.df = self.df.append([newrow])

    def write(self, fileName, restart=False):
        self.df.columns = self.colnames
Exemple #2
0
    '2o_1': (108, 98.35, 200, 98.35),
    '1o_0': (92, 105, 0, 105),
    '1o_1': (92, 101.65, 0, 101.65),
    '4o_0': (105, 108, 105, 200),
    '4o_1': (101.65, 108, 101.65, 200),
    '3o_0': (95, 92, 95, 0),
    '3o_1': (98.35, 92, 98.35, 0)
}

# which roads connect to other roads
intersections = [['1i_0', '3o_0'], ['1i_0', '2o_0'], ['1i_1', '4o_1'],
                 ['2i_0', '4o_0'], ['2i_0', '1o_0'], ['2i_1', '3o_1'],
                 ['3i_0', '2o_0'], ['3i_0', '4o_0'], ['3i_1', '1o_1'],
                 ['4i_0', '1o_0'], ['4i_0', '3o_0'], ['4i_1', '2o_1']]

roadMap = RoadMap(roads, intersections)

Sim = Simulator(roadMap, gui=GUI, delay=SIMDELAY)
Sim.createVehicle('mycar', '1i_0', 50.)

Sim.moveVehicle('mycar', '1i_1', 50.)
for k in range(20):
    exited = Sim.moveVehicleAlong('mycar', 5., '4o_1')

    carLane, carLanePos, carPos, carAngle = Sim.getVehicleState('mycar')
    print carPos

    manual_escape = Sim.updateGUI(allowPause=True)
    if exited or manual_escape:
        break