Esempio n. 1
0
         print '!!!! lane is none '+ str(carID)
         cars.loc[carID,'status']=1
         continue
     
     #if carLane[1] == 'o':
     #    cars.loc[carID,'status'] = 1
     cars.loc[carID,'lane'] = carLane
     cars.loc[carID,'lanepos'] = carLanePos
     cars.loc[carID,'x'] = carPos[0]
     cars.loc[carID,'y'] = carPos[1]
     cars.loc[carID,'angle'] = carAngle
     
     if carLane[1] == 'i' and len(carLane)==4: # not in intersection yet
         destlane = cars.loc[carID,'dest']
         destlane = destlane[:3] + carLane[3:]
         cars.loc[carID,'ilane'] = roadMap.combineRoad(carLane, destlane)
     elif len(carLane)==4:
         cars.loc[carID,'ilane'] = carLane
     else:
         cars.loc[carID, 'ilane'] = carLane
 
 # cars that collided last time are now completely removed
 carsThatCollidedLastStep = np.where(cars['status']>=2)[0]
 for carID in carsThatCollidedLastStep:
     
     cars.loc[carID, 'status'] = 1
     Sim.removeVehicle(str(carID))
 
 # check for collisions
 activeCars = np.where(cars['status']==0)[0]
 for carNum in range(len(activeCars)):
Esempio n. 2
0
                continue

            #if carLane[1] == 'o':
            #    cars.loc[carID,'status'] = 1
            cars.loc[carID, 'lane'] = carLane
            cars.loc[carID, 'lanepos'] = carLanePos
            cars.loc[carID, 'x'] = carPos[0]
            cars.loc[carID, 'y'] = carPos[1]
            cars.loc[carID, 'angle'] = carAngle

            if carLane[1] == 'i' and len(
                    carLane) == 4:  # not in intersection yet
                destlane = cars.loc[carID, 'dest']
                destlane = destlane[:3] + carLane[3:]
                cars.loc[carID,
                         'ilane'] = roadMap.combineRoad(carLane, destlane)
            elif len(carLane) == 4:
                cars.loc[carID, 'ilane'] = carLane
            else:
                cars.loc[carID, 'ilane'] = carLane

        # cars that collided last time are now completely removed
        carsThatCollidedLastStep = np.where(cars['status'] >= 2)[0]
        for carID in carsThatCollidedLastStep:

            cars.loc[carID, 'status'] = 1
            Sim.removeVehicle(str(carID))

        # check for collisions
        activeCars = np.where(cars['status'] == 0)[0]
        for carNum in range(len(activeCars)):