'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)}
intersections   =    [['1i_0','3o_0'] , #['1i_0','2o_1'] ,
                      ['1i_0','2o_0'] , ['1i_1','4o_1'] ,
                      ['2i_0','4o_0'] , #['2i_0','1o_1'] ,
                      ['2i_0','1o_0'] , ['2i_1','3o_1'] ,
                      ['3i_0','2o_0'] , #['3i_0','4o_1'] ,
                      ['3i_0','4o_0'] , ['3i_1','1o_1'] ,
                      ['4i_0','1o_0'] , #['4i_0','3o_1'] ,
                      ['4i_0','3o_0'] , ['4i_1','2o_1'] ]  
roadMap = RoadMap(roads, intersections)
roadOrder = pd.DataFrame({'left':[4,3,1,2],'right':[3,4,2,1],
                          'straight':[2,1,4,3]},index=[1,2,3,4])
                          
def combineRoad(inroad, outroad):
    if any(list(inroad==i and outroad==j for i,j in intersections)):
        return inroad + '_' + outroad
    return None
    
class WriteFrame: # makes repeatedly adding to data frame easier
    def __init__(self, colnames=None):
        self.colnames = colnames
        self.restart=True
    def add(self, newrows):
        if self.restart:
            self.df = pd.DataFrame(newrows)
Esempio n. 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)}
intersections   =    [['1i_0','3o_0'] , #['1i_0','2o_1'] ,
                      ['1i_0','2o_0'] , ['1i_1','4o_1'] ,
                      ['2i_0','4o_0'] , #['2i_0','1o_1'] ,
                      ['2i_0','1o_0'] , ['2i_1','3o_1'] ,
                      ['3i_0','2o_0'] , #['3i_0','4o_1'] ,
                      ['3i_0','4o_0'] , ['3i_1','1o_1'] ,
                      ['4i_0','1o_0'] , #['4i_0','3o_1'] ,
                      ['4i_0','3o_0'] , ['4i_1','2o_1'] ]  
roadMap = RoadMap(roads, intersections)

#intersectionInfo = pd.read_csv('collisionsFile_OwnSim.csv',header=0)
intersectionInfo = pd.read_csv('collisionsFile_Quad.csv',header=0) 
   
def splitRoad(lane):
    if len(lane)==9: # internal lane for intersection
        #inroute,ingrade,inlane = splitRoad(lane[:4])
        return [lane[:4], 1, lane[5:]]
    elif len(lane)==4: # starting or ending road
        if lane[1] == 'i':
            grade = 0
        elif lane[1] == 'o':
            grade = 2
    return [int(lane[0]), grade, int(lane[3])]